This commit is contained in:
@@ -191,7 +191,7 @@ function clickHandler(menuItem) {
|
||||
//////////////////////
|
||||
//
|
||||
//
|
||||
function generateMenu(vm, readOnly) {
|
||||
function generateMenu(vm) {
|
||||
var menuOptions = {
|
||||
isMain: false,
|
||||
icon: "fa-splotch",
|
||||
@@ -200,32 +200,34 @@ function generateMenu(vm, readOnly) {
|
||||
menuItems: []
|
||||
};
|
||||
|
||||
if (readOnly != true) {
|
||||
//TODO: Handle new record here
|
||||
menuOptions.menuItems = [
|
||||
{
|
||||
title: vm.$gzlocale.get("Save"),
|
||||
icon: "save",
|
||||
surface: true,
|
||||
key: "inventory-widget-edit:save",
|
||||
vm: vm
|
||||
},
|
||||
{
|
||||
title: vm.$gzlocale.get("Delete"),
|
||||
icon: "trash-alt",
|
||||
surface: true,
|
||||
key: "inventory-widget-edit:delete",
|
||||
vm: vm
|
||||
},
|
||||
{ divider: true, inset: false },
|
||||
{
|
||||
title: vm.$gzlocale.get("Duplicate"),
|
||||
//TODO: save and new? Or only from main?
|
||||
if (vm.rights.change) {
|
||||
menuOptions.menuItems.push({
|
||||
title: vm.$gzlocale.get("Save"),
|
||||
icon: "save",
|
||||
surface: true,
|
||||
key: "inventory-widget-edit:save",
|
||||
vm: vm
|
||||
});
|
||||
}
|
||||
|
||||
icon: "clone",
|
||||
key: "inventory-widget-edit:duplicate",
|
||||
vm: vm
|
||||
}
|
||||
];
|
||||
if (vm.rights.delete) {
|
||||
menuOptions.menuItems.push({
|
||||
title: vm.$gzlocale.get("Delete"),
|
||||
icon: "trash-alt",
|
||||
surface: true,
|
||||
key: "inventory-widget-edit:delete",
|
||||
vm: vm
|
||||
});
|
||||
}
|
||||
|
||||
if (vm.rights.change) {
|
||||
menuOptions.menuItems.push({
|
||||
title: vm.$gzlocale.get("Duplicate"),
|
||||
icon: "clone",
|
||||
key: "inventory-widget-edit:duplicate",
|
||||
vm: vm
|
||||
});
|
||||
}
|
||||
|
||||
vm.$gzevent.$emit("menu-change", menuOptions);
|
||||
@@ -266,7 +268,11 @@ export default {
|
||||
var vm = this;
|
||||
this.$gzlocale
|
||||
.fetch(ltKeysRequired)
|
||||
.then(() => (vm.formState.ready = true))
|
||||
.then(() => {
|
||||
//don't have access to local data object until here
|
||||
vm.rights = this.$gzrole.getRights(this, this.$gztype.Widget);
|
||||
vm.formState.ready = true;
|
||||
})
|
||||
.catch(err => {
|
||||
vm.formState.ready = true;
|
||||
vm.$gzHandleFormError(err);
|
||||
@@ -279,17 +285,21 @@ export default {
|
||||
this.getDataFromApi();
|
||||
} else {
|
||||
//setup for new record
|
||||
//first get rights, are they allowed here at all?
|
||||
var readOnly = this.rights.change;
|
||||
//Update the form status
|
||||
// this.$gzform.setFormState({
|
||||
// vm: this,
|
||||
// dirty: false,
|
||||
// valid: true,
|
||||
// loading: false,
|
||||
// readOnly: res.readOnly ? true : false
|
||||
// });
|
||||
// //modify the menu as necessary
|
||||
// generateMenu(this, res.readOnly);
|
||||
this.$gzform.setFormState({
|
||||
vm: this,
|
||||
dirty: false,
|
||||
valid: true,
|
||||
loading: false,
|
||||
readOnly: readOnly
|
||||
});
|
||||
|
||||
//it's a new record so it can't be deleted so...
|
||||
this.rights.delete = false;
|
||||
|
||||
//modify the menu as necessary
|
||||
generateMenu(this);
|
||||
}
|
||||
},
|
||||
beforeRouteLeave(to, from, next) {
|
||||
@@ -322,7 +332,8 @@ export default {
|
||||
errorBoxMessage: null,
|
||||
appError: null,
|
||||
serverError: {}
|
||||
}
|
||||
},
|
||||
rights: this.$gzrole.defaultRightsObject()
|
||||
};
|
||||
},
|
||||
//WATCHERS
|
||||
@@ -423,7 +434,8 @@ export default {
|
||||
} else {
|
||||
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
|
||||
if (res.id) {
|
||||
//Handle "post" of new record
|
||||
//Handle "post" of new record (CREATE)
|
||||
//wouldn't this be cleaner if it just opened the new record directly since the url still has zero in the id field??
|
||||
vm.obj = res.data;
|
||||
vm.$gzform.setFormState({
|
||||
vm: vm,
|
||||
@@ -431,7 +443,7 @@ export default {
|
||||
readOnly: res.readOnly ? true : false
|
||||
});
|
||||
} else {
|
||||
//Handle "put" of an existing record
|
||||
//Handle "put" of an existing record (UPDATE)
|
||||
vm.obj.concurrencyToken = res.data.concurrencyToken;
|
||||
vm.$gzform.setFormState({
|
||||
vm: vm,
|
||||
|
||||
Reference in New Issue
Block a user