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

@@ -4,7 +4,6 @@
<v-form ref="form">
<v-row>
<gz-error :error-box-message="formState.errorBoxMessage"></gz-error>
<v-col cols="12" sm="6" lg="4" xl="3">
<v-radio-group
v-model="obj.serverState"
@@ -44,22 +43,15 @@
</v-col>
</v-row>
</template>
<script>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Xeslint-disable */
////////////////////////////////////////////////////////////////////////////////////////////////////////////
const FORM_KEY = "ops-server-state";
const API_BASE_URL = "server-state/";
const FORM_CUSTOM_TEMPLATE_KEY = "ServerState"; //<-- Should always be CoreBizObject AyaType name here where possible
const FORM_CUSTOM_TEMPLATE_KEY = "ServerState";
export default {
async created() {
let vm = this;
const vm = this;
try {
await initForm(vm);
vm.rights = window.$gz.role.getRights(window.$gz.type.ServerState);
vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler);
@@ -93,17 +85,13 @@ export default {
rights: window.$gz.role.defaultRightsObject()
};
},
//WATCHERS
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 {
@@ -128,32 +116,26 @@ export default {
}
},
async getDataFromApi() {
let vm = this;
const vm = this;
vm.formState.loading = true;
let url = API_BASE_URL;
window.$gz.form.deleteAllErrorBoxErrors(vm);
try {
let res = await window.$gz.api.get(url);
const res = await window.$gz.api.get(API_BASE_URL);
vm.formState.ready = true;
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.obj = res.data;
//Update the form status
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true,
loading: false
});
//modify the menu as necessary
generateMenu(vm);
}
} catch (error) {
//Update the form status
window.$gz.form.setFormState({
vm: vm,
loading: false
@@ -162,24 +144,17 @@ export default {
}
},
async submit() {
let vm = this;
const vm = this;
if (vm.canSave) {
vm.formState.loading = true;
let url = API_BASE_URL;
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
try {
let res = await window.$gz.api.upsert(url, vm.obj);
const res = await window.$gz.api.upsert(API_BASE_URL, vm.obj);
vm.formState.loading = false;
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//UserOptions is never a POST as it always exists and can't be deleted so always a PUT
//Handle "put" of an existing record (UPDATE)
vm.obj.concurrency = res.data.concurrency;
window.$gz.form.setFormState({
vm: vm,
@@ -193,12 +168,11 @@ export default {
}
},
async shutdown() {
let vm = this;
const vm = this;
vm.formState.loading = true;
let url = "server-state/shutdown";
window.$gz.form.deleteAllErrorBoxErrors(vm);
try {
let res = await window.$gz.api.upsert(url, {});
const res = await window.$gz.api.upsert("server-state/shutdown", {});
vm.formState.loading = false;
if (res.error) {
vm.formState.serverError = res.error;
@@ -221,7 +195,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":
@@ -250,7 +224,7 @@ async function clickHandler(menuItem) {
//
//
function generateMenu(vm) {
let menuOptions = {
const menuOptions = {
isMain: true,
readOnly: vm.formState.readOnly,
icon: "$ayiDoorOpen",
@@ -259,9 +233,6 @@ function generateMenu(vm) {
formData: {
ayaType: window.$gz.type.ServerState
},
formData: {
// ayaType: window.$gz.type.UserOptions
},
menuItems: []
};
@@ -290,14 +261,14 @@ function generateMenu(vm) {
//
//
async function initForm(vm) {
await fetchTranslatedText(vm);
await fetchTranslatedText();
}
//////////////////////////////////////////////////////////
//
// Ensures UI translated text is available
//
async function fetchTranslatedText(vm) {
async function fetchTranslatedText() {
await window.$gz.translation.cacheTranslations([
"ServerStateOpen",
"ServerStateOps",