@@ -158,7 +158,7 @@ export default {
name: 'ConditionModal',
inject: ['t', 'save', 'template', 'withConditions'],
props: {
- field: {
+ item: {
type: Object,
required: true
},
@@ -170,22 +170,26 @@ export default {
emits: ['close'],
data () {
return {
- conditions: this.field.conditions?.[0] ? JSON.parse(JSON.stringify(this.field.conditions)) : [{}]
+ conditions: this.item.conditions?.[0] ? JSON.parse(JSON.stringify(this.item.conditions)) : [{}]
}
},
computed: {
fields () {
- return this.template.fields.reduce((acc, f) => {
- if (f !== this.field && f.submitter_uuid === this.field.submitter_uuid) {
- acc.push(f)
- }
+ if (this.item.submitter_uuid) {
+ return this.template.fields.reduce((acc, f) => {
+ if (f !== this.item && f.submitter_uuid === this.item.submitter_uuid) {
+ acc.push(f)
+ }
- return acc
- }, [])
+ return acc
+ }, [])
+ } else {
+ return this.template.fields
+ }
}
},
created () {
- this.field.conditions ||= []
+ this.item.conditions ||= []
},
methods: {
conditionField (condition) {
@@ -219,9 +223,9 @@ export default {
}
if (this.conditions.find((f) => f.field_uuid)) {
- this.field.conditions = this.conditions
+ this.item.conditions = this.conditions
} else {
- delete this.field.conditions
+ delete this.item.conditions
}
this.save()
diff --git a/app/javascript/template_builder/field.vue b/app/javascript/template_builder/field.vue
index 63aa2175..b5a38f62 100644
--- a/app/javascript/template_builder/field.vue
+++ b/app/javascript/template_builder/field.vue
@@ -236,7 +236,7 @@
:to="modalContainerEl"
>
@@ -365,7 +365,7 @@ export default {
} else {
const typeIndex = fields.filter((f) => f.type === field.type).indexOf(field)
- if (this.field.type === 'heading') {
+ if (field.type === 'heading') {
return `${this.fieldNames[field.type]} ${typeIndex + 1}`
} else {
return `${this.fieldLabels[field.type]} ${typeIndex + 1}`
diff --git a/app/javascript/template_builder/fields.vue b/app/javascript/template_builder/fields.vue
index db8143dc..55932181 100644
--- a/app/javascript/template_builder/fields.vue
+++ b/app/javascript/template_builder/fields.vue
@@ -229,6 +229,10 @@ export default {
type: Array,
required: true
},
+ template: {
+ type: Object,
+ required: true
+ },
withHelp: {
type: Boolean,
required: false,
@@ -380,6 +384,14 @@ export default {
})
})
+ this.template.schema.forEach((item) => {
+ (item.conditions || []).forEach((c) => {
+ if (c.field_uuid === field.uuid) {
+ item.conditions.splice(item.conditions.indexOf(c), 1)
+ }
+ })
+ })
+
this.save()
}
}
diff --git a/app/javascript/template_builder/mobile_draw_field.vue b/app/javascript/template_builder/mobile_draw_field.vue
index 556d2209..c8644766 100644
--- a/app/javascript/template_builder/mobile_draw_field.vue
+++ b/app/javascript/template_builder/mobile_draw_field.vue
@@ -1,6 +1,6 @@