diff --git a/ayanova/src/components/work-order-address.vue b/ayanova/src/components/work-order-address.vue index 3ae30ed2..5971fdde 100644 --- a/ayanova/src/components/work-order-address.vue +++ b/ayanova/src/components/work-order-address.vue @@ -344,7 +344,8 @@ export default { return { openDialog: false, openSelectDialog: false, - selectType: 1 //1==service / physical, 2==billing / postal + selectType: 1, //1==service / physical, 2==billing / postal + alternateAddresses: [] //{objectName:"NAME-Type",addressViz:"summary",addressFields:{address:aaa,city:aaa,region:aaa,country:ccc, code:ccc, lat:lll, long:lll}} }; }, @@ -376,12 +377,14 @@ export default { window.$gz.form.fieldValueChanged(this.pvm, ref); } }, - AddressSelectAlternatePostal() { + async AddressSelectAlternatePostal() { this.selectType = 2; + await populateAlternateAddresses(this); this.openSelectDialog = true; }, - AddressSelectAlternatePhysical() { + async AddressSelectAlternatePhysical() { this.selectType = 1; + await populateAlternateAddresses(this); this.openSelectDialog = true; }, AddressCopyToPostal() { @@ -483,26 +486,66 @@ export default { return this.pvm.formCustomTemplateKey; }, displayServiceAddress() { - //Address as displayed on workorder form - //as compact as possible - let ret = ""; - if (!window.$gz.util.stringIsNullOrEmpty(this.value.address)) { - ret += this.value.address + " "; - } - if (!window.$gz.util.stringIsNullOrEmpty(this.value.city)) { - ret += this.value.city + " "; - } - if (!window.$gz.util.stringIsNullOrEmpty(this.value.region)) { - ret += this.value.region + " "; - } - if (!window.$gz.util.stringIsNullOrEmpty(this.value.country)) { - ret += this.value.country + " "; - } - - return ret; + return formatAddress(this.value).physical; } } }; + +///////////////////////////////// +// +// +async function populateAlternateAddresses(vm) { + //walk through workorder + //find all the addressible objects, get their addresses and push into list + //at top should be customer, headoffice, then units + vm.alternateAddresses = []; + const wo = vm.value; + if (wo.customerId != null) { + res = await window.$gz.api.get(`customer/address/${wo.customerId}`); + } +} + +//////////////////////////////// +// +// +function formatAddress(o) { + //Format address(es) as compact as possible + let ret = { physical: "", postal: "" }; + + //Physical + if (!window.$gz.util.stringIsNullOrEmpty(o.address)) { + ret.physical += o.address + " "; + } + if (!window.$gz.util.stringIsNullOrEmpty(o.city)) { + ret.physical += o.city + " "; + } + if (!window.$gz.util.stringIsNullOrEmpty(o.region)) { + ret.physical += o.region + " "; + } + if (!window.$gz.util.stringIsNullOrEmpty(o.country)) { + ret.physical += o.country; + } + + //Postal + if (!window.$gz.util.stringIsNullOrEmpty(o.postAddress)) { + ret.postal += o.postAddress + " "; + } + if (!window.$gz.util.stringIsNullOrEmpty(o.postCity)) { + ret.postal += o.postCity + " "; + } + if (!window.$gz.util.stringIsNullOrEmpty(o.postRegion)) { + ret.postal += o.postRegion + " "; + } + if (!window.$gz.util.stringIsNullOrEmpty(o.postCountry)) { + ret.postal += o.postCountry; + } + if (!window.$gz.util.stringIsNullOrEmpty(o.postCode)) { + ret.postal += o.postCode; + } + + return ret; +} + /* postAddress: null, postCity: null,