Maps type names to field component types for the Card View component.

Class members

Methods

  • getComponentTypeResolver(type: string, defaultValue: Type<any> = this.defaultValue): DynamicComponentResolveFunction
    Gets the currently active DynamicComponentResolveFunction for a field type.
    • type: string - The type whose resolver you want
    • defaultValue: Type<any> - Default type returned for types that are not yet mapped
    • Returns DynamicComponentResolveFunction - Resolver function
  • register(components: Function, override: boolean = false)
    Register multiple components
    • components: Function -
    • override: boolean -
  • resolveComponentType(model: DynamicComponentModel, defaultValue: Type<any> = this.defaultValue): Type<any>
    Finds the component type that is needed to render a form field.
    • model: DynamicComponentModel - Form field model for the field to render
    • defaultValue: Type<any> - Default type returned for field types that are not yet mapped.
    • Returns Type<any> - Component type
  • setComponentTypeResolver(type: string, resolver: DynamicComponentResolveFunction, override: boolean = true)
    Sets or optionally replaces a DynamicComponentResolveFunction for a field type.
    • type: string - The type whose resolver you want to set
    • resolver: DynamicComponentResolveFunction - The new resolver function
    • override: boolean - The new resolver will only replace an existing one if this parameter is true

Details

The Card View component uses this service to find the component type that is required to display a particular field type (text, date, etc). The service maps a type name string to a corresponding DynamicComponentResolveFunction that takes a model object as a parameter and returns the component type needed to display that model.

The default mapping is shown below:

Adding new type mappings

You can define your own custom field types for the Card View (see the Card View Item interface page for full details of how to do this). When you have defined the field component, you need to register it with the Card Item Types service so that the Card View component can make use of it:

@Component({
    ...
    providers: [ CardItemTypeService ] /* If you don't want to pollute the main instance of the CardItemTypeService service */
    ...
})
class SomeParentComponent {

    constructor(private cardItemTypeService: CardItemTypeService) {
        cardItemTypeService.setComponentTypeResolver('star-date', () => CardViewStarDateItemComponent);
    }
}

See also

© 2023 Alfresco Software, Inc. All Rights Reserved.