-
Notifications
You must be signed in to change notification settings - Fork 0
Component Dynamic engine
Dynamic engine allows to add form interactive capabilities, change component states based on workflow state and data model state.
Each component should have support to apply dynamic rule and change its state according to rule details when some appropriate event happens, like data value was applied to another component or document was moved through workflow process.
Dynamic support should be included into form engine and can be extended or overridden through dynamic engine. Component dynamic behavior description should be included into dynamic property in the component configuration root.
Component dynamic rule consist of two main parts:
- describe the state changes for this component
- describe conditions when state above should change
Simple dynamic rule example:
{
dynamic: {
prop: 'ui.label',
val: 'new label',
operator: 'and',
when: [{
binding: 'someBinding',
fn: 'comparator',
val: 'valueToCompare'
}]
}
}
when:
- prop - name of property including path to this property which should be changed when rule starts to execute
- val - value to be assigned to property when rule completes. This can be as a new value as well as the path to data inside data model tree to get data before assigning. In this case val string should start with '@' symbol.
- operator - bool operator to be applied as the concatenation rule for when statements. Should support at least 'or' and 'and' value and should have 'and' as a default value.
when property describes conditions which should meets to start dynamic rule to re-execute. Each condition can have next properties:
- binding - the path to data in data model tree to get data from
-
fn - comparison function. Form engine should add support for next functions:
-
eg
- equal(a, b); -
contains
- contains(a, b); -
lt
- lessThen(a, b); -
gt
- greaterThen(a, b); -
change
- explicitly makewhen
condition positive by any data change
-
- val - value to compare with. This can be as static value as well as the path to data inside data model tree to get data from. In this case val string should start with '@' symbol.
Dynamic rule which point to data model values:
{
dynamic: {
prop: 'ui.label',
val: '@path.to.data',
when: [{
binding: 'someBinding',
fn: 'comparator',
val: '@path.to.data'
}]
}
}
To make data processing more powerful - extra data conversions can be configured once the condition meets requirements and value will be stored in the specified property. To configure extra data process function - val
property can support link to action, e.g. val: @calculateMean(path.to.data)
.
Also each of existing or new functions should support unary negation functionality by adding '!' symbol as first position: '!eq', '!contains'. This should be supported by system by converting calculation result using 'NOT' bool operand.
The main purpose of supporting dynamic engine as independent module:
- allow to add or override existing functions
- allow to add or override existing operator implementation, e.g. adding "xor" operand support
- extend 'binding' property to support deep-list pointers, e.g. to special list item with row counter support
- add supports for new values in 'prop' property or change assignment strategy for existence
- add support for tree-based 'when' declaration