From 2b8779be462d3fa28b1aba06f1a5e1fb1852c9dc Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 2 Feb 2023 19:10:41 +1100 Subject: [PATCH] Accept user input from approve quote flow --- app/DataMapper/CompanySettings.php | 5 ++++- resources/js/clients/quotes/approve.js | 16 ++++++++++------ .../views/portal/ninja2020/quotes/show.blade.php | 1 + 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/DataMapper/CompanySettings.php b/app/DataMapper/CompanySettings.php index dd11547e34ff..de053970f237 100644 --- a/app/DataMapper/CompanySettings.php +++ b/app/DataMapper/CompanySettings.php @@ -461,8 +461,11 @@ class CompanySettings extends BaseSettings public $show_shipping_address = false; + public $accept_client_input_quote_approval = false; + public static $casts = [ - 'custom_sending_email' => 'string', + 'accept_client_input_quote_approval' => 'bool', + 'custom_sending_email' => 'string', 'show_paid_stamp' => 'bool', 'show_shipping_address' => 'bool', 'company_logo_size' => 'string', diff --git a/resources/js/clients/quotes/approve.js b/resources/js/clients/quotes/approve.js index 41f4d593822a..e1b0740d151e 100644 --- a/resources/js/clients/quotes/approve.js +++ b/resources/js/clients/quotes/approve.js @@ -9,9 +9,10 @@ */ class Approve { - constructor(displaySignature, displayTerms) { + constructor(displaySignature, displayTerms, userInput) { this.shouldDisplaySignature = displaySignature; this.shouldDisplayTerms = displayTerms; + this.shouldDisplayUserInput = userInput; this.termsAccepted = false; } @@ -59,7 +60,7 @@ class Approve { document .getElementById('approve-button') .addEventListener('click', () => { - if (this.shouldDisplaySignature && this.shouldDisplayTerms) { + if (this.shouldDisplaySignature && this.shouldDisplayTerms && !this.shouldDisplayUserInput) { this.displaySignature(); document @@ -76,10 +77,11 @@ class Approve { this.termsAccepted = true; this.submitForm(); }); + }); } - if (this.shouldDisplaySignature && !this.shouldDisplayTerms) { + if (this.shouldDisplaySignature && !this.shouldDisplayTerms && !this.shouldDisplayUserInput) { this.displaySignature(); document @@ -92,7 +94,7 @@ class Approve { }); } - if (!this.shouldDisplaySignature && this.shouldDisplayTerms) { + if (!this.shouldDisplaySignature && this.shouldDisplayTerms && !this->this.shouldDisplayUserInput) { this.displayTerms(); document @@ -103,7 +105,7 @@ class Approve { }); } - if (!this.shouldDisplaySignature && !this.shouldDisplayTerms) { + if (!this.shouldDisplaySignature && !this.shouldDisplayTerms && !this.shouldDisplayUserInput) { this.submitForm(); } }); @@ -115,4 +117,6 @@ const signature = document.querySelector('meta[name="require-quote-signature"]') const terms = document.querySelector('meta[name="show-quote-terms"]').content; -new Approve(Boolean(+signature), Boolean(+terms)).handle(); +const user_input = document.querySelector('meta[name="accept-user-input"]').content; + +new Approve(Boolean(+signature), Boolean(+terms), Boolean(+user_input)).handle(); diff --git a/resources/views/portal/ninja2020/quotes/show.blade.php b/resources/views/portal/ninja2020/quotes/show.blade.php index aeae870dcae8..86d73aa87421 100644 --- a/resources/views/portal/ninja2020/quotes/show.blade.php +++ b/resources/views/portal/ninja2020/quotes/show.blade.php @@ -7,6 +7,7 @@ + @include('portal.ninja2020.components.no-cache')