[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:
Andy Stark
2018-02-13 22:44:47 +00:00
committed by Eugenio Romano
parent b3955b3f6c
commit 68ded23c9a
10 changed files with 331 additions and 63 deletions

View File

@@ -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);