This commit is contained in:
2020-06-20 00:12:19 +00:00
parent 5e1efbab24
commit 534d47132d
6 changed files with 375 additions and 415 deletions

View File

@@ -111,21 +111,20 @@ const FORM_KEY = "ay-history";
const API_BASE_URL = "event-log/"; const API_BASE_URL = "event-log/";
const DEFAULT_EVENTS_PAGE_SIZE = 200; const DEFAULT_EVENTS_PAGE_SIZE = 200;
export default { export default {
created() { async created() {
let vm = this; let vm = this;
initForm(vm) try {
.then(() => { await initForm(vm);
vm.readOnly = true;
window.$gz.eventBus.$on("menu-click", clickHandler); vm.readOnly = true;
generateMenu(vm, false); window.$gz.eventBus.$on("menu-click", clickHandler);
vm.getDataFromApi(); generateMenu(vm, false);
}) vm.getDataFromApi();
.catch(err => { } catch (err) {
window.$gz.errorHandler.handleFormError(err, vm); window.$gz.errorHandler.handleFormError(err, vm);
}) } finally {
.finally(function() { vm.formState.ready = true;
vm.formState.ready = true; }
});
}, },
data() { data() {
return { return {
@@ -244,7 +243,7 @@ export default {
return "primary"; return "primary";
} }
}, },
getDataFromApi() { async getDataFromApi() {
let vm = this; let vm = this;
if (vm.formState.loading) { if (vm.formState.loading) {
return; return;
@@ -270,68 +269,60 @@ export default {
//paging //paging
url += "&Offset=" + vm.page * DEFAULT_EVENTS_PAGE_SIZE; url += "&Offset=" + vm.page * DEFAULT_EVENTS_PAGE_SIZE;
url += "&limit=" + DEFAULT_EVENTS_PAGE_SIZE; url += "&limit=" + DEFAULT_EVENTS_PAGE_SIZE;
try {
let res = await window.$gz.api.get(url);
window.$gz.api if (res.error) {
.get(url) //Not found?
.then(res => { if (res.error.code == "2010") {
if (res.error) { //notify not found error then navigate backwards
//Not found? window.$gz.eventBus.$emit("notify-error", vm.$ay.t("ErrorAPI2010"));
if (res.error.code == "2010") { // navigate backwards
//notify not found error then navigate backwards window.$gz._.delay(function() {
window.$gz.eventBus.$emit( vm.$router.go(-1);
"notify-error", }, 2000);
vm.$ay.t("ErrorAPI2010")
);
// navigate backwards
window.$gz._.delay(function() {
vm.$router.go(-1);
}, 2000);
}
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.moreAvailable =
res.data.events.length == DEFAULT_EVENTS_PAGE_SIZE;
vm.name = res.data.name;
let temp = res.data.events;
let currentEventCount = vm.obj.length;
let timeZoneName = window.$gz.locale.getBrowserTimeZoneName();
let languageName = window.$gz.locale.getBrowserLanguages();
let hour12 = window.$gz.store.state.locale.hour12;
for (let i = 0; i < temp.length; i++) {
temp[
i
].date = window.$gz.locale.utcDateToShortDateAndTimeLocalized(
temp[i].date,
timeZoneName,
languageName,
hour12
);
temp[i].index = currentEventCount + i;
}
vm.obj = [...vm.obj, ...temp];
//Update the form status
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true,
loading: false
});
//modify the menu as necessary
// generateMenu(vm);
} }
}) vm.formState.serverError = res.error;
.catch(function handleGetDataFromAPIError(error) { window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.moreAvailable = res.data.events.length == DEFAULT_EVENTS_PAGE_SIZE;
vm.name = res.data.name;
let temp = res.data.events;
let currentEventCount = vm.obj.length;
let timeZoneName = window.$gz.locale.getBrowserTimeZoneName();
let languageName = window.$gz.locale.getBrowserLanguages();
let hour12 = window.$gz.store.state.locale.hour12;
for (let i = 0; i < temp.length; i++) {
temp[i].date = window.$gz.locale.utcDateToShortDateAndTimeLocalized(
temp[i].date,
timeZoneName,
languageName,
hour12
);
temp[i].index = currentEventCount + i;
}
vm.obj = [...vm.obj, ...temp];
//Update the form status //Update the form status
window.$gz.form.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
dirty: false,
valid: true,
loading: false loading: false
}); });
window.$gz.errorHandler.handleFormError(error, vm); //modify the menu as necessary
// generateMenu(vm);
}
} catch (error) {
//Update the form status
window.$gz.form.setFormState({
vm: vm,
loading: false
}); });
window.$gz.errorHandler.handleFormError(error, vm);
}
} }
} }
}; };
@@ -388,30 +379,29 @@ function initForm(vm) {
////////////////////// //////////////////////
// //
// //
function populateAyaTypeList(vm) { async function populateAyaTypeList(vm) {
return window.$gz.enums.fetchEnumList("ayatype").then(() => { await window.$gz.enums.fetchEnumList("ayatype");
let ayt = window.$gz.enums.getSelectionList("ayatype"); let ayt = window.$gz.enums.getSelectionList("ayatype");
let temp = {}; let temp = {};
for (let i = 0; i < ayt.length; i++) { for (let i = 0; i < ayt.length; i++) {
let item = ayt[i]; let item = ayt[i];
let openableObject = false; let openableObject = false;
//CoreBizObject add here //CoreBizObject add here
switch (item.id) { switch (item.id) {
case window.$gz.type.User: case window.$gz.type.User:
case window.$gz.type.Widget: case window.$gz.type.Widget:
openableObject = true; openableObject = true;
break; break;
default: default:
openableObject = false; openableObject = false;
}
temp[item.id] = {
name: item.name,
icon: window.$gz.util.iconForType(item.id),
openableObject: openableObject
};
} }
vm.ayaTypes = temp; temp[item.id] = {
}); name: item.name,
icon: window.$gz.util.iconForType(item.id),
openableObject: openableObject
};
}
vm.ayaTypes = temp;
} }
///////////////////////////////// /////////////////////////////////

View File

@@ -10,7 +10,7 @@
<script> <script>
/* Xeslint-disable */ /* Xeslint-disable */
export default { export default {
created() { async created() {
let vm = this; let vm = this;
window.$gz.eventBus.$emit("menu-change", { window.$gz.eventBus.$emit("menu-change", {
isMain: false, isMain: false,
@@ -28,13 +28,13 @@ export default {
outText += value + "\n"; outText += value + "\n";
}); });
this.logText = outText; this.logText = outText;
window.$gz.translation try {
.fetch(["Log"]) await window.$gz.translation.fetch(["Log"]);
.then(() => (vm.formState.ready = true)) vm.formState.ready = true;
.catch(err => { } catch (err) {
vm.formState.ready = true; vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm); window.$gz.errorHandler.handleFormError(err, vm);
}); }
}, },
data() { data() {
return { return {

View File

@@ -92,52 +92,50 @@ const FORM_KEY = "home-password";
const API_BASE_URL = "auth/changepassword"; const API_BASE_URL = "auth/changepassword";
export default { export default {
created() { async created() {
let vm = this; let vm = this;
initForm(vm) try {
.then(() => { await initForm(vm);
vm.rights = window.$gz.role.fullRightsObject();
generateMenu(vm); vm.rights = window.$gz.role.fullRightsObject();
vm.formState.ready = true; generateMenu(vm);
window.$gz.form.setFormState({ vm.formState.ready = true;
vm: vm, window.$gz.form.setFormState({
dirty: false, vm: vm,
valid: true, dirty: false,
loading: false, valid: true,
readOnly: false loading: false,
}); readOnly: false
window.$gz.eventBus.$on("menu-click", clickHandler);
//-------------
//Set known password warning if applicable
//note: all code assumes only one known user the superuser
//if this changes then auth.js as well as store and here will need to be changed as well
if (
window.$gz.store.state.knownPassword &&
(window.$gz.store.state.globalSettings.licenseStatus == 3 || //ActivePurchased = 3,
window.$gz.store.state.globalSettings.licenseStatus == 4) // ExpiredPurchased = 4
) {
this.formState.errorBoxMessage = vm.$ay.t("KnownPasswordWarning");
this.obj.loginName = "superuser";
this.obj.oldPassword = "l3tm3in";
}
//------------------
})
.catch(err => {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
}); });
window.$gz.eventBus.$on("menu-click", clickHandler);
//-------------
//Set known password warning if applicable
//note: all code assumes only one known user the superuser
//if this changes then auth.js as well as store and here will need to be changed as well
if (
window.$gz.store.state.knownPassword &&
(window.$gz.store.state.globalSettings.licenseStatus == 3 || //ActivePurchased = 3,
window.$gz.store.state.globalSettings.licenseStatus == 4) // ExpiredPurchased = 4
) {
this.formState.errorBoxMessage = vm.$ay.t("KnownPasswordWarning");
this.obj.loginName = "superuser";
this.obj.oldPassword = "l3tm3in";
}
//------------------
} catch (err) {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
}
}, },
beforeRouteLeave(to, from, next) { async beforeRouteLeave(to, from, next) {
if (this.formState.dirty) { if (!this.formState.dirty) {
window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => {
if (dialogResult == true) {
next();
} else {
next(false);
}
});
} else {
next(); next();
return;
}
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
next();
} else {
next(false);
} }
}, },
beforeDestroy() { beforeDestroy() {
@@ -203,8 +201,7 @@ export default {
window.$gz.form.fieldValueChanged(this, ref); window.$gz.form.fieldValueChanged(this, ref);
} }
}, },
async submit() {
submit() {
let vm = this; let vm = this;
if (vm.canSave) { if (vm.canSave) {
vm.formState.loading = true; vm.formState.loading = true;
@@ -214,26 +211,24 @@ export default {
//clear any errors vm might be around from previous submit //clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm); window.$gz.form.deleteAllErrorBoxErrors(vm);
window.$gz.api try {
.upsert(url, vm.obj) let res = await window.$gz.api.upsert(url, vm.obj);
.then(res => {
if (res.error) { if (res.error) {
vm.formState.serverError = res.error; vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm); window.$gz.form.setErrorBoxErrors(vm);
} else { } else {
//Only a post, no data returned //Only a post, no data returned
window.$gz.form.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
dirty: false dirty: false
}); });
} }
}) } catch (error) {
.catch(function handleSubmitError(error) { window.$gz.errorHandler.handleFormError(error, vm);
window.$gz.errorHandler.handleFormError(error, vm); } finally {
}) vm.loading = false;
.finally(function() { }
vm.loading = false;
});
} }
} }
} }

View File

@@ -107,39 +107,39 @@ export default {
next(); next();
}, },
created() { async created() {
let vm = this; let vm = this;
initForm(vm) try {
.then(() => { await initForm(vm);
vm.formState.ready = true;
window.$gz.eventBus.$on("menu-click", clickHandler);
generateMenu(vm);
if (vm.$route.params.ayatype) { vm.formState.ready = true;
vm.searchObjectType = vm.$route.params.ayatype; window.$gz.eventBus.$on("menu-click", clickHandler);
generateMenu(vm);
if (vm.$route.params.ayatype) {
vm.searchObjectType = vm.$route.params.ayatype;
}
//get form settings from session cache, if same type as in route then re-use teh last search stuff
//however if different than need to clear it (or not rehydrate it)
let savedSettings = window.$gz.form.getFormSettings(FORM_KEY);
if (savedSettings && savedSettings.temp) {
savedSettings = savedSettings.temp;
if (
vm.searchObjectType == null ||
vm.searchObjectType == savedSettings.ayaType
) {
//same type or no type so go ahead and rehydrate
vm.searchPhrase = savedSettings.phrase;
vm.searchObjectType = savedSettings.ayaType;
vm.items = savedSettings.items;
} }
}
//get form settings from session cache, if same type as in route then re-use teh last search stuff } catch (err) {
//however if different than need to clear it (or not rehydrate it) vm.formState.ready = true;
let savedSettings = window.$gz.form.getFormSettings(FORM_KEY); window.$gz.errorHandler.handleFormError(err, vm);
}
if (savedSettings && savedSettings.temp) {
savedSettings = savedSettings.temp;
if (
vm.searchObjectType == null ||
vm.searchObjectType == savedSettings.ayaType
) {
//same type or no type so go ahead and rehydrate
vm.searchPhrase = savedSettings.phrase;
vm.searchObjectType = savedSettings.ayaType;
vm.items = savedSettings.items;
}
}
})
.catch(err => {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
});
}, },
beforeDestroy() { beforeDestroy() {
window.$gz.eventBus.$off("menu-click", clickHandler); window.$gz.eventBus.$off("menu-click", clickHandler);
@@ -176,7 +176,7 @@ export default {
id: item.id id: item.id
}); });
}, },
getExcerpt(item) { async getExcerpt(item) {
let vm = this; let vm = this;
//Search/Info/2/1?phrase=we //Search/Info/2/1?phrase=we
if (item.info || item.id == 0) { if (item.info || item.id == 0) {
@@ -203,9 +203,8 @@ export default {
default: default:
max = 40; max = 40;
} }
try {
window.$gz.api let res = await window.$gz.api.get(
.get(
API_BASE_URL + API_BASE_URL +
"Info/" + "Info/" +
item.type + item.type +
@@ -215,37 +214,35 @@ export default {
vm.searchPhrase + vm.searchPhrase +
"&max=" + "&max=" +
max max
) );
.then(res => {
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
let showInfo = res.data;
let searchTerms = vm.searchPhrase
.toLocaleLowerCase()
.replace(/[*]/gi, "")
.split(" ");
for (let i = 0; i < searchTerms.length; i++) {
showInfo = showInfo.replace(
searchTerms[i],
"<span class='v-list-item__mask'>" + searchTerms[i] + "</span>"
);
}
item.info = showInfo; if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
let showInfo = res.data;
let searchTerms = vm.searchPhrase
.toLocaleLowerCase()
.replace(/[*]/gi, "")
.split(" ");
for (let i = 0; i < searchTerms.length; i++) {
showInfo = showInfo.replace(
searchTerms[i],
"<span class='v-list-item__mask'>" + searchTerms[i] + "</span>"
);
} }
})
.catch(function handleGetDataFromAPIError(error) { item.info = showInfo;
window.$gz.errorHandler.handleFormError(error, vm); }
}); } catch (error) {
window.$gz.errorHandler.handleFormError(error, vm);
}
}, },
getDataFromApi() { async getDataFromApi() {
let vm = this; let vm = this;
if (!vm.searchPhrase || vm.formState.loading) { if (!vm.searchPhrase || vm.formState.loading) {
return; return;
} }
vm.formState.loading = true; vm.formState.loading = true;
window.$gz.form.deleteAllErrorBoxErrors(vm); window.$gz.form.deleteAllErrorBoxErrors(vm);
/** /**
@@ -257,61 +254,52 @@ export default {
} }
* *
*/ */
try {
window.$gz.api let res = await window.$gz.api.upsert(API_BASE_URL, {
.upsert(API_BASE_URL, {
phrase: vm.searchPhrase, phrase: vm.searchPhrase,
nameOnly: false, nameOnly: false,
typeOnly: !!vm.searchObjectType ? vm.searchObjectType : 0, typeOnly: !!vm.searchObjectType ? vm.searchObjectType : 0,
maxResults: MAX_RESULTS maxResults: MAX_RESULTS
})
.then(res => {
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.maxResultsReturned =
res.data.searchResults.length == MAX_RESULTS;
let newResults = [];
let nDex = 0;
let lastType = -1;
for (let i = 0; i < res.data.searchResults.length; i++) {
let item = res.data.searchResults[i];
if (item.type != lastType) {
//change of type, set subheader props
let tsub = window.$gz._.find(vm.selectLists.objectTypes, [
"id",
item.type
]);
if (tsub != null) {
item.subheader = tsub.name;
} else {
item.subheader = "TYPE " + item.type;
}
item.icon = window.$gz.util.iconForType(item.type);
lastType = item.type;
}
item.info = null;
item.index = ++nDex;
newResults.push(item);
}
vm.items = newResults;
}
})
.catch(function handleGetDataFromAPIError(error) {
window.$gz.errorHandler.handleFormError(error, vm);
})
.finally(function() {
//Update the form status
window.$gz.form.setFormState({
vm: vm,
loading: false
});
}); });
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.maxResultsReturned = res.data.searchResults.length == MAX_RESULTS;
let newResults = [];
let nDex = 0;
let lastType = -1;
for (let i = 0; i < res.data.searchResults.length; i++) {
let item = res.data.searchResults[i];
if (item.type != lastType) {
//change of type, set subheader props
let tsub = window.$gz._.find(vm.selectLists.objectTypes, [
"id",
item.type
]);
if (tsub != null) {
item.subheader = tsub.name;
} else {
item.subheader = "TYPE " + item.type;
}
item.icon = window.$gz.util.iconForType(item.type);
lastType = item.type;
}
item.info = null;
item.index = ++nDex;
newResults.push(item);
}
vm.items = newResults;
}
} catch (error) {
window.$gz.errorHandler.handleFormError(error, vm);
} finally {
//Update the form status
window.$gz.form.setFormState({
vm: vm,
loading: false
});
}
} }
} }
}; };
@@ -386,14 +374,13 @@ async function fetchTranslatedText(vm) {
////////////////////// //////////////////////
// //
// //
function populateSelectionLists(vm) { async function populateSelectionLists(vm) {
return window.$gz.api.get("enum-list/list/Core").then(res => { let res = await window.$gz.api.get("enum-list/list/Core");
if (res.error) { if (res.error) {
window.$gz.errorHandler.handleFormError(res.error, vm); window.$gz.errorHandler.handleFormError(res.error, vm);
} else { } else {
vm.selectLists.objectTypes = res.data; vm.selectLists.objectTypes = res.data;
window.$gz.form.addNoSelectionItem(vm.selectLists.objectTypes); window.$gz.form.addNoSelectionItem(vm.selectLists.objectTypes);
} }
});
} }
</script> </script>

View File

@@ -121,38 +121,36 @@ const API_BASE_URL = "user-option/";
const FORM_CUSTOM_TEMPLATE_KEY = "Useroptions"; const FORM_CUSTOM_TEMPLATE_KEY = "Useroptions";
export default { export default {
created() { async created() {
let vm = this; let vm = this;
initForm(vm) try {
.then(() => { await initForm(vm);
vm.rights = window.$gz.role.getRights(window.$gz.type.UserOptions);
vm.formState.ready = true;
window.$gz.eventBus.$on("menu-click", clickHandler);
//UserOptions never creates a new one so this code is a little different than other forms
//NOTE: FOR NOW GOING TO ASSUME THIS FORM WILL ONLY EVER BE USED TO EDIT *CURRENT* USER'S USEROPTIONS
//SO NOT FOR EDITING OTHER USERS, WILL ASSUME THE USER EDITOR FORM FOR MANAGEMENT WILL HAVE A COMPACT VERSION
//OF THESE SAME FIELDS FOR THAT PURPOSE
//SO ALWAYS USER CURRENT LOGGED IN USER ID FOR THIS
//id 0 means create a new record don't load one but thats not applicable here
vm.getDataFromApi(); vm.rights = window.$gz.role.getRights(window.$gz.type.UserOptions);
}) vm.formState.ready = true;
.catch(err => { window.$gz.eventBus.$on("menu-click", clickHandler);
vm.formState.ready = true; //UserOptions never creates a new one so this code is a little different than other forms
window.$gz.errorHandler.handleFormError(err, vm); //NOTE: FOR NOW GOING TO ASSUME THIS FORM WILL ONLY EVER BE USED TO EDIT *CURRENT* USER'S USEROPTIONS
}); //SO NOT FOR EDITING OTHER USERS, WILL ASSUME THE USER EDITOR FORM FOR MANAGEMENT WILL HAVE A COMPACT VERSION
//OF THESE SAME FIELDS FOR THAT PURPOSE
//SO ALWAYS USER CURRENT LOGGED IN USER ID FOR THIS
//id 0 means create a new record don't load one but thats not applicable here
vm.getDataFromApi();
} catch (err) {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
}
}, },
beforeRouteLeave(to, from, next) { async beforeRouteLeave(to, from, next) {
if (this.formState.dirty) { if (!this.formState.dirty) {
window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => {
if (dialogResult == true) {
next();
} else {
next(false);
}
});
} else {
next(); next();
return;
}
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
next();
} else {
next(false);
} }
}, },
beforeDestroy() { beforeDestroy() {
@@ -243,56 +241,50 @@ export default {
window.$gz.form.fieldValueChanged(this, ref); window.$gz.form.fieldValueChanged(this, ref);
} }
}, },
getDataFromApi() { async getDataFromApi() {
let vm = this; let vm = this;
vm.formState.loading = true; vm.formState.loading = true;
//always fetch on this form for the current logged in user id //always fetch on this form for the current logged in user id
let url = API_BASE_URL + vm.$store.state.userId; let url = API_BASE_URL + vm.$store.state.userId;
window.$gz.form.deleteAllErrorBoxErrors(vm); window.$gz.form.deleteAllErrorBoxErrors(vm);
try {
let res = await window.$gz.api.get(url);
window.$gz.api if (res.error) {
.get(url) //Not found?
.then(res => { if (res.error.code == "2010") {
if (res.error) { //notify not found error then navigate backwards
//Not found? window.$gz.eventBus.$emit("notify-error", vm.$ay.t("ErrorAPI2010"));
if (res.error.code == "2010") { // navigate backwards
//notify not found error then navigate backwards window.$gz._.delay(function() {
window.$gz.eventBus.$emit( vm.$router.go(-1);
"notify-error", }, 2000);
vm.$ay.t("ErrorAPI2010")
);
// navigate backwards
window.$gz._.delay(function() {
vm.$router.go(-1);
}, 2000);
}
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);
} }
}) vm.formState.serverError = res.error;
.catch(function handleGetDataFromAPIError(error) { window.$gz.form.setErrorBoxErrors(vm);
} else {
vm.obj = res.data;
//Update the form status //Update the form status
window.$gz.form.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
dirty: false,
valid: true,
loading: false loading: false
}); });
window.$gz.errorHandler.handleFormError(error, vm); //modify the menu as necessary
generateMenu(vm);
}
} catch (error) {
//Update the form status
window.$gz.form.setFormState({
vm: vm,
loading: false
}); });
window.$gz.errorHandler.handleFormError(error, vm);
}
}, },
submit() { async submit() {
let vm = this; let vm = this;
if (vm.canSave) { if (vm.canSave) {
vm.formState.loading = true; vm.formState.loading = true;
@@ -302,49 +294,48 @@ export default {
//clear any errors vm might be around from previous submit //clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm); window.$gz.form.deleteAllErrorBoxErrors(vm);
window.$gz.api try {
.upsert(url, vm.obj) let res = await window.$gz.api.upsert(url, vm.obj);
.then(res => {
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.formState.loading = false;
vm.obj.concurrency = res.data.concurrency; if (res.error) {
window.$gz.form.setFormState({ vm.formState.serverError = res.error;
vm: vm, window.$gz.form.setErrorBoxErrors(vm);
dirty: false } else {
}); //UserOptions is never a POST as it always exists and can't be deleted so always a PUT
//Set values in store so they are updated immediately for user //Handle "put" of an existing record (UPDATE)
let l = vm.$store.state.locale; vm.obj.concurrency = res.data.concurrency;
window.$gz.form.setFormState({
vm: vm,
dirty: false
});
if (vm.obj.languageOverride) { //Set values in store so they are updated immediately for user
l.languageOverride = vm.obj.languageOverride; let l = vm.$store.state.locale;
}
if (vm.obj.timeZoneOverride) { if (vm.obj.languageOverride) {
l.timeZoneOverride = vm.obj.timeZoneOverride; l.languageOverride = vm.obj.languageOverride;
}
if (vm.obj.currencyName) {
l.currencyName = vm.obj.currencyName;
}
if (vm.obj.hour12) {
l.hour12 = vm.obj.hour12;
}
window.$gz.store.commit("setLocale", l);
} }
})
.catch(function handleSubmitError(error) { if (vm.obj.timeZoneOverride) {
vm.formState.loading = false; l.timeZoneOverride = vm.obj.timeZoneOverride;
window.$gz.errorHandler.handleFormError(error, vm); }
});
if (vm.obj.currencyName) {
l.currencyName = vm.obj.currencyName;
}
if (vm.obj.hour12) {
l.hour12 = vm.obj.hour12;
}
window.$gz.store.commit("setLocale", l);
}
} catch (error) {
vm.formState.loading = false;
window.$gz.errorHandler.handleFormError(error, vm);
}
} }
} }
} }
@@ -446,15 +437,14 @@ async function fetchTranslatedText(vm) {
////////////////////// //////////////////////
// //
// //
function populateSelectionLists(vm) { async function populateSelectionLists(vm) {
//http://localhost:7575/api/v8/translation/list //http://localhost:7575/api/v8/translation/list
return window.$gz.api.get("translation/list").then(res => { let res = await window.$gz.api.get("translation/list");
if (res.error) { if (res.error) {
window.$gz.errorHandler.handleFormError(res.error, vm); window.$gz.errorHandler.handleFormError(res.error, vm);
} else { } else {
vm.selectLists.translations = res.data; vm.selectLists.translations = res.data;
} }
});
} }
</script> </script>

View File

@@ -98,33 +98,31 @@
const FORM_KEY = "ops-backup"; const FORM_KEY = "ops-backup";
export default { export default {
created() { async created() {
let vm = this; let vm = this;
initForm(vm) try {
.then(() => { await initForm(vm);
vm.rights = window.$gz.role.getRights(window.$gz.type.GlobalOps);
vm.formState.readOnly = !vm.rights.change; vm.rights = window.$gz.role.getRights(window.$gz.type.GlobalOps);
vm.formState.ready = true; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); vm.formState.ready = true;
vm.getDataFromApi(); window.$gz.eventBus.$on("menu-click", clickHandler);
vm.getBackupStatus(); vm.getDataFromApi();
}) vm.getBackupStatus();
.catch(err => { } catch (err) {
vm.formState.ready = true; vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm); window.$gz.errorHandler.handleFormError(err, vm);
}); }
}, },
beforeRouteLeave(to, from, next) { async beforeRouteLeave(to, from, next) {
if (this.formState.dirty) { if (!this.formState.dirty) {
window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => {
if (dialogResult == true) {
next();
} else {
next(false);
}
});
} else {
next(); next();
return;
}
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
next();
} else {
next(false);
} }
}, },
beforeDestroy() { beforeDestroy() {