Improve contact name handling for new custorder
This commit is contained in:
parent
c611eb3787
commit
5e339bb7ea
|
@ -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,11 +386,17 @@
|
|||
</header>
|
||||
|
||||
<section class="modal-card-body">
|
||||
<b-field label="Customer Name">
|
||||
<b-input v-model="editNewCustomerName"
|
||||
<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">
|
||||
<b-input v-model="editNewCustomerPhone"></b-input>
|
||||
|
@ -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
|
||||
|
|
|
@ -48,7 +48,7 @@ class CustomerOrderBatchView(BatchMasterView):
|
|||
|
||||
grid_columns = [
|
||||
'id',
|
||||
'customer',
|
||||
'contact_name',
|
||||
'rowcount',
|
||||
'total_price',
|
||||
'created',
|
||||
|
@ -98,7 +98,7 @@ class CustomerOrderBatchView(BatchMasterView):
|
|||
|
||||
g.set_type('total_price', 'currency')
|
||||
|
||||
g.set_link('customer')
|
||||
g.set_link('contact_name')
|
||||
g.set_link('created')
|
||||
g.set_link('created_by')
|
||||
|
||||
|
|
|
@ -405,7 +405,7 @@ class CustomerOrderView(MasterView):
|
|||
'customer_uuid': batch.customer_uuid,
|
||||
'person_uuid': batch.person_uuid,
|
||||
'phone_number': batch.phone_number,
|
||||
'contact_display': self.handler.get_contact_display(batch),
|
||||
'contact_display': batch.contact_name,
|
||||
'email_address': batch.email_address,
|
||||
'contact_phones': self.handler.get_contact_phones(batch),
|
||||
'contact_emails': self.handler.get_contact_emails(batch),
|
||||
|
@ -414,6 +414,8 @@ class CustomerOrderView(MasterView):
|
|||
'add_email_address': bool(batch.get_param('add_email_address')),
|
||||
'contact_profile_url': None,
|
||||
'new_customer_name': None,
|
||||
'new_customer_first_name': None,
|
||||
'new_customer_last_name': None,
|
||||
'new_customer_phone': None,
|
||||
'new_customer_email': None,
|
||||
}
|
||||
|
@ -421,6 +423,8 @@ class CustomerOrderView(MasterView):
|
|||
pending = batch.pending_customer
|
||||
if pending:
|
||||
context.update({
|
||||
'new_customer_first_name': pending.first_name,
|
||||
'new_customer_last_name': pending.last_name,
|
||||
'new_customer_name': pending.display_name,
|
||||
'new_customer_phone': pending.phone_number,
|
||||
'new_customer_email': pending.email_address,
|
||||
|
@ -486,6 +490,7 @@ class CustomerOrderView(MasterView):
|
|||
def update_pending_customer(self, batch, data):
|
||||
model = self.model
|
||||
app = self.get_rattail_app()
|
||||
people = app.get_people_handler()
|
||||
|
||||
# clear out any contact it may have
|
||||
self.handler.unassign_contact(batch)
|
||||
|
@ -499,11 +504,15 @@ class CustomerOrderView(MasterView):
|
|||
batch.pending_customer = pending
|
||||
|
||||
# update pending customer info
|
||||
pending.display_name = data['display_name']
|
||||
pending.first_name = data['first_name']
|
||||
pending.last_name = data['last_name']
|
||||
pending.display_name = people.normalize_full_name(pending.first_name,
|
||||
pending.last_name)
|
||||
pending.phone_number = app.format_phone_number(data['phone_number'])
|
||||
pending.email_address = data['email_address']
|
||||
|
||||
# also update the batch w/ contact info
|
||||
batch.contact_name = pending.display_name
|
||||
batch.phone_number = pending.phone_number
|
||||
batch.email_address = pending.email_address
|
||||
|
||||
|
|
Loading…
Reference in a new issue