Accept user input from approve quote flow

This commit is contained in:
David Bomba 2023-02-02 19:10:41 +11:00
parent 4c76107526
commit 2b8779be46
3 changed files with 15 additions and 7 deletions

View File

@ -461,7 +461,10 @@ class CompanySettings extends BaseSettings
public $show_shipping_address = false; public $show_shipping_address = false;
public $accept_client_input_quote_approval = false;
public static $casts = [ public static $casts = [
'accept_client_input_quote_approval' => 'bool',
'custom_sending_email' => 'string', 'custom_sending_email' => 'string',
'show_paid_stamp' => 'bool', 'show_paid_stamp' => 'bool',
'show_shipping_address' => 'bool', 'show_shipping_address' => 'bool',

View File

@ -9,9 +9,10 @@
*/ */
class Approve { class Approve {
constructor(displaySignature, displayTerms) { constructor(displaySignature, displayTerms, userInput) {
this.shouldDisplaySignature = displaySignature; this.shouldDisplaySignature = displaySignature;
this.shouldDisplayTerms = displayTerms; this.shouldDisplayTerms = displayTerms;
this.shouldDisplayUserInput = userInput;
this.termsAccepted = false; this.termsAccepted = false;
} }
@ -59,7 +60,7 @@ class Approve {
document document
.getElementById('approve-button') .getElementById('approve-button')
.addEventListener('click', () => { .addEventListener('click', () => {
if (this.shouldDisplaySignature && this.shouldDisplayTerms) { if (this.shouldDisplaySignature && this.shouldDisplayTerms && !this.shouldDisplayUserInput) {
this.displaySignature(); this.displaySignature();
document document
@ -76,10 +77,11 @@ class Approve {
this.termsAccepted = true; this.termsAccepted = true;
this.submitForm(); this.submitForm();
}); });
}); });
} }
if (this.shouldDisplaySignature && !this.shouldDisplayTerms) { if (this.shouldDisplaySignature && !this.shouldDisplayTerms && !this.shouldDisplayUserInput) {
this.displaySignature(); this.displaySignature();
document document
@ -92,7 +94,7 @@ class Approve {
}); });
} }
if (!this.shouldDisplaySignature && this.shouldDisplayTerms) { if (!this.shouldDisplaySignature && this.shouldDisplayTerms && !this->this.shouldDisplayUserInput) {
this.displayTerms(); this.displayTerms();
document document
@ -103,7 +105,7 @@ class Approve {
}); });
} }
if (!this.shouldDisplaySignature && !this.shouldDisplayTerms) { if (!this.shouldDisplaySignature && !this.shouldDisplayTerms && !this.shouldDisplayUserInput) {
this.submitForm(); 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; 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();

View File

@ -7,6 +7,7 @@
<meta name="show-quote-terms" content="{{ $settings->show_accept_quote_terms ? true : false }}"> <meta name="show-quote-terms" content="{{ $settings->show_accept_quote_terms ? true : false }}">
<meta name="require-quote-signature" content="{{ $client->company->account->hasFeature(\App\Models\Account::FEATURE_INVOICE_SETTINGS) && $settings->require_quote_signature }}"> <meta name="require-quote-signature" content="{{ $client->company->account->hasFeature(\App\Models\Account::FEATURE_INVOICE_SETTINGS) && $settings->require_quote_signature }}">
<meta name="accept-user-input" content="{{ $client->getSetting('accept_client_input_quote_approval') }}">
@include('portal.ninja2020.components.no-cache') @include('portal.ninja2020.components.no-cache')