detach areas on remove docuemnt

pull/105/head
Alex Turchyn 2 years ago
parent db7e3794d9
commit 21b9ca8ea5

@ -11,7 +11,10 @@
v-for="(area, areaIndex) in field.areas" v-for="(area, areaIndex) in field.areas"
:key="areaIndex" :key="areaIndex"
> >
<Teleport :to="`#page-${area.attachment_uuid}-${area.page}`"> <Teleport
v-if="attachmentsIndex[area.attachment_uuid]"
:to="`#page-${area.attachment_uuid}-${area.page}`"
>
<FieldArea <FieldArea
:ref="setAreaRef" :ref="setAreaRef"
v-model="values[field.uuid]" v-model="values[field.uuid]"

@ -356,7 +356,7 @@ export default {
if (this.selectedField?.type === this.dragFieldType) { if (this.selectedField?.type === this.dragFieldType) {
baseArea = this.selectedAreaRef.value baseArea = this.selectedAreaRef.value
} else if (previousField?.areas) { } else if (previousField?.areas?.length) {
baseArea = previousField.areas[previousField.areas.length - 1] baseArea = previousField.areas[previousField.areas.length - 1]
} else { } else {
if (['checkbox'].includes(this.dragFieldType)) { if (['checkbox'].includes(this.dragFieldType)) {
@ -420,6 +420,14 @@ export default {
this.template.schema.splice(this.template.schema.indexOf(item), 1) this.template.schema.splice(this.template.schema.indexOf(item), 1)
} }
this.template.fields.forEach((field) => {
[...field.areas].forEach((area) => {
if (area.attachment_uuid === item.attachment_uuid) {
field.areas.splice(field.areas.indexOf(area), 1)
}
})
})
this.save() this.save()
}, },
onDocumentReplace ({ replaceSchemaItem, schema, documents }) { onDocumentReplace ({ replaceSchemaItem, schema, documents }) {

Loading…
Cancel
Save