This mixin module provides a function
for overriding the default widget model to be generated. This function provides a consistent way in which
new widgets can be added, removed, replaced and updated.
- Since:
- 1.0.97
- Copyright:
- Copyright (C) 2005-2020 Alfresco Software Limited
- License:
- GNU Lesser General Public License, see: Open Source Licensing
- Source:
Methods
-
applyWidgetOverrides(widgets, overrides)
-
Applies the supplied overrides to the supplied widgets model. Each element in the overrides array should define how it should be applied to the widgets array. Given the starting widgets array:
Parameters:
Name Type Description widgets
object[] The default widgets overrides
object[] The overrides to apply - Source:
Examples
[ { id: "WIDGET_1", name: "alfresco/forms/controls/TextBox", config: { fieldId: "NAME", label: "Name", description: "Enter your name", name: "name" } }, { id: "WIDGET_2", name: "alfresco/forms/controls/NumberSpinner", config: { fieldId: "AGE", label: "Age", description: "How old are you?", name: "age" } } ]
[ { id: "ADDRESS", targetPosition: "START", name: "alfresco/forms/controls/TextBox", config: { fieldId: "ADDRESS", label: "Address", description: "Where do you live?", name: "address" } } ]
[ { id: "ADDRESS", targetPosition: "END", name: "alfresco/forms/controls/TextBox", config: { fieldId: "ADDRESS", label: "Address", description: "Where do you live?", name: "address" } } ]
[ { id: "ADDRESS", targetId: "WIDGET_2" targetPosition: "BEFORE", name: "alfresco/forms/controls/TextBox", config: { fieldId: "ADDRESS", label: "Address", description: "Where do you live?", name: "address" } } ]
[ { id: "ADDRESS", targetId: "WIDGET_1" targetPosition: "AFTER", name: "alfresco/forms/controls/TextBox", config: { fieldId: "ADDRESS", label: "Address", description: "Where do you live?", name: "address" } } ]
[ { id: "WIDGET_2", remove: true } ]
[ { id: "WIDGET_2", replace: true, name: "alfresco/forms/controls/TextArea", config: { fieldId: "ADDRESS", label: "Location", name: "address" } } ]
[ { id: "WIDGET_1", name: "alfresco/forms/controls/TextArea", config: { name: "Who are you?" } } ]
-
findWidgetToOverride(widgets, targetId) → {number}
-
Iterates over the supplied array of widgets until one with the supplied target id is found. The index of the widget within the supplied array is then returned.
Parameters:
Name Type Description widgets
object[] An array of widgets to iterate over targetId
string The target ID to match - Source:
Returns:
The index of the widget in the array or -1 if it could not be found.- Type
- number