mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-1769] Added JSDocs to services (#2937)
* [ADF-1769] Added JSDocs to services * Removed JSDoc return directives from doc comments
This commit is contained in:
committed by
Eugenio Romano
parent
b3955b3f6c
commit
68ded23c9a
@@ -31,6 +31,11 @@ export abstract class DynamicComponentMapper {
|
||||
protected defaultValue: Type<{}> = undefined;
|
||||
protected types: { [key: string]: DynamicComponentResolveFunction } = {};
|
||||
|
||||
/**
|
||||
* Gets the currently active ComponentTypeResolver function for a field type.
|
||||
* @param type The type whose resolver you want
|
||||
* @param defaultValue Default type returned for types that are not yet mapped
|
||||
*/
|
||||
getComponentTypeResolver(type: string, defaultValue: Type<{}> = this.defaultValue): DynamicComponentResolveFunction {
|
||||
if (type) {
|
||||
return this.types[type] || DynamicComponentResolver.fromType(defaultValue);
|
||||
@@ -38,6 +43,12 @@ export abstract class DynamicComponentMapper {
|
||||
return DynamicComponentResolver.fromType(defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or optionally replaces a ComponentTypeResolver function for a field type.
|
||||
* @param type The type whose resolver you want to set
|
||||
* @param resolver The new resolver function
|
||||
* @param override The new resolver will only replace an existing one if this parameter is true
|
||||
*/
|
||||
setComponentTypeResolver(type: string, resolver: DynamicComponentResolveFunction, override: boolean = false) {
|
||||
if (!type) {
|
||||
throw new Error(`type is null or not defined`);
|
||||
@@ -55,6 +66,11 @@ export abstract class DynamicComponentMapper {
|
||||
this.types[type] = resolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the component type that is needed to render a form field.
|
||||
* @param model [Form field model](form-field.model.md) for the field to render
|
||||
* @param defaultValue Default type returned for field types that are not yet mapped.
|
||||
*/
|
||||
resolveComponentType(model: DynamicComponentModel, defaultValue: Type<{}> = this.defaultValue): Type<{}> {
|
||||
if (model) {
|
||||
let resolver = this.getComponentTypeResolver(model.type, defaultValue);
|
||||
|
Reference in New Issue
Block a user