1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-14 07:02:34 +01:00
invoiceninja/resources/js/clients/quotes/approve.js

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-03-23 18:10:42 +01:00
/**
* Invoice Ninja (https://invoiceninja.com)
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://opensource.org/licenses/AAL
*/
class Approve {
constructor(displaySignature) {
this.shouldDisplaySignature = displaySignature;
}
submitForm() {
document.getElementById('approve-form').submit();
}
displaySignature() {
let displaySignatureModal = document.getElementById('displaySignatureModal');
displaySignatureModal.removeAttribute('style');
const signaturePad = new SignaturePad(document.getElementById('signature-pad'), {
backgroundColor: 'rgb(240,240,240)',
penColor: 'rgb(0, 0, 0)'
});
}
handle() {
document.getElementById('approve-button').addEventListener('click', () => {
if (this.shouldDisplaySignature) {
this.displaySignature();
document.getElementById('signature-next-step').addEventListener('click', () => {
this.submitForm();
});
}
if (!this.shouldDisplaySignature) this.submitForm();
})
}
}
const signature = document.querySelector(
'meta[name="require-quote-signature"]'
).content;
new Approve(Boolean(+signature)).handle();