Class

ModelPage

ModelPage(operation, modelName, modelId)

Constructor

# new ModelPage(operation, modelName, modelId)

The ModelPage component provides a comprehensive interface for performing Create, Read, Update, and Delete operations on any registered model entity within the Decaf framework. This component dynamically adapts to different model types and operations, providing a unified interface for data manipulation. It integrates with the repository pattern for data access, supports real-time data refresh, and provides user feedback through toast notifications and navigation management.

Key features include:

  • Dynamic model resolution based on model name
  • Support for all CRUD operations with operation-specific UI adaptation
  • Automatic repository instantiation and management
  • Integration with Angular routing for navigation flow
  • Error handling with comprehensive logging
  • Real-time data refresh and cache management
  • Toast notifications for user feedback
  • Responsive layout with Ionic components

Angular component page for CRUD operations on dynamic model entities.

sequenceDiagram participant U as User participant MP as ModelPage participant R as Repository participant RS as RouterService participant T as ToastComponent participant L as Logger U->>MP: Navigate to page MP->>MP: ngOnInit() MP->>L: Initialize logger MP->>MP: ionViewWillEnter() MP->>MP: Set allowed operations MP->>MP: refresh(modelId) alt Operation is READ/UPDATE/DELETE MP->>R: handleGet(modelId) R->>R: read(modelId) R-->>MP: Return model data MP->>MP: Set model end U->>MP: Submit form MP->>MP: handleEvent(submitEvent) MP->>MP: handleSubmit(event) MP->>MP: parseData(event.data) alt Operation is CREATE MP->>R: create(data) else Operation is UPDATE MP->>R: update(data) else Operation is DELETE MP->>R: delete(data) end R-->>MP: Return operation result MP->>R: refresh(modelName, operation, modelId) MP->>RS: backToLastPage() MP->>T: inform(success message) alt Error occurs MP->>L: error(error) MP->>MP: throw Error end
Parameters:
Name Type Description
operation OperationKeys

The CRUD operation to perform (CREATE, READ, UPDATE, DELETE)

modelName string

The name of the model class to operate on

modelId string

The unique identifier of the model instance for read/update/delete operations

View Source app/pages/model/model.page.ts, line 18

Example
```typescript
// Usage in routing configuration
{
  path: 'user/:modelId',
  component: ModelPage,
  data: {
    modelName: 'User',
    operation: OperationKeys.READ
  }
}

// Direct component usage
<app-model
  modelName="Product"
  [operation]="OperationKeys.CREATE"
  (submit)="handleSubmit($event)">
</app-model>
```

Members

Array.<OperationKeys>

# static allowedOperations

Dynamically determined list of operations that are permitted based on the current context and model state. Initially contains CREATE and READ operations, with UPDATE and DELETE added when a modelId is present. This controls which action buttons are displayed and which operations are accessible to the user.

Array of operations allowed for the current model instance.

Default Value:
  • [OperationKeys.CREATE, OperationKeys.READ]

View Source lib/engine/NgxModelPageDirective.ts, line 61

string

# static modelName

Identifies which registered model class this component should work with. This name is used to resolve the model constructor from the global model registry and instantiate the appropriate repository for data operations. The model must be properly registered using the @Model decorator for resolution to work.

The name of the model class to operate on.

View Source lib/engine/NgxModelPageDirective.ts, line 49

OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE

# static operation

Specifies which operation (Create, Read, Update, Delete) this component instance should perform. This determines the UI behavior, form configuration, and available actions. The operation affects form validation, field availability, and the specific repository method called during data submission.

The CRUD operation type to be performed on the model.

Default Value:
  • OperationKeys.READ

View Source lib/engine/NgxModelPageDirective.ts, line 38

ModelPage(operation, modelName, modelId)

Constructor

# new ModelPage(operation, modelName, modelId)

The ModelPage component provides a comprehensive interface for performing Create, Read, Update, and Delete operations on any registered model entity within the Decaf framework. This component dynamically adapts to different model types and operations, providing a unified interface for data manipulation. It integrates with the repository pattern for data access, supports real-time data refresh, and provides user feedback through toast notifications and navigation management.

Key features include:

  • Dynamic model resolution based on model name
  • Support for all CRUD operations with operation-specific UI adaptation
  • Automatic repository instantiation and management
  • Integration with Angular routing for navigation flow
  • Error handling with comprehensive logging
  • Real-time data refresh and cache management
  • Toast notifications for user feedback
  • Responsive layout with Ionic components

Angular component page for CRUD operations on dynamic model entities.

sequenceDiagram participant U as User participant MP as ModelPage participant R as Repository participant RS as RouterService participant T as ToastComponent participant L as Logger U->>MP: Navigate to page MP->>MP: ngOnInit() MP->>L: Initialize logger MP->>MP: ionViewWillEnter() MP->>MP: Set allowed operations MP->>MP: refresh(modelId) alt Operation is READ/UPDATE/DELETE MP->>R: handleGet(modelId) R->>R: read(modelId) R-->>MP: Return model data MP->>MP: Set model end U->>MP: Submit form MP->>MP: handleEvent(submitEvent) MP->>MP: handleSubmit(event) MP->>MP: parseData(event.data) alt Operation is CREATE MP->>R: create(data) else Operation is UPDATE MP->>R: update(data) else Operation is DELETE MP->>R: delete(data) end R-->>MP: Return operation result MP->>R: refresh(modelName, operation, modelId) MP->>RS: backToLastPage() MP->>T: inform(success message) alt Error occurs MP->>L: error(error) MP->>MP: throw Error end
Parameters:
Name Type Description
operation OperationKeys

The CRUD operation to perform (CREATE, READ, UPDATE, DELETE)

modelName string

The name of the model class to operate on

modelId string

The unique identifier of the model instance for read/update/delete operations

View Source app/pages/products/products.page.ts, line 21

Example
```typescript
// Usage in routing configuration
{
  path: 'user/:modelId',
  component: ModelPage,
  data: {
    modelName: 'User',
    operation: OperationKeys.READ
  }
}

// Direct component usage
<app-model
  modelName="Product"
  [operation]="OperationKeys.CREATE"
  (submit)="handleSubmit($event)">
</app-model>
```

Members

Array.<OperationKeys>

# static allowedOperations

Dynamically determined list of operations that are permitted based on the current context and model state. Initially contains CREATE and READ operations, with UPDATE and DELETE added when a modelId is present. This controls which action buttons are displayed and which operations are accessible to the user.

Array of operations allowed for the current model instance.

Default Value:
  • [OperationKeys.CREATE, OperationKeys.READ]

View Source lib/engine/NgxModelPageDirective.ts, line 61

string

# static modelName

Identifies which registered model class this component should work with. This name is used to resolve the model constructor from the global model registry and instantiate the appropriate repository for data operations. The model must be properly registered using the @Model decorator for resolution to work.

The name of the model class to operate on.

View Source lib/engine/NgxModelPageDirective.ts, line 49

OperationKeys.CREATE | OperationKeys.READ | OperationKeys.UPDATE | OperationKeys.DELETE

# static operation

Specifies which operation (Create, Read, Update, Delete) this component instance should perform. This determines the UI behavior, form configuration, and available actions. The operation affects form validation, field availability, and the specific repository method called during data submission.

The CRUD operation type to be performed on the model.

Default Value:
  • OperationKeys.READ

View Source lib/engine/NgxModelPageDirective.ts, line 38