This commit is contained in:
2019-06-11 19:43:09 +00:00
parent 81a5c6fefc
commit 2071c0d1ba

View File

@@ -161,6 +161,9 @@
/* Xeslint-disable */ /* Xeslint-disable */
//////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
const FORM_KEY = "inventory-widget-edit";
const FORM_BASE_URL = "Widget/";
///////////////////////////// /////////////////////////////
// //
// //
@@ -169,7 +172,7 @@ function clickHandler(menuItem) {
return; return;
} }
var m = this.$gzmenu.parseMenuItem(menuItem); var m = this.$gzmenu.parseMenuItem(menuItem);
if (m.owner == "inventory-widget-edit" && !m.disabled) { if (m.owner == FORM_KEY && !m.disabled) {
switch (m.key) { switch (m.key) {
case "save": case "save":
m.vm.submit(); m.vm.submit();
@@ -183,7 +186,7 @@ function clickHandler(menuItem) {
default: default:
m.vm.$gzevent.$emit( m.vm.$gzevent.$emit(
"notify-warning", "notify-warning",
"inventory-widget-edit.vue::context click: [" + m.key + "]" FORM_KEY + "::context click: [" + m.key + "]"
); );
} }
} }
@@ -210,7 +213,7 @@ function generateMenu(vm) {
title: vm.$gzlocale.get("Save"), title: vm.$gzlocale.get("Save"),
icon: "save", icon: "save",
surface: true, surface: true,
key: "inventory-widget-edit:save", key: FORM_KEY + ":save",
vm: vm vm: vm
}); });
} }
@@ -220,7 +223,7 @@ function generateMenu(vm) {
title: vm.$gzlocale.get("Delete"), title: vm.$gzlocale.get("Delete"),
icon: "trash-alt", icon: "trash-alt",
surface: true, surface: true,
key: "inventory-widget-edit:delete", key: FORM_KEY + ":delete",
vm: vm vm: vm
}); });
} }
@@ -229,11 +232,20 @@ function generateMenu(vm) {
menuOptions.menuItems.push({ menuOptions.menuItems.push({
title: vm.$gzlocale.get("Duplicate"), title: vm.$gzlocale.get("Duplicate"),
icon: "clone", icon: "clone",
key: "inventory-widget-edit:duplicate", key: FORM_KEY + ":duplicate",
vm: vm vm: vm
}); });
} }
//STUB REPORTS
menuOptions.menuItems.push({
title: vm.$gzlocale.get("Print"),
icon: "print",
key: FORM_KEY + ":report",
vm: vm,
subItems: vm.$gzreport.availableReports("")
});
vm.$gzevent.$emit("menu-change", menuOptions); vm.$gzevent.$emit("menu-change", menuOptions);
} }
@@ -409,26 +421,17 @@ export default {
//enable / disable save button //enable / disable save button
var canSave = val.dirty && val.valid && !val.readOnly; var canSave = val.dirty && val.valid && !val.readOnly;
if (canSave) { if (canSave) {
this.$gzevent.$emit("menu-enable-item", "inventory-widget-edit:save"); this.$gzevent.$emit("menu-enable-item", FORM_KEY + ":save");
} else { } else {
this.$gzevent.$emit( this.$gzevent.$emit("menu-disable-item", FORM_KEY + ":save");
"menu-disable-item",
"inventory-widget-edit:save"
);
} }
//enable / disable duplicate button //enable / disable duplicate button
var canDuplicate = !val.dirty && val.valid && !val.readOnly; var canDuplicate = !val.dirty && val.valid && !val.readOnly;
if (canDuplicate) { if (canDuplicate) {
this.$gzevent.$emit( this.$gzevent.$emit("menu-enable-item", FORM_KEY + ":duplicate");
"menu-enable-item",
"inventory-widget-edit:duplicate"
);
} else { } else {
this.$gzevent.$emit( this.$gzevent.$emit("menu-disable-item", FORM_KEY + ":duplicate");
"menu-disable-item",
"inventory-widget-edit:duplicate"
);
} }
}, },
deep: true deep: true
@@ -451,9 +454,9 @@ export default {
getDataFromApi(recordId) { getDataFromApi(recordId) {
this.formState.loading = true; this.formState.loading = true;
if (!recordId) { if (!recordId) {
throw "inventory-widget-edit::getDataFromApi -> Missing recordID!"; throw FORM_KEY + "::getDataFromApi -> Missing recordID!";
} }
var url = "Widget/" + recordId; var url = FORM_BASE_URL + recordId;
var vm = this; var vm = this;
this.$gzform.deleteAllErrorBoxErrors(this); this.$gzform.deleteAllErrorBoxErrors(this);
@@ -501,7 +504,7 @@ export default {
if (this.canSave) { if (this.canSave) {
this.formState.loading = true; this.formState.loading = true;
var vm = this; var vm = this;
var url = "Widget/" + this.$route.params.id; var url = FORM_BASE_URL + this.$route.params.id;
//clear any errors vm might be around from previous submit //clear any errors vm might be around from previous submit
this.$gzform.deleteAllErrorBoxErrors(this); this.$gzform.deleteAllErrorBoxErrors(this);
@@ -551,7 +554,7 @@ export default {
//do the delete //do the delete
vm.formState.loading = true; vm.formState.loading = true;
var url = "Widget/" + vm.$route.params.id; var url = FORM_BASE_URL + vm.$route.params.id;
//TODO: check if it's a new record (no ID) or one from server (has id) //TODO: check if it's a new record (no ID) or one from server (has id)
vm.$gzform.deleteAllErrorBoxErrors(vm); vm.$gzform.deleteAllErrorBoxErrors(vm);
vm.$gzapi vm.$gzapi
@@ -583,7 +586,7 @@ export default {
if (this.canDuplicate && this.$route.params.id != 0) { if (this.canDuplicate && this.$route.params.id != 0) {
this.formState.loading = true; this.formState.loading = true;
var vm = this; var vm = this;
var url = "Widget/duplicate/" + this.$route.params.id; var url = FORM_BASE_URL + "duplicate/" + this.$route.params.id;
//clear any errors vm might be around from previous submit //clear any errors vm might be around from previous submit
this.$gzform.deleteAllErrorBoxErrors(this); this.$gzform.deleteAllErrorBoxErrors(this);