From e48f14641d8b6430bf9bd41c0d9358be6df1cb58 Mon Sep 17 00:00:00 2001 From: "ala'n (Alexey Stsefanovich)" Date: Thu, 16 May 2024 00:58:27 +0200 Subject: [PATCH] [EAK-521] Ability to pass a `path` to `set`/`set-if-blank` actions to access nested fields --- docs/content/dev-tools/depends-on/api.md | 13 +++++++++-- .../etoolbox-authoring-kit/depends-on/js.txt | 1 + .../js/actions/dependsOnCoralBasicActions.js | 22 ------------------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/docs/content/dev-tools/depends-on/api.md b/docs/content/dev-tools/depends-on/api.md index 46cc0ff91..53d506f34 100644 --- a/docs/content/dev-tools/depends-on/api.md +++ b/docs/content/dev-tools/depends-on/api.md @@ -10,12 +10,21 @@ order: 3 Built-in plug-in actions are: * `visibility` - hide the element if the Query result is 'falsy'. This is the default action that is applied when no action is specified. + * `tab-visibility` - hide the tab or the element's parent tab if the Query result is 'falsy' -* `set` - set the Query result as the field's value (undefined Query result skipped) -* `set-if-blank` - set the Query result as the field's value only if the current value is blank (undefined Query result skipped) + +* `set` - set the Query result as the field's value (`undefined` Query result skipped). + Supports optional `path` parameter to set the value to the nested property of the field. + +* `set-if-blank` - set the Query result as the field's value only if the current value is blank (`undefined` Query result skipped). + Supports optional `path` parameter to set the value to the nested property of the field. + * `readonly` - set the readonly marker of the field from the Query result. + * `required` - set the required marker of the field from the Query result. + * `validate` - set the validation state of the field from the Query result. + * `disabled` - set the field's disabled state from the Query result. Supports multiple actions effect for the same field. ### Async actions diff --git a/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/depends-on/js.txt b/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/depends-on/js.txt index be69214c3..49ad4a456 100644 --- a/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/depends-on/js.txt +++ b/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/depends-on/js.txt @@ -30,6 +30,7 @@ js/accessors/dependsOnCoralFieldsetAccessor.js # Actions js/actions/dependsOnCoralBasicActions.js +js/actions/dependsOnCoralSetActions.js js/actions/dependsOnCoralValidateAction.js js/actions/dependsOnFetchAction.js js/actions/dependsOnCoralTabAction.js diff --git a/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/depends-on/js/actions/dependsOnCoralBasicActions.js b/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/depends-on/js/actions/dependsOnCoralBasicActions.js index 8fbc766df..5cb9acd2c 100644 --- a/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/depends-on/js/actions/dependsOnCoralBasicActions.js +++ b/ui.apps/src/main/content/jcr_root/apps/etoolbox-authoring-kit/depends-on/js/actions/dependsOnCoralBasicActions.js @@ -61,26 +61,4 @@ ns.ActionRegistry.register('disabled', function setDisabled(state) { ns.ElementAccessors.requestDisable(this.$el, state, this); }); - - /** - * Set the field value from the query result, skip undefined query results - * query type: string - * */ - ns.ActionRegistry.register('set', function setValue(value) { - if (value !== undefined) { - ns.ElementAccessors.setValue(this.$el, value); - } - }); - - /** - * Set the field value from the query result only if the field value is blank, - * skip undefined query results - * query type: string - * */ - ns.ActionRegistry.register('set-if-blank', function setValueIfBlank(value) { - const current = ns.ElementAccessors.getValue(this.$el); - if ((current === '' || current === null || current === undefined) && value !== undefined) { - ns.ElementAccessors.setValue(this.$el, value); - } - }); })(Granite.$, Granite.DependsOnPlugin = (Granite.DependsOnPlugin || {}));