Show "contact notes" when creating new custorder

This commit is contained in:
Lance Edgar 2021-10-03 19:26:25 -04:00
parent 272b0fd071
commit 711e526822
2 changed files with 138 additions and 121 deletions

View file

@ -108,144 +108,157 @@
</div> </div>
<div v-show="contactIsKnown" <div v-show="contactIsKnown"
style="padding-left: 10rem;"> style="padding-left: 10rem; display: flex;">
<b-field label="Customer" grouped> <div :style="{'flex-grow': contactNotes.length ? 0 : 1}">
<b-field style="margin-left: 1rem;""
:expanded="!contactUUID"> <b-field label="Customer" grouped>
<tailbone-autocomplete ref="contactAutocomplete" <b-field style="margin-left: 1rem;""
v-model="contactUUID" :expanded="!contactUUID">
placeholder="Enter name or phone number" <tailbone-autocomplete ref="contactAutocomplete"
:initial-label="contactDisplay" v-model="contactUUID"
% if new_order_requires_customer: placeholder="Enter name or phone number"
serviceUrl="${url('{}.customer_autocomplete'.format(route_prefix))}" :initial-label="contactDisplay"
% else: % if new_order_requires_customer:
serviceUrl="${url('{}.person_autocomplete'.format(route_prefix))}" serviceUrl="${url('{}.customer_autocomplete'.format(route_prefix))}"
% endif % else:
@input="contactChanged"> serviceUrl="${url('{}.person_autocomplete'.format(route_prefix))}"
</tailbone-autocomplete> % endif
@input="contactChanged">
</tailbone-autocomplete>
</b-field>
<b-button v-if="contactUUID && contactProfileURL"
type="is-primary"
tag="a" target="_blank"
:href="contactProfileURL"
icon-pack="fas"
icon-left="external-link-alt">
View Profile
</b-button>
</b-field> </b-field>
<b-button v-if="contactUUID && contactProfileURL"
type="is-primary"
tag="a" target="_blank"
:href="contactProfileURL"
icon-pack="fas"
icon-left="external-link-alt">
View Profile
</b-button>
</b-field>
<b-field grouped v-show="contactUUID" <b-field grouped v-show="contactUUID"
style="margin-top: 2rem;"> style="margin-top: 2rem;">
<b-field label="Phone Number" <b-field label="Phone Number"
style="margin-right: 3rem;"> style="margin-right: 3rem;">
<div class="level"> <div class="level">
<div class="level-left"> <div class="level-left">
<div class="level-item"> <div class="level-item">
{{ orderPhoneNumber }} {{ orderPhoneNumber }}
</div> </div>
<div class="level-item"> <div class="level-item">
<b-button type="is-primary" <b-button type="is-primary"
@click="editPhoneNumberInit()" @click="editPhoneNumberInit()"
icon-pack="fas" icon-pack="fas"
icon-left="edit"> icon-left="edit">
Edit Edit
</b-button> </b-button>
<b-modal has-modal-card <b-modal has-modal-card
:active.sync="editPhoneNumberShowDialog"> :active.sync="editPhoneNumberShowDialog">
<div class="modal-card"> <div class="modal-card">
<header class="modal-card-head"> <header class="modal-card-head">
<p class="modal-card-title">Edit Phone Number</p> <p class="modal-card-title">Edit Phone Number</p>
</header> </header>
<section class="modal-card-body"> <section class="modal-card-body">
<b-field label="Phone Number" <b-field label="Phone Number"
:type="editPhoneNumberValue ? null : 'is-danger'"> :type="editPhoneNumberValue ? null : 'is-danger'">
<b-input v-model="editPhoneNumberValue" <b-input v-model="editPhoneNumberValue"
ref="editPhoneNumberInput"> ref="editPhoneNumberInput">
</b-input> </b-input>
</b-field> </b-field>
</section> </section>
<footer class="modal-card-foot"> <footer class="modal-card-foot">
<b-button type="is-primary" <b-button type="is-primary"
icon-pack="fas" icon-pack="fas"
icon-left="save" icon-left="save"
:disabled="editPhoneNumberSaveDisabled" :disabled="editPhoneNumberSaveDisabled"
@click="editPhoneNumberSave()"> @click="editPhoneNumberSave()">
{{ editPhoneNumberSaveText }} {{ editPhoneNumberSaveText }}
</b-button> </b-button>
<b-button @click="editPhoneNumberShowDialog = false"> <b-button @click="editPhoneNumberShowDialog = false">
Cancel Cancel
</b-button> </b-button>
</footer> </footer>
</div> </div>
</b-modal> </b-modal>
</div>
</div> </div>
</div> </div>
</div> </b-field>
</b-field>
<b-field label="Email Address"> <b-field label="Email Address">
<div class="level"> <div class="level">
<div class="level-left"> <div class="level-left">
<div class="level-item"> <div class="level-item">
<span v-if="orderEmailAddress"> <span v-if="orderEmailAddress">
{{ orderEmailAddress }} {{ orderEmailAddress }}
</span> </span>
<span v-if="!orderEmailAddress" <span v-if="!orderEmailAddress"
class="has-text-danger"> class="has-text-danger">
(no valid email on file) (no valid email on file)
</span> </span>
</div> </div>
<div class="level-item"> <div class="level-item">
<b-button type="is-primary" <b-button type="is-primary"
@click="editEmailAddressInit()" @click="editEmailAddressInit()"
icon-pack="fas" icon-pack="fas"
icon-left="edit"> icon-left="edit">
Edit Edit
</b-button> </b-button>
<b-modal has-modal-card <b-modal has-modal-card
:active.sync="editEmailAddressShowDialog"> :active.sync="editEmailAddressShowDialog">
<div class="modal-card"> <div class="modal-card">
<header class="modal-card-head"> <header class="modal-card-head">
<p class="modal-card-title">Edit Email Address</p> <p class="modal-card-title">Edit Email Address</p>
</header> </header>
<section class="modal-card-body"> <section class="modal-card-body">
<b-field label="Email Address" <b-field label="Email Address"
:type="editEmailAddressValue ? null : 'is-danger'"> :type="editEmailAddressValue ? null : 'is-danger'">
<b-input v-model="editEmailAddressValue" <b-input v-model="editEmailAddressValue"
ref="editEmailAddressInput"> ref="editEmailAddressInput">
</b-input> </b-input>
</b-field> </b-field>
</section> </section>
<footer class="modal-card-foot"> <footer class="modal-card-foot">
<b-button type="is-primary" <b-button type="is-primary"
icon-pack="fas" icon-pack="fas"
icon-left="save" icon-left="save"
:disabled="editEmailAddressSaveDisabled" :disabled="editEmailAddressSaveDisabled"
@click="editEmailAddressSave()"> @click="editEmailAddressSave()">
{{ editEmailAddressSaveText }} {{ editEmailAddressSaveText }}
</b-button> </b-button>
<b-button @click="editEmailAddressShowDialog = false"> <b-button @click="editEmailAddressShowDialog = false">
Cancel Cancel
</b-button> </b-button>
</footer> </footer>
</div> </div>
</b-modal> </b-modal>
</div>
</div> </div>
</div> </div>
</div> </b-field>
</b-field>
</b-field> </b-field>
</div>
<div v-show="contactNotes.length"
style="margin-left: 1rem;">
<b-notification v-for="note in contactNotes"
:key="note"
type="is-warning"
:closable="false">
{{ note }}
</b-notification>
</div>
</div> </div>
<br /> <br />
@ -505,6 +518,7 @@
customerName: null, customerName: null,
phoneNumber: null, phoneNumber: null,
orderEmailAddress: ${json.dumps(batch.email_address)|n}, orderEmailAddress: ${json.dumps(batch.email_address)|n},
contactNotes: ${json.dumps(contact_notes)|n},
editPhoneNumberShowDialog: false, editPhoneNumberShowDialog: false,
editPhoneNumberValue: null, editPhoneNumberValue: null,
@ -803,7 +817,6 @@
} }
let that = this let that = this
this.submitBatchData(params, function(response) { this.submitBatchData(params, function(response) {
console.log(response.data)
% if new_order_requires_customer: % if new_order_requires_customer:
that.contactUUID = response.data.customer_uuid that.contactUUID = response.data.customer_uuid
% else: % else:
@ -812,6 +825,7 @@
that.orderPhoneNumber = response.data.phone_number that.orderPhoneNumber = response.data.phone_number
that.orderEmailAddress = response.data.email_address that.orderEmailAddress = response.data.email_address
that.contactProfileURL = response.data.contact_profile_url that.contactProfileURL = response.data.contact_profile_url
that.contactNotes = response.data.contact_notes
}) })
}, },

View file

@ -256,6 +256,7 @@ class CustomerOrderView(MasterView):
'normalized_batch': self.normalize_batch(batch), 'normalized_batch': self.normalize_batch(batch),
'new_order_requires_customer': self.handler.new_order_requires_customer(), 'new_order_requires_customer': self.handler.new_order_requires_customer(),
'contact_profile_url': None, 'contact_profile_url': None,
'contact_notes': self.handler.get_contact_notes(batch),
'order_items': items, 'order_items': items,
'product_autocomplete_url': self.request.route_url(product_autocomplete)} 'product_autocomplete_url': self.request.route_url(product_autocomplete)}
@ -391,6 +392,7 @@ class CustomerOrderView(MasterView):
'person_uuid': batch.person_uuid, 'person_uuid': batch.person_uuid,
'phone_number': batch.phone_number, 'phone_number': batch.phone_number,
'email_address': batch.email_address, 'email_address': batch.email_address,
'contact_notes': self.handler.get_contact_notes(batch),
} }
# maybe add profile URL # maybe add profile URL
@ -411,6 +413,7 @@ class CustomerOrderView(MasterView):
'phone_number': batch.phone_number, 'phone_number': batch.phone_number,
'email_address': batch.email_address, 'email_address': batch.email_address,
'contact_profile_url': None, 'contact_profile_url': None,
'contact_notes': self.handler.get_contact_notes(batch),
} }
return context return context