From 6a31d2c72268ee0daef35618a5109642aa05e570 Mon Sep 17 00:00:00 2001 From: Pete Matsyburka Date: Sat, 8 Jun 2024 10:01:14 +0300 Subject: [PATCH] alert message on missing submitter fields --- app/javascript/template_builder/builder.vue | 34 +++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/app/javascript/template_builder/builder.vue b/app/javascript/template_builder/builder.vue index 08746a1be..3cfcd9ee2 100644 --- a/app/javascript/template_builder/builder.vue +++ b/app/javascript/template_builder/builder.vue @@ -1129,6 +1129,15 @@ export default { e.preventDefault() alert('Please draw fields to prepare the document.') + } else { + const submitterWithoutFields = + this.template.submitters.find((submitter) => !this.template.fields.some((f) => f.submitter_uuid === submitter.uuid)) + + if (submitterWithoutFields) { + e.preventDefault() + + alert(`Please add fields for ${submitterWithoutFields.name} to prepare the document or remove the party.`) + } } }, onSaveClick () { @@ -1142,16 +1151,23 @@ export default { } } - if (this.template.fields.length) { - this.isSaving = true - - this.save().then(() => { - window.Turbo.visit(`/templates/${this.template.id}`) - }).finally(() => { - this.isSaving = false - }) - } else { + if (!this.template.fields.length) { alert('Please draw fields to prepare the document.') + } else { + const submitterWithoutFields = + this.template.submitters.find((submitter) => !this.template.fields.some((f) => f.submitter_uuid === submitter.uuid)) + + if (submitterWithoutFields) { + alert(`Please add fields for ${submitterWithoutFields.name} to prepare the document or remove the party.`) + } else { + this.isSaving = true + + this.save().then(() => { + window.Turbo.visit(`/templates/${this.template.id}`) + }).finally(() => { + this.isSaving = false + }) + } } }, scrollToArea (area) {