From d64308fdd14cfdb00ee627d2de5031d3b942a7c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 17 Nov 2020 16:57:42 +0100 Subject: [PATCH] production builds --- .../ClientPortal/QuoteController.php | 5 + public/js/clients/quotes/approve.js | 2 +- public/mix-manifest.json | 2 +- resources/js/clients/quotes/approve.js | 92 +++++++++++++++---- 4 files changed, 79 insertions(+), 22 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/QuoteController.php b/app/Http/Controllers/ClientPortal/QuoteController.php index 3cf36cc6b93c..02d425a64455 100644 --- a/app/Http/Controllers/ClientPortal/QuoteController.php +++ b/app/Http/Controllers/ClientPortal/QuoteController.php @@ -6,6 +6,7 @@ use App\Events\Quote\QuoteWasApproved; use App\Http\Controllers\Controller; use App\Http\Requests\ClientPortal\ProcessQuotesInBulkRequest; use App\Http\Requests\ClientPortal\ShowQuoteRequest; +use App\Jobs\Invoice\InjectSignature; use App\Models\Company; use App\Models\Quote; use App\Utils\Ninja; @@ -111,6 +112,10 @@ class QuoteController extends Controller foreach ($quotes as $quote) { $quote->service()->approve(auth()->user())->save(); event(new QuoteWasApproved(auth('contact')->user(), $quote, $quote->company, Ninja::eventVars())); + + if (request()->has('signature') && !is_null(request()->signature) && !empty(request()->signature)) { + InjectSignature::dispatch($quote, request()->signature); + } } return redirect() diff --git a/public/js/clients/quotes/approve.js b/public/js/clients/quotes/approve.js index 2faaab5f8dca..9059c38633cd 100644 --- a/public/js/clients/quotes/approve.js +++ b/public/js/clients/quotes/approve.js @@ -1,2 +1,2 @@ /*! For license information please see approve.js.LICENSE.txt */ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=10)}({10:function(e,t,n){e.exports=n("WuMn")},WuMn:function(e,t){function n(e,t){for(var n=0;n { - if (this.shouldDisplaySignature) { - this.displaySignature(); + document + .getElementById('approve-button') + .addEventListener('click', () => { + if (this.shouldDisplaySignature && this.shouldDisplayTerms) { + this.displaySignature(); - document.getElementById('signature-next-step').addEventListener('click', () => { + document + .getElementById('signature-next-step') + .addEventListener('click', () => { + this.displayTerms(); + + document + .getElementById('accept-terms-button') + .addEventListener('click', () => { + document.querySelector( + 'input[name="signature"' + ).value = this.signaturePad.toDataURL(); + this.termsAccepted = true; + this.submitForm(); + }); + }); + } + + if (this.shouldDisplaySignature && !this.shouldDisplayTerms) { + this.displaySignature(); + + document + .getElementById('signature-next-step') + .addEventListener('click', () => { + document.querySelector( + 'input[name="signature"' + ).value = this.signaturePad.toDataURL(); + this.submitForm(); + }); + } + + if (!this.shouldDisplaySignature && this.shouldDisplayTerms) { + this.displayTerms(); + + document + .getElementById('accept-terms-button') + .addEventListener('click', () => { + this.termsAccepted = true; + this.submitForm(); + }); + } + + if (!this.shouldDisplaySignature && !this.shouldDisplayTerms) { this.submitForm(); - }); - } - - if (!this.shouldDisplaySignature) this.submitForm(); - }) + } + }); } } -const signature = document.querySelector( - 'meta[name="require-quote-signature"]' -).content; - -new Approve(Boolean(+signature)).handle(); +const signature = document.querySelector('meta[name="require-quote-signature"]') + .content; +const terms = document.querySelector('meta[name="show-quote-terms"]').content; +new Approve(Boolean(+signature), Boolean(+terms)).handle();