Skip to content

Commit

Permalink
alert message on missing submitter fields
Browse files Browse the repository at this point in the history
  • Loading branch information
omohokcoj committed Jun 8, 2024
1 parent f26bfe9 commit 6a31d2c
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions app/javascript/template_builder/builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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) {
Expand Down

0 comments on commit 6a31d2c

Please sign in to comment.