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

@@ -684,24 +684,14 @@
</v-overlay>
</div>
</template>
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Xeslint-disable */
//
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
const FORM_KEY = "global-settings-edit";
const API_BASE_URL = "global-biz-setting/";
//const FORM_CUSTOM_TEMPLATE_KEY = "Global"; //<-- Should always be CoreBizObject AyaType name here where possible
export default {
async created() {
let vm = this;
const vm = this;
try {
await initForm(vm);
vm.rights = window.$gz.role.getRights(window.$gz.type.Global);
vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler);
@@ -715,7 +705,7 @@ export default {
loading: false
});
} else {
await vm.getDataFromApi(); //let getdata handle loading
await vm.getDataFromApi();
}
window.$gz.form.setFormState({
vm: vm,
@@ -745,57 +735,51 @@ export default {
},
data() {
return {
// formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
obj:
//IMPORTANT NOTE: Fields that are NON NULLABLE in the schema for the table but *are* hideable **MUST** have a default value set here or else there will be no way to save the record
//I.E. Serial, usertype fields, ACTIVE
//Also, if it's a non-nullable Enum backed field then it should have a valid selection i.e. not zero if there is no zero
{
id: 0,
concurrency: 0,
filterCaseSensitive: false,
useInventory: true,
taxPartPurchaseId: null,
taxPartSaleId: null,
taxRateSaleId: null,
workOrderCompleteByAge: "00:00:00",
allowScheduleConflicts: false,
workOrderTravelDefaultMinutes: 0,
workLaborScheduleDefaultMinutes: 0,
customerDefaultWorkOrderReportId: null,
customerServiceRequestInfoText: null,
signatureTitle: null,
signatureHeader: null,
signatureFooter: null,
customerAllowCSR: false,
customerAllowCSRInTags: [],
customerAllowCSROutTags: [],
customerAllowViewWO: false,
customerAllowViewWOInTags: [],
customerAllowViewWOOutTags: [],
customerAllowWOWiki: false,
customerAllowWOWikiInTags: [],
customerAllowWOWikiOutTags: [],
customerAllowUserSettings: false,
customerAllowUserSettingsInTags: [],
customerAllowUserSettingsOutTags: [],
customerAllowNotifyServiceImminent: false,
customerAllowNotifyServiceImminentInTags: [],
customerAllowNotifyServiceImminentOutTags: [],
customerAllowNotifyCSRAccepted: false,
customerAllowNotifyCSRAcceptedInTags: [],
customerAllowNotifyCSRAcceptedOutTags: [],
customerAllowNotifyCSRRejected: false,
customerAllowNotifyCSRRejectedInTags: [],
customerAllowNotifyCSRRejectedOutTags: [],
customerAllowNotifyWOCreated: false,
customerAllowNotifyWOCreatedInTags: [],
customerAllowNotifyWOCreatedOutTags: [],
customerAllowNotifyWOCompleted: false,
customerAllowNotifyWOCompletedInTags: [],
customerAllowNotifyWOCompletedOutTags: []
},
obj: {
id: 0,
concurrency: 0,
filterCaseSensitive: false,
useInventory: true,
taxPartPurchaseId: null,
taxPartSaleId: null,
taxRateSaleId: null,
workOrderCompleteByAge: "00:00:00",
allowScheduleConflicts: false,
workOrderTravelDefaultMinutes: 0,
workLaborScheduleDefaultMinutes: 0,
customerDefaultWorkOrderReportId: null,
customerServiceRequestInfoText: null,
signatureTitle: null,
signatureHeader: null,
signatureFooter: null,
customerAllowCSR: false,
customerAllowCSRInTags: [],
customerAllowCSROutTags: [],
customerAllowViewWO: false,
customerAllowViewWOInTags: [],
customerAllowViewWOOutTags: [],
customerAllowWOWiki: false,
customerAllowWOWikiInTags: [],
customerAllowWOWikiOutTags: [],
customerAllowUserSettings: false,
customerAllowUserSettingsInTags: [],
customerAllowUserSettingsOutTags: [],
customerAllowNotifyServiceImminent: false,
customerAllowNotifyServiceImminentInTags: [],
customerAllowNotifyServiceImminentOutTags: [],
customerAllowNotifyCSRAccepted: false,
customerAllowNotifyCSRAcceptedInTags: [],
customerAllowNotifyCSRAcceptedOutTags: [],
customerAllowNotifyCSRRejected: false,
customerAllowNotifyCSRRejectedInTags: [],
customerAllowNotifyCSRRejectedOutTags: [],
customerAllowNotifyWOCreated: false,
customerAllowNotifyWOCreatedInTags: [],
customerAllowNotifyWOCreatedOutTags: [],
customerAllowNotifyWOCompleted: false,
customerAllowNotifyWOCompletedInTags: [],
customerAllowNotifyWOCompletedOutTags: []
},
formState: {
ready: false,
dirty: false,
@@ -810,16 +794,13 @@ export default {
ayaType: window.$gz.type.Project
};
},
//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 && !val.readOnly) {
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
} else {
@@ -833,7 +814,6 @@ export default {
canSave: function() {
return this.formState.valid && this.formState.dirty;
},
ayaTypes: function() {
return window.$gz.type;
},
@@ -850,20 +830,15 @@ export default {
}
},
async getDataFromApi() {
let vm = this;
const vm = this;
window.$gz.form.setFormState({
vm: vm,
loading: true
});
let url = API_BASE_URL;
try {
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.get(url);
const res = await window.$gz.api.get(API_BASE_URL);
if (res.error) {
//Not found?
if (res.error.code == "2010") {
window.$gz.form.handleObjectNotFound(vm);
}
@@ -871,9 +846,7 @@ export default {
window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.obj = res.data;
//modify the menu as necessary
generateMenu(vm);
//Update the form status
window.$gz.form.setFormState({
vm: vm,
dirty: false,
@@ -891,40 +864,31 @@ export default {
}
},
async submit() {
let vm = this;
const vm = this;
if (vm.canSave == false) {
return;
}
try {
window.$gz.form.setFormState({
vm: vm,
loading: true
});
let url = API_BASE_URL;
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.put(url, vm.obj);
const res = await window.$gz.api.put(API_BASE_URL, vm.obj);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//PUT - only concurrency token is returned (**warning, if server changes object other fields then this needs to act more like POST above but is more efficient this way**)
//Handle "put" of an existing record (UPDATE)
//PUT
vm.obj.concurrency = res.data.concurrency;
//Update the form status
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true
});
//refresh the local global settings cache so user can try their settings right away
//get the client version of the global settings object values
let gsets = await window.$gz.api.get("global-biz-setting/client");
const gsets = await window.$gz.api.get("global-biz-setting/client");
if (!gsets.error) {
window.$gz.store.commit("setGlobalSettings", gsets.data);
}
@@ -938,7 +902,6 @@ export default {
});
}
}
//end methods
}
};
@@ -949,13 +912,12 @@ 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":
m.vm.submit();
break;
default:
window.$gz.eventBus.$emit(
"notify-warning",
@@ -969,23 +931,19 @@ async function clickHandler(menuItem) {
//
//
function generateMenu(vm) {
let menuOptions = {
const menuOptions = {
isMain: false,
readOnly: vm.formState.readOnly,
icon: "$ayiCogs",
//title: vm.$ay.t("AdministrationGlobalSettings"),
title: "AdministrationGlobalSettings",
helpUrl: "adm-global-settings",
formData: {
ayaType: window.$gz.type.Project,
recordId: vm.$route.params.recordid,
recordName: vm.$ay.t("AdministrationGlobalSettings")
//,
//formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
},
menuItems: []
};
if (vm.rights.change) {
menuOptions.menuItems.push({
title: "Save",
@@ -995,9 +953,7 @@ function generateMenu(vm) {
vm: vm
});
}
menuOptions.menuItems.push({ divider: true, inset: false });
window.$gz.eventBus.$emit("menu-change", menuOptions);
}
@@ -1006,7 +962,6 @@ function generateMenu(vm) {
//
async function initForm(vm) {
await fetchTranslatedText(vm);
//await window.$gz.formCustomTemplate.get(FORM_CUSTOM_TEMPLATE_KEY, vm);
}
//////////////////////////////////////////////////////////