This commit is contained in:
2021-06-29 15:59:43 +00:00
parent a94bb16b68
commit 97251d69a3
37 changed files with 209 additions and 133 deletions

View File

@@ -428,6 +428,8 @@ CURRENTLY DOING:
also any redundant support code that was related to duplication also any redundant support code that was related to duplication
NOT THE FOLLOWING THOUGH which are too complex to dupe at client NOT THE FOLLOWING THOUGH which are too complex to dupe at client
Translation, User, Purchaseorder, Contact, Translation, User, Purchaseorder, Contact,
- New name should reflect it's a copy so user can see something changed
otherwise hard to see it's a dupe except for the url bar
@@ -462,6 +464,21 @@ todo: purchase order dupe code at server is a bit sus.
is affecting inventory on duplicate?? is affecting inventory on duplicate??
Look into it. Look into it.
todo: work order remove all option - workorder duplicate brought up that it would be handy to be able to remove *all* of a grandchild collection
e.g. Scheduled users has a "Mark All for deletion" menu option to quickly remove a bunch
See item immediately below about this
maybe it's a menu option at top to just quickly remove all labor or whatever if it's a duplicate?
todo: work order reset dates - for duplicate scenario and to replace templates
some kind of option that changes all dates to move them forward or center around a date
might need to capture a created date in original wo
then can use that date to move all other dates relatively speaking
Not sure about this one, but it will be an issue
see how templates work in v7 as an idea
if they don't do labor and parts then having the ability to remove all parts or all labor from a work order would be the dandiest way to resolve this
so users can duplicate than slice out quickly the bits they don't want and bob's your lobster!!!
todo: how to directly open a workorder quickly when you know the wo number?? todo: how to directly open a workorder quickly when you know the wo number??
should be supported, otherwise you need to scroll around a list to find it which is fucked should be supported, otherwise you need to scroll around a list to find it which is fucked

View File

@@ -124,7 +124,7 @@ export default {
//NOTE: THIS FORM IS CREATE ONLY NO OPEN OLD ONES SO... //NOTE: THIS FORM IS CREATE ONLY NO OPEN OLD ONES SO...
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//Ok, we're here to *view* an existing record //Ok, we're here to *view* an existing record
//so we must fetch the deets now //so we must fetch the deets now

View File

@@ -220,7 +220,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -182,7 +182,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -218,7 +218,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -162,7 +162,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -433,7 +433,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -317,7 +317,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
// //id 0 means create a new record don't load one // //id 0 means create or duplicate to new
// if (vm.$route.params.recordid != 0) { // if (vm.$route.params.recordid != 0) {
// //is there already an obj from a prior operation? // //is there already an obj from a prior operation?
// if (vm.$route.params.obj) { // if (vm.$route.params.obj) {
@@ -347,7 +347,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -85,7 +85,7 @@ export default {
vm.rights = window.$gz.role.getRights(window.$gz.type.CustomerNote); vm.rights = window.$gz.role.getRights(window.$gz.type.CustomerNote);
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -767,7 +767,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -677,7 +677,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -419,7 +419,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -276,7 +276,7 @@ export default {
vm.formState.readOnly = !vm.rights.change || vm.obj.status != 0; vm.formState.readOnly = !vm.rights.change || vm.obj.status != 0;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -184,7 +184,7 @@ export default {
vm.formState.readOnly = false; //can always do things with your own memos vm.formState.readOnly = false; //can always do things with your own memos
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
vm.composing = false; vm.composing = false;
//is there already an obj from a prior operation? //is there already an obj from a prior operation?

View File

@@ -203,7 +203,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
// //id 0 means create a new record don't load one // //id 0 means create or duplicate to new
// if (vm.$route.params.recordid != 0) { // if (vm.$route.params.recordid != 0) {
// //is there already an obj from a prior operation? // //is there already an obj from a prior operation?
// if (this.$route.params.obj) { // if (this.$route.params.obj) {
@@ -227,7 +227,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -155,7 +155,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
// //id 0 means create a new record don't load one // //id 0 means create or duplicate to new
// if (vm.$route.params.recordid != 0) { // if (vm.$route.params.recordid != 0) {
// //is there already an obj from a prior operation? // //is there already an obj from a prior operation?
// if (this.$route.params.obj) { // if (this.$route.params.obj) {
@@ -192,7 +192,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -194,7 +194,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -207,7 +207,7 @@ export default {
//SO NOT FOR EDITING OTHER USERS, WILL ASSUME THE USER EDITOR FORM FOR MANAGEMENT WILL HAVE A COMPACT VERSION //SO NOT FOR EDITING OTHER USERS, WILL ASSUME THE USER EDITOR FORM FOR MANAGEMENT WILL HAVE A COMPACT VERSION
//OF THESE SAME FIELDS FOR THAT PURPOSE //OF THESE SAME FIELDS FOR THAT PURPOSE
//SO ALWAYS USER CURRENT LOGGED IN USER ID FOR THIS //SO ALWAYS USER CURRENT LOGGED IN USER ID FOR THIS
//id 0 means create a new record don't load one but thats not applicable here //id 0 means create or duplicate to new but thats not applicable here
await vm.getDataFromApi(); await vm.getDataFromApi();
} catch (err) { } catch (err) {

View File

@@ -292,7 +292,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -89,7 +89,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid == 0) { if (vm.$route.params.recordid == 0) {
throw "Invalid partid"; throw "Invalid partid";
} else { } else {

View File

@@ -118,7 +118,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid == 0) { if (vm.$route.params.recordid == 0) {
throw "Invalid partid"; throw "Invalid partid";
} else { } else {

View File

@@ -123,7 +123,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -327,7 +327,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -842,7 +842,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -1335,7 +1335,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -270,7 +270,7 @@ export default {
vm.formState.readOnly = !vm.rights.change || vm.obj.status != 0; vm.formState.readOnly = !vm.rights.change || vm.obj.status != 0;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -446,7 +446,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -199,7 +199,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -238,7 +238,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -283,7 +283,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -740,7 +740,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -79,7 +79,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -96,7 +96,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -140,7 +140,7 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -66,9 +66,12 @@ export default {
//set base rights //set base rights
vm.rights = window.$gz.role.getRights(window.$gz.type.WorkOrder); vm.rights = window.$gz.role.getRights(window.$gz.type.WorkOrder);
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
let setDirty = false;
let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//open existing path
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {
//yes, no need to fetch it //yes, no need to fetch it
@@ -82,19 +85,88 @@ export default {
await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
} }
} else { } else {
//NEW //new path
this.formState.loading = false; if (this.$route.params.obj) {
this.formState.ready = true; //DUPLICATE
//trigger rule breaking / validation this.obj = this.$route.params.obj;
this.$nextTick(() => { this.obj.concurrency = undefined;
this.obj.customerId = null; this.obj.id = 0;
this.fieldValueChanged(`customerId`); this.obj.serial = 0;
}); this.obj.isDirty = true;
vm.obj.items.forEach(z => {
z.id = 0;
z.concurrency = undefined;
z.workOrderId = 0;
z.isDirty = true;
z.expenses.forEach(x => {
x.id = 0;
x.concurrency = undefined;
x.isDirty = true;
});
z.labors.forEach(x => {
x.id = 0;
x.concurrency = undefined;
x.isDirty = true;
});
z.loans.forEach(x => {
x.id = 0;
x.concurrency = undefined;
x.isDirty = true;
});
z.parts.forEach(x => {
x.id = 0;
x.concurrency = undefined;
x.isDirty = true;
});
z.partRequests.forEach(x => {
x.id = 0;
x.concurrency = undefined;
x.isDirty = true;
});
z.scheduledUsers.forEach(x => {
x.id = 0;
x.concurrency = undefined;
x.isDirty = true;
});
z.tasks.forEach(x => {
x.id = 0;
x.concurrency = undefined;
x.isDirty = true;
});
z.travels.forEach(x => {
x.id = 0;
x.concurrency = undefined;
x.isDirty = true;
});
z.units.forEach(x => {
x.id = 0;
x.concurrency = undefined;
x.isDirty = true;
});
z.outsideServices.forEach(x => {
x.id = 0;
x.concurrency = undefined;
x.isDirty = true;
});
});
setDirty = true;
} else {
//NEW
this.formState.loading = false;
this.formState.ready = true;
//trigger rule breaking / validation
this.$nextTick(() => {
this.obj.customerId = null;
this.fieldValueChanged(`customerId`);
});
}
} }
window.$gz.form.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
dirty: false, loading: false,
valid: true dirty: setDirty,
valid: setValid
}); });
//update which areas are available to user and force generate menu //update which areas are available to user and force generate menu
@@ -645,41 +717,16 @@ export default {
} }
}, },
async duplicate() { async duplicate() {
let vm = this; //Navigate to new record
if (!vm.canDuplicate || vm.$route.params.recordid == 0) { this.$router.push({
return; name: "workorder-edit",
} params: {
window.$gz.form.setFormState({ recordid: 0,
vm: vm, obj: this.obj
loading: true
});
let url = API_BASE_URL + "duplicate/" + vm.$route.params.recordid;
try {
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.upsert(url);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//Navigate to new record
this.$router.push({
name: "workorder-edit",
params: {
recordid: res.data.id,
obj: res.data // Pass data object to new form
}
});
} }
} catch (ex) { });
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
window.$gz.form.setFormState({
vm: vm,
loading: false
});
}
} }
//end methods //end methods
} }
}; };

View File

@@ -602,7 +602,7 @@ export default {
let setDirty = false; let setDirty = false;
let setValid = true; let setValid = true;
//id 0 means create a new record don't load one //id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {

View File

@@ -250,37 +250,75 @@ export default {
vm.formState.readOnly = !vm.rights.change; vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler); window.$gz.eventBus.$on("menu-click", clickHandler);
//id 0 means create a new record don't load one // //id 0 means create or duplicate to new
// if (vm.$route.params.recordid != 0) {
// //is there already an obj from a prior operation?
// if (this.$route.params.obj) {
// //yes, no need to fetch it
// this.obj = this.$route.params.obj;
// window.$gz.form.setFormState({
// vm: vm,
// loading: false
// });
// } else {
// await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
// }
// } else {
// //----------------------------------------------------------
// //NEW OBJECT DEFAULTS
// let defaultDates = window.$gz.locale.defaultStartDateTime(
// window.$gz.type.Widget
// );
// vm.obj.startDate = defaultDates.start;
// vm.obj.endDate = defaultDates.end;
// //----------------------------------------------------------
// window.$gz.form.setFormState({
// vm: vm,
// loading: false
// });
// }
// window.$gz.form.setFormState({
// vm: vm,
// dirty: false,
// valid: true
// });
let setDirty = false;
let setValid = true;
//id 0 means create or duplicate to new
if (vm.$route.params.recordid != 0) { if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation? //is there already an obj from a prior operation?
if (this.$route.params.obj) { if (this.$route.params.obj) {
//yes, no need to fetch it //yes, no need to fetch it
this.obj = this.$route.params.obj; this.obj = this.$route.params.obj;
window.$gz.form.setFormState({
vm: vm,
loading: false
});
} else { } else {
await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
} }
} else { } else {
//---------------------------------------------------------- //Might be a duplicate and contain another record
//NEW OBJECT DEFAULTS if (this.$route.params.obj) {
let defaultDates = window.$gz.locale.defaultStartDateTime( this.obj = this.$route.params.obj;
window.$gz.type.Widget this.obj.concurrency = undefined;
); this.obj.id = 0;
vm.obj.startDate = defaultDates.start; setDirty = true;
vm.obj.endDate = defaultDates.end; } else {
//---------------------------------------------------------- //----------------------------------------------------------
window.$gz.form.setFormState({ //NEW OBJECT DEFAULTS
vm: vm, let defaultDates = window.$gz.locale.defaultStartDateTime(
loading: false window.$gz.type.Widget
}); );
vm.obj.startDate = defaultDates.start;
vm.obj.endDate = defaultDates.end;
//----------------------------------------------------------
}
} }
window.$gz.form.setFormState({ window.$gz.form.setFormState({
vm: vm, vm: vm,
dirty: false, loading: false,
valid: true dirty: setDirty,
valid: setValid
}); });
generateMenu(vm); generateMenu(vm);
@@ -544,40 +582,14 @@ export default {
} }
}, },
async duplicate() { async duplicate() {
let vm = this; //Navigate to new record
if (!vm.canDuplicate || vm.$route.params.recordid == 0) { this.$router.push({
return; name: "widget-edit",
} params: {
window.$gz.form.setFormState({ recordid: 0,
vm: vm, obj: this.obj
loading: true
});
let url = API_BASE_URL + "duplicate/" + vm.$route.params.recordid;
try {
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.upsert(url);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//Navigate to new record
this.$router.push({
name: "widget-edit",
params: {
recordid: res.data.id,
obj: res.data // Pass data object to new form
}
});
} }
} catch (ex) { });
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
window.$gz.form.setFormState({
vm: vm,
loading: false
});
}
} }
} }
}; };