Skip to content

Commit e48f146

Browse files
committed
[EAK-521] Ability to pass a path to set/set-if-blank actions to access nested fields
1 parent bc18e28 commit e48f146

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

docs/content/dev-tools/depends-on/api.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ order: 3
1010

1111
Built-in plug-in actions are:
1212
* `visibility` - hide the element if the Query result is 'falsy'. <u>This is the default action that is applied when no action is specified.</u>
13+
1314
* `tab-visibility` - hide the tab or the element's parent tab if the Query result is 'falsy'
14-
* `set` - set the Query result as the field's value (undefined Query result skipped)
15-
* `set-if-blank` - set the Query result as the field's value only if the current value is blank (undefined Query result skipped)
15+
16+
* `set` - set the Query result as the field's value (`undefined` Query result skipped).
17+
Supports optional `path` parameter to set the value to the nested property of the field.
18+
19+
* `set-if-blank` - set the Query result as the field's value only if the current value is blank (`undefined` Query result skipped).
20+
Supports optional `path` parameter to set the value to the nested property of the field.
21+
1622
* `readonly` - set the readonly marker of the field from the Query result.
23+
1724
* `required` - set the required marker of the field from the Query result.
25+
1826
* `validate` - set the validation state of the field from the Query result.
27+
1928
* `disabled` - set the field's disabled state from the Query result. Supports multiple actions effect for the same field.
2029

2130
### Async actions

ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/depends-on/js.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ js/accessors/dependsOnCoralFieldsetAccessor.js
3030

3131
# Actions
3232
js/actions/dependsOnCoralBasicActions.js
33+
js/actions/dependsOnCoralSetActions.js
3334
js/actions/dependsOnCoralValidateAction.js
3435
js/actions/dependsOnFetchAction.js
3536
js/actions/dependsOnCoralTabAction.js

ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/depends-on/js/actions/dependsOnCoralBasicActions.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,4 @@
6161
ns.ActionRegistry.register('disabled', function setDisabled(state) {
6262
ns.ElementAccessors.requestDisable(this.$el, state, this);
6363
});
64-
65-
/**
66-
* Set the field value from the query result, skip undefined query results
67-
* query type: string
68-
* */
69-
ns.ActionRegistry.register('set', function setValue(value) {
70-
if (value !== undefined) {
71-
ns.ElementAccessors.setValue(this.$el, value);
72-
}
73-
});
74-
75-
/**
76-
* Set the field value from the query result only if the field value is blank,
77-
* skip undefined query results
78-
* query type: string
79-
* */
80-
ns.ActionRegistry.register('set-if-blank', function setValueIfBlank(value) {
81-
const current = ns.ElementAccessors.getValue(this.$el);
82-
if ((current === '' || current === null || current === undefined) && value !== undefined) {
83-
ns.ElementAccessors.setValue(this.$el, value);
84-
}
85-
});
8664
})(Granite.$, Granite.DependsOnPlugin = (Granite.DependsOnPlugin || {}));

0 commit comments

Comments
 (0)