Logic Fixes (#204)

Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
formsdev 2023-09-18 18:48:54 +05:30 committed by GitHub
parent adcb20b715
commit 402e74eaad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 13 deletions

View File

@ -1,10 +1,8 @@
<template> <template>
<collapse v-if="logic" :key="resetKey" :default-value="isCollapseOpen" @click="onClickCollapse"> <div v-if="logic" :key="resetKey">
<template #title> <h3 class="font-semibold block text-lg">
<h3 class="font-semibold block text-lg"> Logic
Logic </h3>
</h3>
</template>
<p class="text-gray-400 text-xs mb-3"> <p class="text-gray-400 text-xs mb-3">
Add some logic to this block. Start by adding some conditions, and then add some actions. Add some logic to this block. Start by adding some conditions, and then add some actions.
</p> </p>
@ -65,7 +63,7 @@
</div> </div>
</div> </div>
</modal> </modal>
</collapse> </div>
</template> </template>
<script> <script>
@ -74,11 +72,10 @@ import ConditionEditor from './ConditionEditor.vue'
import Modal from '../../../../Modal.vue' import Modal from '../../../../Modal.vue'
import SelectInput from '../../../../forms/SelectInput.vue' import SelectInput from '../../../../forms/SelectInput.vue'
import clonedeep from 'clone-deep' import clonedeep from 'clone-deep'
import Collapse from "../../../../common/Collapse.vue";
export default { export default {
name: 'FormBlockLogicEditor', name: 'FormBlockLogicEditor',
components: {Collapse, SelectInput, Modal, ProTag, ConditionEditor}, components: {SelectInput, Modal, ProTag, ConditionEditor},
props: { props: {
field: { field: {
type: Object, type: Object,
@ -92,7 +89,6 @@ export default {
data() { data() {
return { return {
isCollapseOpen: false,
resetKey: 0, resetKey: 0,
logic: this.field.logic || { logic: this.field.logic || {
conditions: null, conditions: null,
@ -157,6 +153,15 @@ export default {
}, },
deep: true deep: true
}, },
'field.id': {
handler (field, oldField) {
// On field change, reset logic
this.logic = this.field.logic || {
conditions: null,
actions: []
}
}
},
'field.required': 'cleanConditions', 'field.required': 'cleanConditions',
'field.disabled': 'cleanConditions', 'field.disabled': 'cleanConditions',
'field.hidden': 'cleanConditions', 'field.hidden': 'cleanConditions',
@ -203,9 +208,6 @@ export default {
} }
} }
this.showCopyFormModal = false this.showCopyFormModal = false
},
onClickCollapse (e) {
this.isCollapseOpen = e
} }
} }
} }