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 DEFAULT_EVENTS_PAGE_SIZE = 200;
export default {
created() {
async created() {
let vm = this;
initForm(vm)
.then(() => {
vm.readOnly = true;
window.$gz.eventBus.$on("menu-click", clickHandler);
generateMenu(vm, false);
vm.getDataFromApi();
})
.catch(err => {
window.$gz.errorHandler.handleFormError(err, vm);
})
.finally(function() {
vm.formState.ready = true;
});
try {
await initForm(vm);
vm.readOnly = true;
window.$gz.eventBus.$on("menu-click", clickHandler);
generateMenu(vm, false);
vm.getDataFromApi();
} catch (err) {
window.$gz.errorHandler.handleFormError(err, vm);
} finally {
vm.formState.ready = true;
}
},
data() {
return {
@@ -244,7 +243,7 @@ export default {
return "primary";
}
},
getDataFromApi() {
async getDataFromApi() {
let vm = this;
if (vm.formState.loading) {
return;
@@ -270,68 +269,60 @@ export default {
//paging
url += "&Offset=" + vm.page * DEFAULT_EVENTS_PAGE_SIZE;
url += "&limit=" + DEFAULT_EVENTS_PAGE_SIZE;
try {
let res = await window.$gz.api.get(url);
window.$gz.api
.get(url)
.then(res => {
if (res.error) {
//Not found?
if (res.error.code == "2010") {
//notify not found error then navigate backwards
window.$gz.eventBus.$emit(
"notify-error",
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);
if (res.error) {
//Not found?
if (res.error.code == "2010") {
//notify not found error then navigate backwards
window.$gz.eventBus.$emit("notify-error", vm.$ay.t("ErrorAPI2010"));
// navigate backwards
window.$gz._.delay(function() {
vm.$router.go(-1);
}, 2000);
}
})
.catch(function handleGetDataFromAPIError(error) {
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
});
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) {
return window.$gz.enums.fetchEnumList("ayatype").then(() => {
let ayt = window.$gz.enums.getSelectionList("ayatype");
let temp = {};
for (let i = 0; i < ayt.length; i++) {
let item = ayt[i];
let openableObject = false;
//CoreBizObject add here
switch (item.id) {
case window.$gz.type.User:
case window.$gz.type.Widget:
openableObject = true;
break;
default:
openableObject = false;
}
temp[item.id] = {
name: item.name,
icon: window.$gz.util.iconForType(item.id),
openableObject: openableObject
};
async function populateAyaTypeList(vm) {
await window.$gz.enums.fetchEnumList("ayatype");
let ayt = window.$gz.enums.getSelectionList("ayatype");
let temp = {};
for (let i = 0; i < ayt.length; i++) {
let item = ayt[i];
let openableObject = false;
//CoreBizObject add here
switch (item.id) {
case window.$gz.type.User:
case window.$gz.type.Widget:
openableObject = true;
break;
default:
openableObject = false;
}
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>
/* Xeslint-disable */
export default {
created() {
async created() {
let vm = this;
window.$gz.eventBus.$emit("menu-change", {
isMain: false,
@@ -28,13 +28,13 @@ export default {
outText += value + "\n";
});
this.logText = outText;
window.$gz.translation
.fetch(["Log"])
.then(() => (vm.formState.ready = true))
.catch(err => {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
});
try {
await window.$gz.translation.fetch(["Log"]);
vm.formState.ready = true;
} catch (err) {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
}
},
data() {
return {

View File

@@ -92,52 +92,50 @@ const FORM_KEY = "home-password";
const API_BASE_URL = "auth/changepassword";
export default {
created() {
async created() {
let vm = this;
initForm(vm)
.then(() => {
vm.rights = window.$gz.role.fullRightsObject();
generateMenu(vm);
vm.formState.ready = true;
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true,
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);
try {
await initForm(vm);
vm.rights = window.$gz.role.fullRightsObject();
generateMenu(vm);
vm.formState.ready = true;
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true,
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);
}
},
beforeRouteLeave(to, from, next) {
if (this.formState.dirty) {
window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => {
if (dialogResult == true) {
next();
} else {
next(false);
}
});
} else {
async beforeRouteLeave(to, from, next) {
if (!this.formState.dirty) {
next();
return;
}
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
next();
} else {
next(false);
}
},
beforeDestroy() {
@@ -203,8 +201,7 @@ export default {
window.$gz.form.fieldValueChanged(this, ref);
}
},
submit() {
async submit() {
let vm = this;
if (vm.canSave) {
vm.formState.loading = true;
@@ -214,26 +211,24 @@ export default {
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
window.$gz.api
.upsert(url, vm.obj)
.then(res => {
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//Only a post, no data returned
window.$gz.form.setFormState({
vm: vm,
dirty: false
});
}
})
.catch(function handleSubmitError(error) {
window.$gz.errorHandler.handleFormError(error, vm);
})
.finally(function() {
vm.loading = false;
});
try {
let res = await window.$gz.api.upsert(url, vm.obj);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//Only a post, no data returned
window.$gz.form.setFormState({
vm: vm,
dirty: false
});
}
} catch (error) {
window.$gz.errorHandler.handleFormError(error, vm);
} finally {
vm.loading = false;
}
}
}
}

View File

@@ -107,39 +107,39 @@ export default {
next();
},
created() {
async created() {
let vm = this;
initForm(vm)
.then(() => {
vm.formState.ready = true;
window.$gz.eventBus.$on("menu-click", clickHandler);
generateMenu(vm);
try {
await initForm(vm);
if (vm.$route.params.ayatype) {
vm.searchObjectType = vm.$route.params.ayatype;
vm.formState.ready = true;
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
//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;
}
}
})
.catch(err => {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
});
}
} catch (err) {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
}
},
beforeDestroy() {
window.$gz.eventBus.$off("menu-click", clickHandler);
@@ -176,7 +176,7 @@ export default {
id: item.id
});
},
getExcerpt(item) {
async getExcerpt(item) {
let vm = this;
//Search/Info/2/1?phrase=we
if (item.info || item.id == 0) {
@@ -203,9 +203,8 @@ export default {
default:
max = 40;
}
window.$gz.api
.get(
try {
let res = await window.$gz.api.get(
API_BASE_URL +
"Info/" +
item.type +
@@ -215,37 +214,35 @@ export default {
vm.searchPhrase +
"&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) {
window.$gz.errorHandler.handleFormError(error, vm);
});
item.info = showInfo;
}
} catch (error) {
window.$gz.errorHandler.handleFormError(error, vm);
}
},
getDataFromApi() {
async getDataFromApi() {
let vm = this;
if (!vm.searchPhrase || vm.formState.loading) {
return;
}
vm.formState.loading = true;
window.$gz.form.deleteAllErrorBoxErrors(vm);
/**
@@ -257,61 +254,52 @@ export default {
}
*
*/
window.$gz.api
.upsert(API_BASE_URL, {
try {
let res = await window.$gz.api.upsert(API_BASE_URL, {
phrase: vm.searchPhrase,
nameOnly: false,
typeOnly: !!vm.searchObjectType ? vm.searchObjectType : 0,
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) {
return window.$gz.api.get("enum-list/list/Core").then(res => {
if (res.error) {
window.$gz.errorHandler.handleFormError(res.error, vm);
} else {
vm.selectLists.objectTypes = res.data;
window.$gz.form.addNoSelectionItem(vm.selectLists.objectTypes);
}
});
async function populateSelectionLists(vm) {
let res = await window.$gz.api.get("enum-list/list/Core");
if (res.error) {
window.$gz.errorHandler.handleFormError(res.error, vm);
} else {
vm.selectLists.objectTypes = res.data;
window.$gz.form.addNoSelectionItem(vm.selectLists.objectTypes);
}
}
</script>

View File

@@ -121,38 +121,36 @@ const API_BASE_URL = "user-option/";
const FORM_CUSTOM_TEMPLATE_KEY = "Useroptions";
export default {
created() {
async created() {
let vm = this;
initForm(vm)
.then(() => {
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
try {
await initForm(vm);
vm.getDataFromApi();
})
.catch(err => {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, 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();
} catch (err) {
vm.formState.ready = true;
window.$gz.errorHandler.handleFormError(err, vm);
}
},
beforeRouteLeave(to, from, next) {
if (this.formState.dirty) {
window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => {
if (dialogResult == true) {
next();
} else {
next(false);
}
});
} else {
async beforeRouteLeave(to, from, next) {
if (!this.formState.dirty) {
next();
return;
}
if ((await window.$gz.dialog.confirmLeaveUnsaved()) === true) {
next();
} else {
next(false);
}
},
beforeDestroy() {
@@ -243,56 +241,50 @@ export default {
window.$gz.form.fieldValueChanged(this, ref);
}
},
getDataFromApi() {
async getDataFromApi() {
let vm = this;
vm.formState.loading = true;
//always fetch on this form for the current logged in user id
let url = API_BASE_URL + vm.$store.state.userId;
window.$gz.form.deleteAllErrorBoxErrors(vm);
try {
let res = await window.$gz.api.get(url);
window.$gz.api
.get(url)
.then(res => {
if (res.error) {
//Not found?
if (res.error.code == "2010") {
//notify not found error then navigate backwards
window.$gz.eventBus.$emit(
"notify-error",
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);
if (res.error) {
//Not found?
if (res.error.code == "2010") {
//notify not found error then navigate backwards
window.$gz.eventBus.$emit("notify-error", vm.$ay.t("ErrorAPI2010"));
// navigate backwards
window.$gz._.delay(function() {
vm.$router.go(-1);
}, 2000);
}
})
.catch(function handleGetDataFromAPIError(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
});
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;
if (vm.canSave) {
vm.formState.loading = true;
@@ -302,49 +294,48 @@ export default {
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
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
try {
let res = await window.$gz.api.upsert(url, vm.obj);
//Handle "put" of an existing record (UPDATE)
vm.obj.concurrency = res.data.concurrency;
window.$gz.form.setFormState({
vm: vm,
dirty: false
});
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
//Set values in store so they are updated immediately for user
let l = vm.$store.state.locale;
//Handle "put" of an existing record (UPDATE)
vm.obj.concurrency = res.data.concurrency;
window.$gz.form.setFormState({
vm: vm,
dirty: false
});
if (vm.obj.languageOverride) {
l.languageOverride = vm.obj.languageOverride;
}
//Set values in store so they are updated immediately for user
let l = vm.$store.state.locale;
if (vm.obj.timeZoneOverride) {
l.timeZoneOverride = vm.obj.timeZoneOverride;
}
if (vm.obj.currencyName) {
l.currencyName = vm.obj.currencyName;
}
if (vm.obj.hour12) {
l.hour12 = vm.obj.hour12;
}
window.$gz.store.commit("setLocale", l);
if (vm.obj.languageOverride) {
l.languageOverride = vm.obj.languageOverride;
}
})
.catch(function handleSubmitError(error) {
vm.formState.loading = false;
window.$gz.errorHandler.handleFormError(error, vm);
});
if (vm.obj.timeZoneOverride) {
l.timeZoneOverride = vm.obj.timeZoneOverride;
}
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
return window.$gz.api.get("translation/list").then(res => {
if (res.error) {
window.$gz.errorHandler.handleFormError(res.error, vm);
} else {
vm.selectLists.translations = res.data;
}
});
let res = await window.$gz.api.get("translation/list");
if (res.error) {
window.$gz.errorHandler.handleFormError(res.error, vm);
} else {
vm.selectLists.translations = res.data;
}
}
</script>

View File

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