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 v-show="contactIsKnown"
style="padding-left: 10rem;">
style="padding-left: 10rem; display: flex;">
<b-field label="Customer" grouped>
<b-field style="margin-left: 1rem;""
:expanded="!contactUUID">
<tailbone-autocomplete ref="contactAutocomplete"
v-model="contactUUID"
placeholder="Enter name or phone number"
:initial-label="contactDisplay"
% if new_order_requires_customer:
serviceUrl="${url('{}.customer_autocomplete'.format(route_prefix))}"
% else:
serviceUrl="${url('{}.person_autocomplete'.format(route_prefix))}"
% endif
@input="contactChanged">
</tailbone-autocomplete>
<div :style="{'flex-grow': contactNotes.length ? 0 : 1}">
<b-field label="Customer" grouped>
<b-field style="margin-left: 1rem;""
:expanded="!contactUUID">
<tailbone-autocomplete ref="contactAutocomplete"
v-model="contactUUID"
placeholder="Enter name or phone number"
:initial-label="contactDisplay"
% if new_order_requires_customer:
serviceUrl="${url('{}.customer_autocomplete'.format(route_prefix))}"
% else:
serviceUrl="${url('{}.person_autocomplete'.format(route_prefix))}"
% 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-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"
style="margin-top: 2rem;">
<b-field grouped v-show="contactUUID"
style="margin-top: 2rem;">
<b-field label="Phone Number"
style="margin-right: 3rem;">
<div class="level">
<div class="level-left">
<div class="level-item">
{{ orderPhoneNumber }}
</div>
<div class="level-item">
<b-button type="is-primary"
@click="editPhoneNumberInit()"
icon-pack="fas"
icon-left="edit">
Edit
</b-button>
<b-field label="Phone Number"
style="margin-right: 3rem;">
<div class="level">
<div class="level-left">
<div class="level-item">
{{ orderPhoneNumber }}
</div>
<div class="level-item">
<b-button type="is-primary"
@click="editPhoneNumberInit()"
icon-pack="fas"
icon-left="edit">
Edit
</b-button>
<b-modal has-modal-card
:active.sync="editPhoneNumberShowDialog">
<div class="modal-card">
<b-modal has-modal-card
:active.sync="editPhoneNumberShowDialog">
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">Edit Phone Number</p>
</header>
<header class="modal-card-head">
<p class="modal-card-title">Edit Phone Number</p>
</header>
<section class="modal-card-body">
<b-field label="Phone Number"
:type="editPhoneNumberValue ? null : 'is-danger'">
<b-input v-model="editPhoneNumberValue"
ref="editPhoneNumberInput">
</b-input>
</b-field>
</section>
<section class="modal-card-body">
<b-field label="Phone Number"
:type="editPhoneNumberValue ? null : 'is-danger'">
<b-input v-model="editPhoneNumberValue"
ref="editPhoneNumberInput">
</b-input>
</b-field>
</section>
<footer class="modal-card-foot">
<b-button type="is-primary"
icon-pack="fas"
icon-left="save"
:disabled="editPhoneNumberSaveDisabled"
@click="editPhoneNumberSave()">
{{ editPhoneNumberSaveText }}
</b-button>
<b-button @click="editPhoneNumberShowDialog = false">
Cancel
</b-button>
</footer>
</div>
</b-modal>
<footer class="modal-card-foot">
<b-button type="is-primary"
icon-pack="fas"
icon-left="save"
:disabled="editPhoneNumberSaveDisabled"
@click="editPhoneNumberSave()">
{{ editPhoneNumberSaveText }}
</b-button>
<b-button @click="editPhoneNumberShowDialog = false">
Cancel
</b-button>
</footer>
</div>
</b-modal>
</div>
</div>
</div>
</div>
</b-field>
</b-field>
<b-field label="Email Address">
<div class="level">
<div class="level-left">
<div class="level-item">
<span v-if="orderEmailAddress">
{{ orderEmailAddress }}
</span>
<span v-if="!orderEmailAddress"
class="has-text-danger">
(no valid email on file)
</span>
</div>
<div class="level-item">
<b-button type="is-primary"
@click="editEmailAddressInit()"
icon-pack="fas"
icon-left="edit">
Edit
</b-button>
<b-modal has-modal-card
:active.sync="editEmailAddressShowDialog">
<div class="modal-card">
<b-field label="Email Address">
<div class="level">
<div class="level-left">
<div class="level-item">
<span v-if="orderEmailAddress">
{{ orderEmailAddress }}
</span>
<span v-if="!orderEmailAddress"
class="has-text-danger">
(no valid email on file)
</span>
</div>
<div class="level-item">
<b-button type="is-primary"
@click="editEmailAddressInit()"
icon-pack="fas"
icon-left="edit">
Edit
</b-button>
<b-modal has-modal-card
:active.sync="editEmailAddressShowDialog">
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">Edit Email Address</p>
</header>
<header class="modal-card-head">
<p class="modal-card-title">Edit Email Address</p>
</header>
<section class="modal-card-body">
<b-field label="Email Address"
:type="editEmailAddressValue ? null : 'is-danger'">
<b-input v-model="editEmailAddressValue"
ref="editEmailAddressInput">
</b-input>
</b-field>
</section>
<section class="modal-card-body">
<b-field label="Email Address"
:type="editEmailAddressValue ? null : 'is-danger'">
<b-input v-model="editEmailAddressValue"
ref="editEmailAddressInput">
</b-input>
</b-field>
</section>
<footer class="modal-card-foot">
<b-button type="is-primary"
icon-pack="fas"
icon-left="save"
:disabled="editEmailAddressSaveDisabled"
@click="editEmailAddressSave()">
{{ editEmailAddressSaveText }}
</b-button>
<b-button @click="editEmailAddressShowDialog = false">
Cancel
</b-button>
</footer>
</div>
</b-modal>
<footer class="modal-card-foot">
<b-button type="is-primary"
icon-pack="fas"
icon-left="save"
:disabled="editEmailAddressSaveDisabled"
@click="editEmailAddressSave()">
{{ editEmailAddressSaveText }}
</b-button>
<b-button @click="editEmailAddressShowDialog = false">
Cancel
</b-button>
</footer>
</div>
</b-modal>
</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>
<br />
@ -505,6 +518,7 @@
customerName: null,
phoneNumber: null,
orderEmailAddress: ${json.dumps(batch.email_address)|n},
contactNotes: ${json.dumps(contact_notes)|n},
editPhoneNumberShowDialog: false,
editPhoneNumberValue: null,
@ -803,7 +817,6 @@
}
let that = this
this.submitBatchData(params, function(response) {
console.log(response.data)
% if new_order_requires_customer:
that.contactUUID = response.data.customer_uuid
% else:
@ -812,6 +825,7 @@
that.orderPhoneNumber = response.data.phone_number
that.orderEmailAddress = response.data.email_address
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),
'new_order_requires_customer': self.handler.new_order_requires_customer(),
'contact_profile_url': None,
'contact_notes': self.handler.get_contact_notes(batch),
'order_items': items,
'product_autocomplete_url': self.request.route_url(product_autocomplete)}
@ -391,6 +392,7 @@ class CustomerOrderView(MasterView):
'person_uuid': batch.person_uuid,
'phone_number': batch.phone_number,
'email_address': batch.email_address,
'contact_notes': self.handler.get_contact_notes(batch),
}
# maybe add profile URL
@ -411,6 +413,7 @@ class CustomerOrderView(MasterView):
'phone_number': batch.phone_number,
'email_address': batch.email_address,
'contact_profile_url': None,
'contact_notes': self.handler.get_contact_notes(batch),
}
return context