|
|
|
|
@ -683,13 +683,17 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.isSignatureStarted && this.pad.toData().length > 0 && !isValidSignatureCanvas(this.pad.toData())) {
|
|
|
|
|
alert(this.t('signature_is_too_small_or_simple_please_redraw'))
|
|
|
|
|
if (this.field.required === true || this.pad.toData().length > 0) {
|
|
|
|
|
alert(this.t('signature_is_too_small_or_simple_please_redraw'))
|
|
|
|
|
|
|
|
|
|
return Promise.reject(new Error('Image too small or simple'))
|
|
|
|
|
return Promise.reject(new Error('Image too small or simple'))
|
|
|
|
|
} else {
|
|
|
|
|
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], 'signature.png', { type: 'image/png' })
|
|
|
|
|
|
|
|
|
|
if (this.dryRun) {
|
|
|
|
|
@ -725,6 +729,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({})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|