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 */
////////////////////////////////////////////////////////////////////////////////////////////////////////////
const FORM_KEY = "inventory-widget-edit";
const FORM_BASE_URL = "Widget/";
/////////////////////////////
//
//
@@ -169,7 +172,7 @@ function clickHandler(menuItem) {
return;
}
var m = this.$gzmenu.parseMenuItem(menuItem);
if (m.owner == "inventory-widget-edit" && !m.disabled) {
if (m.owner == FORM_KEY && !m.disabled) {
switch (m.key) {
case "save":
m.vm.submit();
@@ -183,7 +186,7 @@ function clickHandler(menuItem) {
default:
m.vm.$gzevent.$emit(
"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"),
icon: "save",
surface: true,
key: "inventory-widget-edit:save",
key: FORM_KEY + ":save",
vm: vm
});
}
@@ -220,7 +223,7 @@ function generateMenu(vm) {
title: vm.$gzlocale.get("Delete"),
icon: "trash-alt",
surface: true,
key: "inventory-widget-edit:delete",
key: FORM_KEY + ":delete",
vm: vm
});
}
@@ -229,11 +232,20 @@ function generateMenu(vm) {
menuOptions.menuItems.push({
title: vm.$gzlocale.get("Duplicate"),
icon: "clone",
key: "inventory-widget-edit:duplicate",
key: FORM_KEY + ":duplicate",
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);
}
@@ -409,26 +421,17 @@ export default {
//enable / disable save button
var canSave = val.dirty && val.valid && !val.readOnly;
if (canSave) {
this.$gzevent.$emit("menu-enable-item", "inventory-widget-edit:save");
this.$gzevent.$emit("menu-enable-item", FORM_KEY + ":save");
} else {
this.$gzevent.$emit(
"menu-disable-item",
"inventory-widget-edit:save"
);
this.$gzevent.$emit("menu-disable-item", FORM_KEY + ":save");
}
//enable / disable duplicate button
var canDuplicate = !val.dirty && val.valid && !val.readOnly;
if (canDuplicate) {
this.$gzevent.$emit(
"menu-enable-item",
"inventory-widget-edit:duplicate"
);
this.$gzevent.$emit("menu-enable-item", FORM_KEY + ":duplicate");
} else {
this.$gzevent.$emit(
"menu-disable-item",
"inventory-widget-edit:duplicate"
);
this.$gzevent.$emit("menu-disable-item", FORM_KEY + ":duplicate");
}
},
deep: true
@@ -451,9 +454,9 @@ export default {
getDataFromApi(recordId) {
this.formState.loading = true;
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;
this.$gzform.deleteAllErrorBoxErrors(this);
@@ -501,7 +504,7 @@ export default {
if (this.canSave) {
this.formState.loading = true;
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
this.$gzform.deleteAllErrorBoxErrors(this);
@@ -551,7 +554,7 @@ export default {
//do the delete
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)
vm.$gzform.deleteAllErrorBoxErrors(vm);
vm.$gzapi
@@ -583,7 +586,7 @@ export default {
if (this.canDuplicate && this.$route.params.id != 0) {
this.formState.loading = true;
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
this.$gzform.deleteAllErrorBoxErrors(this);