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

@@ -96,9 +96,6 @@
</v-row>
</template>
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Xeslint-disable */
////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//NOTE: This is a simple form with no need for business rules or validation so stripped out any extraneous code related to all that
//
@@ -109,18 +106,15 @@ export default {
window.$gz.eventBus.$off("menu-click", clickHandler);
},
async created() {
let vm = this;
const vm = this;
try {
await initForm(vm);
vm.formState.ready = true;
vm.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler);
//NOTE: this would normally be in getDataFromAPI but this form doesn't really need that function so doing it here
//modify the menu as necessary
generateMenu(vm);
await vm.getDataFromApi();
vm.formState.loading = false;
} catch (err) {
vm.formState.ready = true;
@@ -151,13 +145,10 @@ export default {
watch: {
formState: {
handler: function(val) {
//,oldval is available here too if necessary
if (this.formState.loading) {
return;
}
//enable / disable save button
let canSave = val.dirty && val.valid && !val.readOnly;
const canSave = val.dirty && val.valid && !val.readOnly;
if (canSave) {
window.$gz.eventBus.$emit("menu-enable-item", FORM_KEY + ":save");
} else {
@@ -184,13 +175,12 @@ export default {
}
},
async getDataFromApi() {
let vm = this;
const vm = this;
vm.formState.loading = true;
window.$gz.form.deleteAllErrorBoxErrors(vm);
try {
//get current values
let res = await window.$gz.api.get(API_BASE_URL);
const res = await window.$gz.api.get(API_BASE_URL);
if (res.error) {
vm.formState.serverError = res.error;
@@ -198,7 +188,6 @@ export default {
} else {
vm.obj = res.data;
//Update the form status
window.$gz.form.setFormState({
vm: vm,
dirty: false,
@@ -207,7 +196,6 @@ export default {
});
}
} catch (error) {
//Update the form status
window.$gz.form.setFormState({
vm: vm,
loading: false
@@ -216,27 +204,24 @@ export default {
}
},
async submit(aType, nextNumber) {
let vm = this;
let url = `${API_BASE_URL}${aType}/${nextNumber}`;
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
window.$gz.form.deleteAllErrorBoxErrors(this);
try {
let res = await window.$gz.api.put(url);
vm.formState.loading = false;
const res = await window.$gz.api.put(
`${API_BASE_URL}${aType}/${nextNumber}`
);
this.formState.loading = false;
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
this.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(this);
} else {
window.$gz.form.setFormState({
vm: vm,
vm: this,
dirty: false
});
}
} catch (error) {
vm.formState.loading = false;
window.$gz.errorHandler.handleFormError(error, vm);
this.formState.loading = false;
window.$gz.errorHandler.handleFormError(error, this);
}
}
}
@@ -249,7 +234,7 @@ 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":
@@ -271,7 +256,7 @@ function clickHandler(menuItem) {
//
//
function generateMenu(vm) {
let menuOptions = {
const menuOptions = {
isMain: false,
readOnly: vm.formState.readOnly,
icon: null,
@@ -283,7 +268,6 @@ function generateMenu(vm) {
},
menuItems: []
};
window.$gz.eventBus.$emit("menu-change", menuOptions);
}