Improve contact name handling for new custorder

This commit is contained in:
Lance Edgar 2021-10-07 12:33:52 -04:00
parent c611eb3787
commit 5e339bb7ea
3 changed files with 45 additions and 19 deletions

View file

@ -342,8 +342,13 @@
<div v-if="!contactIsKnown"
style="padding-left: 10rem; display: flex;">
<div>
<b-field label="Customer Name">
<span>{{ newCustomerName }}</span>
<b-field grouped>
<b-field label="First Name">
<span>{{ newCustomerFirstName }}</span>
</b-field>
<b-field label="Last Name">
<span>{{ newCustomerLastName }}</span>
</b-field>
</b-field>
<b-field grouped>
<b-field label="Phone Number">
@ -381,10 +386,16 @@
</header>
<section class="modal-card-body">
<b-field label="Customer Name">
<b-input v-model="editNewCustomerName"
ref="editNewCustomerInput">
</b-input>
<b-field grouped>
<b-field label="First Name">
<b-input v-model="editNewCustomerFirstName"
ref="editNewCustomerInput">
</b-input>
</b-field>
<b-field label="Last Name">
<b-input v-model="editNewCustomerLastName">
</b-input>
</b-field>
</b-field>
<b-field grouped>
<b-field label="Phone Number">
@ -674,13 +685,15 @@
% endif
newCustomerName: ${json.dumps(new_customer_name)|n},
newCustomerFirstName: ${json.dumps(new_customer_first_name)|n},
newCustomerLastName: ${json.dumps(new_customer_last_name)|n},
newCustomerPhone: ${json.dumps(new_customer_phone)|n},
newCustomerEmail: ${json.dumps(new_customer_email)|n},
contactNotes: ${json.dumps(contact_notes)|n},
editNewCustomerShowDialog: false,
editNewCustomerName: null,
editNewCustomerFirstName: null,
editNewCustomerLastName: null,
editNewCustomerPhone: null,
editNewCustomerEmail: null,
editNewCustomerSaving: false,
@ -718,8 +731,8 @@
}
}
} else {
if (this.newCustomerName) {
text = "Customer: " + this.newCustomerName
if (this.contactDisplay) {
text = "Customer: " + this.contactDisplay
}
}
@ -772,7 +785,7 @@
}
phoneNumber = this.orderPhoneNumber
} else { // customer is not known
if (!this.newCustomerName) {
if (!this.contactDisplay) {
return {
type: 'is-danger',
text: "Please identify the customer.",
@ -850,7 +863,7 @@
if (this.editNewCustomerSaving) {
return true
}
if (!this.editNewCustomerName) {
if (!(this.editNewCustomerFirstName && this.editNewCustomerLastName)) {
return true
}
if (!(this.editNewCustomerPhone || this.editNewCustomerEmail)) {
@ -1147,7 +1160,8 @@
% endif
editNewCustomerInit() {
this.editNewCustomerName = this.newCustomerName
this.editNewCustomerFirstName = this.newCustomerFirstName
this.editNewCustomerLastName = this.newCustomerLastName
this.editNewCustomerPhone = this.newCustomerPhone
this.editNewCustomerEmail = this.newCustomerEmail
this.editNewCustomerShowDialog = true
@ -1161,14 +1175,17 @@
let params = {
action: 'update_pending_customer',
display_name: this.editNewCustomerName,
first_name: this.editNewCustomerFirstName,
last_name: this.editNewCustomerLastName,
phone_number: this.editNewCustomerPhone,
email_address: this.editNewCustomerEmail,
}
this.submitBatchData(params, response => {
if (response.data.success) {
this.newCustomerName = response.data.new_customer_name
this.contactDisplay = response.data.new_customer_name
this.newCustomerFirstName = response.data.new_customer_first_name
this.newCustomerLastName = response.data.new_customer_last_name
this.newCustomerPhone = response.data.phone_number
this.orderPhoneNumber = response.data.phone_number
this.newCustomerEmail = response.data.email_address