This commit is contained in:
@@ -265,38 +265,37 @@ const API_BASE_URL = "widget/";
|
||||
const FORM_CUSTOM_TEMPLATE_KEY = "Widget";
|
||||
|
||||
export default {
|
||||
created() {
|
||||
async created() {
|
||||
let vm = this;
|
||||
initForm(vm)
|
||||
.then(() => {
|
||||
vm.rights = window.$gz.role.getRights(window.$gz.type.Widget);
|
||||
vm.formState.readOnly = !vm.rights.change;
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
//id 0 means create a new record don't load one
|
||||
if (vm.$route.params.recordid != 0) {
|
||||
vm.getDataFromApi(vm.$route.params.recordid);
|
||||
} else {
|
||||
//setup for new record
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
loading: false
|
||||
});
|
||||
try {
|
||||
await initForm(vm);
|
||||
|
||||
// //bugbug WTF? This doesn't make sense, if it's an attempt to hide delete button then that's wrong
|
||||
// //it's a new record so it can't be deleted so...
|
||||
// vm.rights.delete = false;
|
||||
generateMenu(vm);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
window.$gz.errorHandler.handleFormError(err, vm);
|
||||
})
|
||||
.finally(function() {
|
||||
vm.formState.ready = true;
|
||||
});
|
||||
vm.rights = window.$gz.role.getRights(window.$gz.type.Widget);
|
||||
vm.formState.readOnly = !vm.rights.change;
|
||||
window.$gz.eventBus.$on("menu-click", clickHandler);
|
||||
//id 0 means create a new record don't load one
|
||||
if (vm.$route.params.recordid != 0) {
|
||||
vm.getDataFromApi(vm.$route.params.recordid);
|
||||
} else {
|
||||
//setup for new record
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
loading: false
|
||||
});
|
||||
|
||||
// //bugbug WTF? This doesn't make sense, if it's an attempt to hide delete button then that's wrong
|
||||
// //it's a new record so it can't be deleted so...
|
||||
// vm.rights.delete = false;
|
||||
generateMenu(vm);
|
||||
}
|
||||
} catch (error) {
|
||||
window.$gz.errorHandler.handleFormError(error, vm);
|
||||
} finally {
|
||||
vm.formState.ready = true;
|
||||
}
|
||||
},
|
||||
beforeRouteUpdate(to, from, next) {
|
||||
//This triggers a fetch of the data when the ID value changes on the route
|
||||
@@ -308,18 +307,15 @@ export default {
|
||||
// react to route changes...
|
||||
// don't forget to call next()
|
||||
},
|
||||
beforeRouteLeave(to, from, next) {
|
||||
//let vm = this;
|
||||
if (this.formState.dirty && !JUST_DELETED) {
|
||||
window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => {
|
||||
if (dialogResult == true) {
|
||||
next();
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
async beforeRouteLeave(to, from, next) {
|
||||
if (!this.formState.dirty || JUST_DELETED) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
if ((await window.$gz.dialog.confirmLeaveUnsaved()) == true) {
|
||||
next();
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
},
|
||||
beforeDestroy() {
|
||||
@@ -776,11 +772,10 @@ function fetchTranslatedText(vm) {
|
||||
//////////////////////
|
||||
//
|
||||
//
|
||||
function populateSelectionLists(vm) {
|
||||
async function populateSelectionLists(vm) {
|
||||
//ensure the pick lists required are pre-fetched
|
||||
return window.$gz.enums.fetchEnumList("usertype").then(() => {
|
||||
vm.selectLists.usertypes = window.$gz.enums.getSelectionList("usertype");
|
||||
});
|
||||
await window.$gz.enums.fetchEnumList("usertype");
|
||||
vm.selectLists.usertypes = window.$gz.enums.getSelectionList("usertype");
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user