This commit is contained in:
2023-01-11 22:46:03 +00:00
parent 09f104bb83
commit bb37df122c

View File

@@ -1213,7 +1213,7 @@ export default {
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save"); window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
} }
if (!val.dirty && val.valid && !val.readOnly) { if (!val.dirty && val.valid) {
window.$gz.eventBus.$emit( window.$gz.eventBus.$emit(
"menu-enable-item", "menu-enable-item",
FORM_KEY + ":duplicate" FORM_KEY + ":duplicate"
@@ -1254,9 +1254,15 @@ export default {
this.obj = this.$route.params.obj; this.obj = this.$route.params.obj;
this.obj.concurrency = undefined; this.obj.concurrency = undefined;
this.obj.id = 0; this.obj.id = 0;
this.obj.name = `${this.obj.name} - ${window.$gz.translation.get( this.obj.key = null;
"Copy" this.obj.active=false;
)}`; this.obj.fetchedOn=null;
this.obj.fetchCode=null;
this.obj.created=window.$gz.locale.nowUTC8601String();
this.obj.notificationSent=false;
// this.obj.name = `${this.obj.name} - ${window.$gz.translation.get(
// "Copy"
// )}`;
setDirty = true; setDirty = true;
} }
} }
@@ -1322,8 +1328,26 @@ export default {
window.$gz.form.fieldValueChanged(this, ref); window.$gz.form.fieldValueChanged(this, ref);
} }
}, },
customerChanged(newName) { async customerChanged() {
this.obj.regTo = newName; const id = this.obj.customerId;
if (!id || id == 0) {
return;
}
const res = await window.$gz.api.get(`customer/${id}`);
if (res.error) {
window.$gz.eventBus.$emit(
"notify-warning",
window.$gz.errorHandler.errorToString(res, this)
);
} else {
//Use customer record to update stuff here
this.obj.fetchEmail = res.data.emailAddress;
this.obj.regTo = res.data.name;
if (this.pGroup > 1) {
//NOT V7 OR MISC PRODUCT (so raven basically for now anyway)
this.obj.dbId = res.data.dbId;
}
}
}, },
dtAddOneWeek: function(propName) { dtAddOneWeek: function(propName) {
addToDate(this, propName, { addToDate(this, propName, {
@@ -1395,6 +1419,7 @@ export default {
} }
} }
}, },
async getDataFromApi(recordId) { async getDataFromApi(recordId) {
const vm = this; const vm = this;
window.$gz.form.setFormState({ window.$gz.form.setFormState({
@@ -1460,7 +1485,9 @@ export default {
}); });
} else { } else {
//PUT //PUT
vm.obj.concurrency = res.data.concurrency; vm.obj = res.data;
// vm.obj.concurrency = res.data.concurrency;
// vm.obj.key=res.data.key;
} }
window.$gz.form.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
@@ -1555,6 +1582,19 @@ async function clickHandler(menuItem) {
window.$gz.form.setLastReportMenuItem(FORM_KEY, res, m.vm); window.$gz.form.setLastReportMenuItem(FORM_KEY, res, m.vm);
} }
break; break;
case "delete":
m.vm.remove();
break;
case "new":
m.vm.$router.push({
name: "license-edit",
params: { recordid: 0 }
});
break;
case "duplicate":
m.vm.duplicate();
break;
case "plus-one-week": case "plus-one-week":
{ {
m.vm.dtAddToAll({ days: 7 }); m.vm.dtAddToAll({ days: 7 });
@@ -1626,6 +1666,33 @@ function generateMenu(vm) {
}); });
} }
if (vm.rights.change) {
menuOptions.menuItems.push({
title: "New",
icon: "$sockiPlus",
key: FORM_KEY + ":new",
vm: vm
});
}
if (vm.rights.change && vm.$route.params.recordid != 0) {
menuOptions.menuItems.push({
title: "Duplicate",
icon: "$sockiClone",
key: FORM_KEY + ":duplicate",
vm: vm
});
}
if (vm.rights.delete && vm.$route.params.recordid != 0) {
menuOptions.menuItems.push({
title: "Delete",
icon: "$sockiTrashAlt",
surface: false,
key: FORM_KEY + ":delete",
vm: vm
});
}
menuOptions.menuItems.push({ divider: true, inset: false }); menuOptions.menuItems.push({ divider: true, inset: false });
menuOptions.menuItems.push({ menuOptions.menuItems.push({