From a1e2f7b21db2731e59301fb5638753e6891a5f44 Mon Sep 17 00:00:00 2001 From: formsdev <136701234+formsdev@users.noreply.github.com> Date: Mon, 19 Jun 2023 18:21:08 +0530 Subject: [PATCH] Fix logic actions options (#136) --- .../FormBlockLogicEditor.vue | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/resources/js/components/open/forms/components/form-logic-components/FormBlockLogicEditor.vue b/resources/js/components/open/forms/components/form-logic-components/FormBlockLogicEditor.vue index 32399f6..b6d78a6 100644 --- a/resources/js/components/open/forms/components/form-logic-components/FormBlockLogicEditor.vue +++ b/resources/js/components/open/forms/components/form-logic-components/FormBlockLogicEditor.vue @@ -154,12 +154,9 @@ export default { }, deep: true }, - 'field.required': { - handler() { - this.cleanConditions() - }, - deep: true - } + 'field.required': 'cleanConditions', + 'field.disabled': 'cleanConditions', + 'field.hidden': 'cleanConditions', }, mounted() { @@ -185,12 +182,9 @@ export default { } }, cleanConditions() { - if (this.required && this.logic.actions.includes('require-answer')) { - this.$set(this.logic, 'actions', this.logic.actions.filter((action) => action !== 'require-answer')) - } else if (!this.required && this.logic.actions.includes('make-it-optional')) { - this.$set(this.logic, 'actions', this.logic.actions.filter((action) => action !== 'make-it-optional')) - } - this.resetKey++ + const availableActions = this.actionOptions.map(function(op){ return op.value }); + this.$set(this.logic, 'actions', availableActions.filter(value => this.logic.actions.includes(value))) + this.refreshActions() }, refreshActions() { this.resetKey++