HUGE REFACTOR / CLEANUP

if there is a issue it's probably something in here that was changed
This commit is contained in:
2021-09-28 20:19:44 +00:00
parent 51eddfede9
commit d0afdd9855
238 changed files with 3127 additions and 8614 deletions

View File

@@ -15,7 +15,6 @@
data-cy="woHeader"
@change="setDirty()"
/>
<GzPMItems
v-model="obj"
:form-key="formCustomTemplateKey"
@@ -66,20 +65,12 @@
</template>
</div>
</template>
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Xeslint-disable */
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
import GzPMHeader from "../components/pm-header.vue";
import GzPMItems from "../components/pm-items.vue";
const FORM_KEY = "pm-edit";
const API_BASE_URL = "pm/";
const FORM_CUSTOM_TEMPLATE_KEY = "PM"; //<-- Should always be CoreBizObject AyaType name here where possible
const FORM_CUSTOM_TEMPLATE_KEY = "PM";
export default {
components: {
@@ -92,11 +83,9 @@ export default {
try {
await initForm(vm);
//set base rights
vm.rights = window.$gz.role.getRights(window.$gz.type.PM);
window.$gz.eventBus.$on("menu-click", clickHandler);
let setDirty = false;
let setValid = true;
//id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) {
@@ -111,7 +100,7 @@ export default {
loading: false
});
} else {
await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
await vm.getDataFromApi(vm.$route.params.recordid);
//check for copy wo item on route params
let wi = this.$route.params.copyItem;
if (wi) {
@@ -152,7 +141,7 @@ export default {
vm: vm,
loading: false,
dirty: setDirty,
valid: setValid
valid: true
});
//update which areas are available to user and force generate menu
@@ -272,23 +261,19 @@ export default {
genCopyAttachments: false
};
},
//WATCHERS
watch: {
formState: {
handler: function(val) {
//,oldval is available here too if necessary
if (this.formState.loading) {
return;
}
//enable / disable save button
if (val.dirty && val.valid) {
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
} else {
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
}
//enable / disable duplicate / new button
if (!val.dirty && val.valid && !val.readOnly) {
window.$gz.eventBus.$emit(
"menu-enable-item",
@@ -353,7 +338,6 @@ export default {
const res = await window.$gz.api.get(url);
if (res.error) {
//Not found?
if (res.error.code == "2010") {
window.$gz.form.handleObjectNotFound(vm);
}
@@ -410,12 +394,10 @@ export default {
vm.lastGetContractId = vm.obj.contractId; //preserve for triggering full update if something changes it later
vm.lastGetCustomerId = vm.obj.customerId; //preserve for triggering full update if something changes it later
//modify the menu as necessary
generateMenu(vm);
//update which areas are available to user
updateRights(vm);
//Update the form status
window.$gz.form.setFormState({
vm: vm,
dirty: false,
@@ -444,7 +426,6 @@ export default {
loading: true
});
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
//#######################################################
@@ -542,23 +523,21 @@ export default {
}
},
async remove() {
let vm = this;
const vm = this;
try {
let dialogResult = await window.$gz.dialog.confirmDelete();
if (dialogResult != true) {
return;
}
//do the delete
window.$gz.form.setFormState({
vm: vm,
loading: true
});
//No need to delete a new record, just abandon it...
if (vm.$route.params.recordid == 0) {
//this should not get offered for delete but to be safe and clear just in case:
JUST_DELETED = true;
// navigate backwards
vm.$router.go(-1);
} else {
let url = API_BASE_URL + vm.$route.params.recordid;
@@ -570,14 +549,13 @@ export default {
window.$gz.form.setErrorBoxErrors(vm);
} else {
//workaround to prevent warning about leaving dirty record
//For some reason I couldn't just reset isdirty in formstate
JUST_DELETED = true;
// navigate backwards
vm.$router.go(-1);
}
}
} catch (error) {
//Update the form status
window.$gz.form.setFormState({
vm: vm,
loading: false
@@ -610,7 +588,7 @@ export default {
if (!this.genCopyWiki) {
cp.wiki = null; //already copied, need to remove it instead
}
//Navigate to new record
this.$router.push({
name: "pm-edit",
params: {
@@ -649,7 +627,6 @@ export default {
cp.techSignatureName = null;
cp.techSignatureCaptured = null;
//Navigate to new record
this.$router.push({
name: "workorder-edit",
params: {
@@ -684,7 +661,6 @@ export default {
cp.submitted = null;
cp.approved = null;
//Navigate to new record
this.$router.push({
name: "quote-edit",
params: {
@@ -768,8 +744,6 @@ export default {
});
}
}
//end methods
}
};
@@ -1010,7 +984,7 @@ async function saveUnits(vm, woItemIndex) {
//Server will update fields on put or post for most graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
res.data.warrantyViz = null; //Add local key so it's reactive in vue
vm.obj.items[woItemIndex].units.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
vm.obj.items[woItemIndex].units.splice(i, 1, res.data);
}
}
}
@@ -1052,7 +1026,7 @@ async function saveScheduledUsers(vm, woItemIndex) {
} else {
//Server will update fields on put or post for most graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].scheduledUsers.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
vm.obj.items[woItemIndex].scheduledUsers.splice(i, 1, res.data);
}
}
}
@@ -1120,7 +1094,7 @@ async function saveTasks(vm, woItemIndex) {
} else {
//Server will update fields on put or post for most graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].tasks.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
vm.obj.items[woItemIndex].tasks.splice(i, 1, res.data);
}
}
}
@@ -1226,7 +1200,7 @@ async function saveParts(vm, woItemIndex) {
} else {
//Server will update fields on put or post for most pm graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].parts.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
vm.obj.items[woItemIndex].parts.splice(i, 1, res.data);
}
}
}
@@ -1262,7 +1236,7 @@ async function saveLabors(vm, woItemIndex) {
} else {
//Server will update fields on put or post for most pm graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].labors.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
vm.obj.items[woItemIndex].labors.splice(i, 1, res.data);
}
}
}
@@ -1329,7 +1303,7 @@ async function saveTravels(vm, woItemIndex) {
} else {
//Server will update fields on put or post for most pm graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].travels.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
vm.obj.items[woItemIndex].travels.splice(i, 1, res.data);
}
}
}
@@ -1425,7 +1399,7 @@ async function saveExpenses(vm, woItemIndex) {
} else {
//Server will update fields on put or post for most pm graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].expenses.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
vm.obj.items[woItemIndex].expenses.splice(i, 1, res.data);
}
}
}
@@ -1489,7 +1463,7 @@ async function saveLoans(vm, woItemIndex) {
} else {
//Server will update fields on put or post for most pm graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].loans.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
vm.obj.items[woItemIndex].loans.splice(i, 1, res.data);
}
}
}
@@ -1560,7 +1534,7 @@ async function saveOutsideServices(vm, woItemIndex) {
} else {
//Server will update fields on put or post for most pm graph objecs so need to update entire object here
res.data.isDirty = false; //prime isDirty to detect future edits
vm.obj.items[woItemIndex].outsideServices.splice(i, 1, res.data); //vue needs the splice rather than just setting the value in order to trigger reactivity or else the UI won't update
vm.obj.items[woItemIndex].outsideServices.splice(i, 1, res.data);
}
}
}
@@ -1674,7 +1648,7 @@ async function clickHandler(menuItem) {
if (!menuItem) {
return;
}
let m = window.$gz.menu.parseMenuItem(menuItem);
const m = window.$gz.menu.parseMenuItem(menuItem);
if (m.owner == FORM_KEY && !m.disabled) {
switch (m.key) {
case "save":
@@ -1705,7 +1679,7 @@ async function clickHandler(menuItem) {
m.vm.duplicateDlg = true;
break;
case "report":
let res = await m.vm.$refs.reportSelector.open(
const res = await m.vm.$refs.reportSelector.open(
{
AType: window.$gz.type.PM,
selectedRowIds: [m.vm.obj.id]
@@ -1764,7 +1738,7 @@ async function clickHandler(menuItem) {
//
//
function generateMenu(vm) {
let menuOptions = {
const menuOptions = {
isMain: false,
readOnly: vm.formState.readOnly,
hideCoreBizStandardOptions: vm.obj.userIsRestrictedType,
@@ -1805,8 +1779,6 @@ function generateMenu(vm) {
});
}
//REPORTS
//Report not Print, print is a further option
menuOptions.menuItems.push({
title: "Report",
icon: "$ayiFileAlt",
@@ -1814,8 +1786,7 @@ function generateMenu(vm) {
vm: vm
});
//get last report selected
let lastReport = window.$gz.form.getLastReport(FORM_KEY);
const lastReport = window.$gz.form.getLastReport(FORM_KEY);
if (lastReport != null && !vm.obj.userIsRestrictedType) {
menuOptions.menuItems.push({
title: lastReport.name,