From 08c3b045119386d0a25529c828b347bd16073d99 Mon Sep 17 00:00:00 2001 From: Alex Turchyn Date: Wed, 26 Jul 2023 23:47:35 +0300 Subject: [PATCH] fix builder when field areas key is undefined --- app/javascript/template_builder/builder.vue | 6 +++--- app/javascript/template_builder/fields.vue | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 5d704f33..9325b7a8 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -136,7 +136,7 @@

@@ -421,7 +421,7 @@ export default { } this.template.fields.forEach((field) => { - [...field.areas].forEach((area) => { + [...(field.areas || [])].forEach((area) => { if (area.attachment_uuid === item.attachment_uuid) { field.areas.splice(field.areas.indexOf(area), 1) } @@ -434,7 +434,7 @@ export default { this.template.schema.splice(this.template.schema.indexOf(replaceSchemaItem), 1, schema[0]) this.template.documents.push(...documents) this.template.fields.forEach((field) => { - field.areas.forEach((area) => { + (field.areas || []).forEach((area) => { if (area.attachment_uuid === replaceSchemaItem.attachment_uuid) { area.attachment_uuid = schema[0].attachment_uuid } diff --git a/app/javascript/template_builder/fields.vue b/app/javascript/template_builder/fields.vue index 16e704cc..46189ab4 100644 --- a/app/javascript/template_builder/fields.vue +++ b/app/javascript/template_builder/fields.vue @@ -172,6 +172,7 @@ export default { name: '', uuid: v4(), required: type !== 'checkbox', + areas: [], submitter_uuid: this.selectedSubmitter.uuid, type }