This commit is contained in:
2021-07-19 23:05:31 +00:00
parent 97df26f982
commit 1256466385
5 changed files with 68 additions and 127 deletions

View File

@@ -152,6 +152,17 @@ export default {
noButtonText: window.$gz.translation.get("Cancel"),
type: ttype
});
},
/////////////////////////////////////
// Custom confirmation pre-translated
//
confirmGenericPreTranslated(msg, ttype = "info") {
return VM_LOCAL.$root.$gzconfirm({
message: msg,
yesButtonText: window.$gz.translation.get("OK"),
noButtonText: window.$gz.translation.get("Cancel"),
type: ttype
});
}
//new functions above here

View File

@@ -16,6 +16,9 @@
<template v-if="options.type == 'info'">
<v-icon large color="info">$ayiInfoCircle</v-icon>
</template>
<template v-if="options.type == 'question'">
<v-icon large color="info">$ayiQuestionCircle</v-icon>
</template>
<template v-if="options.type == 'warning'">
<v-icon large color="warning">$ayiExclamationCircle</v-icon>
</template>
@@ -74,7 +77,7 @@ export default {
message: null,
yesButtonText: null,
noButtonText: null,
type: "info" //one of success, info, warning, and error, see v-alert docs for more info
type: "info" //one of success, info, question, warning, and error, see v-alert docs for more info
}
}),
methods: {

View File

@@ -404,6 +404,49 @@ export default {
}
},
methods: {
async updateContractIfApplicable() {
const id = this.value.items[this.activeWoItemIndex].units[
this.activeItemIndex
].unitId;
if (!id || id == 0) {
return;
}
let res = await window.$gz.api.get(`unit/active-contract/${id}`);
if (res.error) {
window.$gz.eventBus.$emit(
"notify-warning",
window.$gz.errorHandler.errorToString(res, this)
);
} else {
if (res.data.id == 0) {
//no contract, just bail
return;
}
//has contract, if it differs from main work order contract then offer to set it
if (res.data.id == this.value.contractId) {
//same contract, just bail
//yes the date could not be different but we're not going to pick that nit, they can just unset and set if it matters
return;
}
//Prompt user to use new contract
const prompt = this.$ay
.t("ApplyUnitContract")
.replace("{0}", res.data.name);
let dialogResult = await window.$gz.dialog.confirmGenericPreTranslated(
prompt,
"question"
);
if (dialogResult == false) {
return;
} else {
this.value.contractId = res.data.id;
this.value.isDirty = true;
this.pvm.formState.dirty = true;
this.$emit("change");
}
}
},
async getWarrantyInfo() {
this.warrantyInfo = null;
@@ -556,13 +599,14 @@ export default {
}
this.bulkUnitsDialog = false;
},
unitChange(newName) {
async unitChange(newName) {
this.value.items[this.activeWoItemIndex].units[
this.activeItemIndex
].unitViz = newName;
this.value.items[this.activeWoItemIndex].units[
this.activeItemIndex
].warrantyViz = null;
await this.updateContractIfApplicable();
},
newItem() {
let newIndex = this.value.items[this.activeWoItemIndex].units.length;

View File

@@ -2129,7 +2129,8 @@ async function fetchTranslatedText(vm) {
"UnitPurchasedDate",
"UnitReceipt",
"RecentWorkOrders",
"WorkOrderGenerateUnit"
"WorkOrderGenerateUnit",
"ApplyUnitContract"
]);
}