This commit is contained in:
2021-06-28 22:00:18 +00:00
parent 94a1761e6c
commit 88e0ff1cb3
3 changed files with 84 additions and 97 deletions

View File

@@ -417,8 +417,15 @@ CURRENTLY DOING:
- rejig the formstate setting and object setting code for duplicate based on project
- replace duplicate code with project version
- Remove at server duplicate route and de-document if found anywhere
- At server remove any now redundant 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
Translation, User
todo: User duplicate not working, error about optionsobj
Message:_vm.optionsObj is undefined
probably need to populate that object as well as main obj on dupe
doesn't work on devops either, broken for a while
also dupe check on the customer contact object too
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

View File

@@ -317,31 +317,53 @@ export default {
vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler);
// //id 0 means create a new record don't load one
// if (vm.$route.params.recordid != 0) {
// //is there already an obj from a prior operation?
// if (vm.$route.params.obj) {
// //yes, no need to fetch it
// vm.obj = vm.$route.params.obj;
// window.$gz.form.setFormState({
// vm: vm,
// loading: false
// });
// } else {
// await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
// }
// //Ok, we're here now fetch the report data and can handle includeWoItemDescendants if necessary
// await fetchReportData(vm);
// } else {
// //New record so there *MUST* be an aType on the route params
// await fetchReportData(vm); //go ahead and fetch report data now, no need to handle includeWoItemDescendants
// window.$gz.form.setFormState({
// vm: vm,
// loading: false
// });
// }
let setDirty = false;
let setValid = true;
//id 0 means create a new record don't load one
if (vm.$route.params.recordid != 0) {
//is there already an obj from a prior operation?
if (vm.$route.params.obj) {
if (this.$route.params.obj) {
//yes, no need to fetch it
vm.obj = vm.$route.params.obj;
window.$gz.form.setFormState({
vm: vm,
loading: false
});
this.obj = this.$route.params.obj;
} else {
await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
}
//Ok, we're here now fetch the report data and can handle includeWoItemDescendants if necessary
await fetchReportData(vm);
} else {
//New record so there *MUST* be an aType on the route params
await fetchReportData(vm); //go ahead and fetch report data now, no need to handle includeWoItemDescendants
window.$gz.form.setFormState({
vm: vm,
loading: false
});
//Might be a duplicate and contain another record
if (this.$route.params.obj) {
this.obj = this.$route.params.obj;
this.obj.concurrency = undefined;
this.obj.id = 0;
setDirty = true;
}
}
//---------------
@@ -407,10 +429,17 @@ export default {
//---------------
// window.$gz.form.setFormState({
// vm: vm,
// dirty: false,
// valid: true
// });
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true
loading: false,
dirty: setDirty,
valid: setValid
});
generateMenu(vm);
@@ -889,41 +918,16 @@ Handlebars.registerHelper('loud', function (aString) {
}
},
async duplicate() {
let vm = this;
if (!vm.canDuplicate || vm.$route.params.recordid == 0) {
return;
}
window.$gz.form.setFormState({
vm: vm,
loading: true
});
let url = "report/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: "ay-report-edit",
params: {
recordid: res.data.id,
obj: res.data // Pass data object to new form
}
});
//Navigate to new record
this.$router.push({
name: "ay-report-edit",
params: {
recordid: 0,
obj: this.obj
}
} catch (ex) {
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
window.$gz.form.setFormState({
vm: vm,
loading: false
});
}
});
},
async render() {
let vm = this;
if (vm.$route.params.recordid == 0) {

View File

@@ -764,6 +764,8 @@ export default {
vm.rights = window.$gz.role.getRights(window.$gz.type.Customer);
vm.formState.readOnly = !vm.rights.change;
window.$gz.eventBus.$on("menu-click", clickHandler);
let setDirty = false;
let setValid = true;
//id 0 means create a new record don't load one
if (vm.$route.params.recordid != 0) {
@@ -771,25 +773,25 @@ export default {
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 {
window.$gz.form.setFormState({
vm: vm,
loading: false
});
//Might be a duplicate and contain another record
if (this.$route.params.obj) {
this.obj = this.$route.params.obj;
this.obj.concurrency = undefined;
this.obj.id = 0;
setDirty = true;
}
}
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true
loading: false,
dirty: setDirty,
valid: setValid
});
generateMenu(vm);
} catch (error) {
window.$gz.errorHandler.handleFormError(error, vm);
@@ -1097,40 +1099,14 @@ export default {
}
},
async duplicate() {
let vm = this;
if (!vm.canDuplicate || vm.$route.params.recordid == 0) {
return;
}
window.$gz.form.setFormState({
vm: vm,
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: "customer-edit",
params: {
recordid: res.data.id,
obj: res.data // Pass data object to new form
}
});
//Navigate to new record
this.$router.push({
name: "customer-edit",
params: {
recordid: 0,
obj: this.obj
}
} catch (ex) {
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
window.$gz.form.setFormState({
vm: vm,
loading: false
});
}
});
},
tabChanged: async function(tab) {
if (tab == 2) {