detach areas on remove docuemnt

This commit is contained in:
Alex Turchyn
2023-07-26 23:17:24 +03:00
parent db7e3794d9
commit 21b9ca8ea5
2 changed files with 13 additions and 2 deletions
+9 -1
View File
@@ -356,7 +356,7 @@ export default {
if (this.selectedField?.type === this.dragFieldType) {
baseArea = this.selectedAreaRef.value
} else if (previousField?.areas) {
} else if (previousField?.areas?.length) {
baseArea = previousField.areas[previousField.areas.length - 1]
} else {
if (['checkbox'].includes(this.dragFieldType)) {
@@ -420,6 +420,14 @@ export default {
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()
},
onDocumentReplace ({ replaceSchemaItem, schema, documents }) {