improve signature validation

This commit is contained in:
Pete Matsyburka
2025-04-17 22:06:27 +03:00
parent d0259791bf
commit 7964d6e0f0
4 changed files with 34 additions and 7 deletions
@@ -339,8 +339,8 @@ export default {
return Promise.resolve({})
}
return new Promise((resolve) => {
cropCanvasAndExportToPNG(this.$refs.canvas).then(async (blob) => {
return new Promise((resolve, reject) => {
cropCanvasAndExportToPNG(this.$refs.canvas, { errorOnTooSmall: true }).then(async (blob) => {
const file = new File([blob], 'initials.png', { type: 'image/png' })
if (this.dryRun) {
@@ -373,6 +373,14 @@ export default {
return resolve(attachment)
})
}
}).catch((error) => {
if (this.field.required === true) {
alert(this.t('signature_is_too_small_or_simple_please_redraw'))
return reject(error)
} else {
return resolve({})
}
})
})
}