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

@@ -1,7 +1,6 @@
<template>
<div v-if="formState.ready" v-resize="onResize" class="my-n8">
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
<v-sheet height="64">
<v-toolbar flat class="ml-n3">
<v-btn outlined class="xxmr-4" color="grey darken-2" @click="setToday">
@@ -402,14 +401,12 @@
</template>
</div>
</template>
<script>
const FORM_KEY = "home-schedule";
const CLICK_DETECT_TIMEOUT = 200; //100 is a bit too fast to recognize a click
export default {
async created() {
let vm = this;
const vm = this;
try {
await initForm(vm);
window.$gz.eventBus.$on("menu-click", clickHandler);
@@ -468,7 +465,7 @@ export default {
});
},
newItem(atype) {
let newEvent = this.events[this.events.length - 1];
const newEvent = this.events[this.events.length - 1];
const addStart = window.$gz.locale.localScheduleFormatToUTC8601String(
newEvent.start,
this.timeZoneName
@@ -508,7 +505,6 @@ export default {
});
break;
}
//remove faux item, server will provide it back once it's created anyway
this.events.splice(this.events.length - 1);
this.newItemDialog = false;
@@ -549,7 +545,7 @@ export default {
}
//MODIFY existing event, drag or extend
if (this.dragEvent || this.extendEvent) {
let param = { type: null, id: null, start: null, end: null };
const param = { type: null, id: null, start: null, end: null };
if (this.dragEvent) {
param.type = this.dragEvent.type;
@@ -574,12 +570,9 @@ export default {
this.timeZoneName
);
}
try {
window.$gz.form.deleteAllErrorBoxErrors(this);
let res = await window.$gz.api.post("schedule/adjust", param);
const res = await window.$gz.api.post("schedule/adjust", param);
if (res.error) {
this.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(this);
@@ -677,11 +670,9 @@ export default {
this.dragEvent.start = mouseDate;
this.dragEvent.end = this.dragEvent.end + moveDelta;
},
startTime(tms) {
//This is called on the start of dragging an existing schedule item or drag extending a NEW schedule item
const mouse = this.toTime(tms);
if (this.dragEvent && this.dragTime === null) {
//# DAY VIEW *DRAG* EXISTING START EVENT (not extend)
//(also called on simple click to view schedule more info)
@@ -710,7 +701,6 @@ export default {
roundTime(time, down = true) {
const roundTo = 15; // minutes
const roundDownTime = roundTo * 60 * 1000;
return down
? time - (time % roundDownTime)
: time + (roundDownTime - (time % roundDownTime));
@@ -731,7 +721,6 @@ export default {
JSON.stringify({
start: this.$refs.calendar.start,
end: this.$refs.calendar.end,
focus: this.focus,
firstInterval: this.$refs.calendar.firstInterval
})
@@ -790,7 +779,6 @@ export default {
}
let route = null;
this.evInfo = {};
switch (event.type) {
case window.$gz.type.WorkOrderItemScheduledUser:
route = `workorder/items/scheduled-users/sched-info/${event.id}`;
@@ -803,12 +791,11 @@ export default {
break;
}
if (route) {
let res = await window.$gz.api.get(route);
const res = await window.$gz.api.get(route);
if (!res.error) {
this.evInfo = res.data;
}
}
const open = () => {
this.selectedEvent = event;
this.selectedElement = nativeEvent.target;
@@ -816,20 +803,18 @@ export default {
requestAnimationFrame(() => (this.moreInfoDialog = true))
);
};
if (this.moreInfoDialog) {
this.moreInfoDialog = false;
requestAnimationFrame(() => requestAnimationFrame(() => open()));
} else {
open();
}
nativeEvent.stopPropagation();
},
async fetchEvents({ start, end }) {
try {
window.$gz.form.deleteAllErrorBoxErrors(this);
let res = await window.$gz.api.post("schedule/personal", {
const res = await window.$gz.api.post("schedule/personal", {
view: window.$gz.util.calendarViewToAyaNovaEnum(this.viewType),
dark: this.$store.state.darkMode,
start: window.$gz.locale.localTimeDateStringToUTC8601String(
@@ -845,7 +830,6 @@ export default {
reviews: this.formUserOptions.reviews,
reminders: this.formUserOptions.reminders
});
if (res.error) {
this.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(this);
@@ -888,11 +872,11 @@ 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 "report":
// let res = await m.vm.$refs.reportSelector.open(
// const res = await m.vm.$refs.reportSelector.open(
// {
// AType: window.$gz.type.Project,
// selectedRowIds: [m.vm.obj.id]
@@ -951,7 +935,7 @@ async function clickHandler(menuItem) {
//
//
function generateMenu(vm) {
let menuOptions = {
const menuOptions = {
isMain: true,
readOnly: vm.formState.readOnly,
icon: "$ayiCalendarDay",
@@ -960,8 +944,7 @@ function generateMenu(vm) {
menuItems: []
};
// //REPORTS
// //Report not Print, print is a further option
// //
// menuOptions.menuItems.push({
// title: "Report",
// icon: "$ayiFileAlt",
@@ -969,8 +952,8 @@ 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) {
// menuOptions.menuItems.push({
// title: lastReport.name,
@@ -1010,7 +993,6 @@ function generateMenu(vm) {
key: FORM_KEY + ":WorkOrderItemLaborList",
vm: vm
});
//--- /show all ---
}
menuOptions.menuItems.push({ divider: true, inset: false });
@@ -1040,7 +1022,7 @@ function getFormSettings(vm) {
}
function saveFormSettings(vm) {
let formSettings = window.$gz.form.getFormSettings(FORM_KEY);
const formSettings = window.$gz.form.getFormSettings(FORM_KEY);
formSettings.temp = { viewType: vm.viewType, focus: vm.focus };
window.$gz.form.setFormSettings(FORM_KEY, formSettings);
@@ -1049,7 +1031,7 @@ function saveFormSettings(vm) {
////////////////////
//
async function getFormUserOptions(vm) {
let res = await window.$gz.api.get(`form-user-options/${FORM_KEY}`);
const res = await window.$gz.api.get(`form-user-options/${FORM_KEY}`);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
@@ -1088,15 +1070,13 @@ async function saveFormUserOptions(vm) {
//translate tempFirstTime to local time
if (vm.tempFirstTime) {
//convert picker's utc time to local hour:MM
let localTime = window.$gz.DateTime.fromISO(vm.tempFirstTime).toLocal();
const localTime = window.$gz.DateTime.fromISO(vm.tempFirstTime).toLocal();
vm.formUserOptions.firstTime = `${localTime.hour}:${localTime.minute}`;
}
let res = await window.$gz.api.post("form-user-options", {
const res = await window.$gz.api.post("form-user-options", {
formKey: FORM_KEY,
options: JSON.stringify(vm.formUserOptions)
});
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);