* fix after rebase * new release strategy for ng next Signed-off-by: eromano <eugenioromano16@gmail.com> * peer dep Signed-off-by: eromano <eugenioromano16@gmail.com> * Angular 14 fix unit test and storybook Signed-off-by: eromano <eugenioromano16@gmail.com> fix after rebase Signed-off-by: eromano <eugenioromano16@gmail.com> update pkg.json Signed-off-by: eromano <eugenioromano16@gmail.com> missing dep Signed-off-by: eromano <eugenioromano16@gmail.com> Fix mistake and missing code Dream....build only affected libs Add utility run commands * Use nx command to run affected tests * Fix nx test core fix content tests Run unit with watch false core test fixes reduce test warnings Fix process cloud unit Fix adf unit test Fix lint process cloud Disable lint next line Use right core path Fix insights unit fix linting insights Fix process-services unit fix the extensions test report fix test warnings Fix content unit Fix bunch of content unit * Produce an adf alpha of 14 * hopefully fixing the content * Push back the npm publish * Remove flaky unit * Fix linting * Make the branch as root * Get rid of angualar13 * Remove the travis depth * Fixing version for npm * Enabling cache for unit and build * Fix scss for core and paths Copy i18 and asset by using ng-packager Export the theming alias and fix path Use ng-package to copy assets process-services-cloud Use ng-package to copy assets process-services Use ng-package to copy assets content-services Use ng-package to copy assets insights * feat: fix api secondary entry point * fix storybook rebase * Move dist under dist/libs from lib/dist * Fix the webstyle * Use only necessary nrwl deps and improve lint * Fix unit for libs * Convert lint.sh to targets - improve performance * Use latest of angular * Align alfresco-js-api Signed-off-by: eromano <eugenioromano16@gmail.com> Co-authored-by: eromano <eugenioromano16@gmail.com> Co-authored-by: Mikolaj Serwicki <mikolaj.serwicki@hyland.com> Co-authored-by: Tomasz <tomasz.gnyp@hyland.com>
7.9 KiB
Title, Added, Status, Last reviewed
Title | Added | Status | Last reviewed |
---|---|---|---|
Form Rendering service | v2.0.0 | Active | 2018-11-20 |
Form Rendering service
Maps a form field type string onto the corresponding form widget component type.
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
- type:
- register(components:
Function
, override:boolean
=false
)
Register multiple components- components:
Function
- - override:
boolean
-
- components:
- 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
- model:
- 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
- type:
Details
The Form
Field component uses this service to choose which widget to use to render an instance of a
form field. The Form
Field model stores the field type name as a string (see the table below).
The Form
Rendering service maintains a mapping between each type name and
a corresponding DynamicComponentResolveFunction
. The function takes a FormFieldModel
object as its argument and
uses the data from the object to determine which widget should be used to render the field.
In some cases, the field type string alone is enough to determine the widget type and so the function just returns the type directly:
let customResolver: DynamicComponentResolveFunction = () => CustomWidgetComponent;
formRenderingService.setComponentTypeResolver('text', customResolver, true);
In other cases, the function may need to choose the widget dynamically based on specific values in the form data:
let customResolver: DynamicComponentResolveFunction = (field: FormFieldModel): Type<{}> => {
if (field) {
let params = field.params;
}
return UnknownWidgetComponent;
};
formRenderingService.setComponentTypeResolver('text', customResolver, true);
Default type mapping
The Form
Rendering service is initialized with the mapping shown in the table below:
Stencil name | Field type string | Component type |
---|---|---|
Amount | "amount" | AmountWidgetComponent |
Attach | "upload" | AttachWidgetComponent or UploadWidgetComponent (based on metadata) |
Checkbox | "boolean" | CheckboxWidgetComponent |
Date | "date" | DateWidgetComponent |
Display text | "readonly-text" | DisplayTextWidgetComponentComponent |
Display Rich text | "display-rich-text" | DisplayRichTextWidgetComponent |
Display value | "readonly" | DisplayValueWidgetComponent |
Dropdown | "dropdown" | DropdownWidgetComponent |
Dynamic table | "dynamic-table" | DynamicTableWidgetComponent |
Group of people | "functional-group" | FunctionalGroupWidgetComponent |
Header | "group" | ContainerWidgetComponent |
Hyperlink | "hyperlink" | HyperlinkWidgetComponent |
Multi-line text | "multi-line-text" | MultilineTextWidgetComponentComponent |
Number | "integer" | NumberWidgetComponent |
People | "people" | PeopleWidgetComponent |
Radio buttons | "radio-buttons" | RadioButtonsWidgetComponent |
Text | "text" | TextWidgetComponent |
Typeahead | "typeahead" | TypeaheadWidgetComponent |
You can add new items to the mapping or replace existing items in order to customize the way fields are rendered.
Adding new or replacement items to the mapping
You can use the setComponentTypeResolver
method to add a new ComponentTypeResolver function for a
particular type string. You can also replace the resolver for a type that already exists in the mapping
if you set the override
parameter to 'true':
formRenderingService.setComponentTypeResolver('text', newResolver, true);
You would typically use this to replace an existing widget with your own custom version that implements a modified layout or responds differently when the data is entered. See the Form Extensibility and Customisation guide for further details and examples of this technique.