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