Welcome to the Alfresco Builder Network

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

Class members

Methods

  • getComponentTypeResolver(type: string, defaultValue: Type<__type> = this.defaultValue): DynamicComponentResolveFunction
    Gets the currently active DynamicComponentResolveFunction for a field type.
    • type: string - The type whose resolver you want
    • defaultValue: Type<__type> - Default type returned for types that are not yet mapped
    • Returns DynamicComponentResolveFunction - Resolver function
  • resolveComponentType(model: DynamicComponentModel, defaultValue: Type<__type> = this.defaultValue): Type<__type>
    Finds the component type that is needed to render a form field.
    • model: DynamicComponentModel - Form field model for the field to render
    • defaultValue: Type<__type> - Default type returned for field types that are not yet mapped.
    • Returns Type<__type> - 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:

Type stringComponent
'text'CardViewTextItemComponent
'int'CardViewTextItemComponent
'float'CardViewTextItemComponent
'date'CardViewDateItemComponent
'datetime'CardViewDateItemComponent
'bool'CardViewBoolItemComponent
'map'CardViewMapItemComponent

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 Type 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

Interested in trying Alfresco?

Try Now