This commit is contained in:
2021-06-28 22:49:46 +00:00
parent 88e0ff1cb3
commit ae14e63dc2
4 changed files with 146 additions and 130 deletions

View File

@@ -421,6 +421,21 @@ CURRENTLY DOING:
NOT THE FOLLOWING THOUGH which are too complex to dupe at client
Translation, User
consider: duplicate workorder if to be replacement for templates needs ability to:
move all dates forward relatively
remove big chunks of things all at once
bugbug: tags are not *displaying* when a record is opened until click in a field
happening in all objects with tags
not happening in wiki
reveals only when a change to the form is made of some kind that triggers I guess formfieldchanged
event. Fuck.
Look at changes to tag control, maybe it's in there?
or in form() manager code
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

View File

@@ -674,31 +674,34 @@ export default {
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) {
//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 {
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);
@@ -1001,41 +1004,16 @@ 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: "head-office-edit",
params: {
recordid: res.data.id,
obj: res.data // Pass data object to new form
}
});
//Navigate to new record
this.$router.push({
name: "head-office-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) {
//contacts tab, load contacts if not done already

View File

@@ -203,26 +203,57 @@ 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 (this.$route.params.obj) {
// //yes, no need to fetch it
// this.obj = this.$route.params.obj;
// vm.formState.loading = false; //here we handle it immediately
// } else {
// await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
// }
// } else {
// //default to their configured email address on new record
// this.obj.deliveryAddress = this.$store.state.userOptions.emailAddress;
// vm.formState.loading = false; //here we handle it immediately
// }
// //set initial form status
// window.$gz.form.setFormState({
// vm: vm,
// dirty: false,
// valid: true
// });
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 (this.$route.params.obj) {
//yes, no need to fetch it
this.obj = this.$route.params.obj;
vm.formState.loading = false; //here we handle it immediately
} else {
await vm.getDataFromApi(vm.$route.params.recordid); //let getdata handle loading
}
} else {
//default to their configured email address on new record
this.obj.deliveryAddress = this.$store.state.userOptions.emailAddress;
vm.formState.loading = false; //here we handle it immediately
//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;
} else {
//default to their configured email address on new record
this.obj.deliveryAddress = this.$store.state.userOptions.emailAddress;
}
}
//set initial form status
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true
loading: false,
dirty: setDirty,
valid: setValid
});
generateMenu(vm);
@@ -576,34 +607,14 @@ export default {
}
},
async duplicate() {
let vm = this;
if (!vm.canDuplicate || vm.$route.params.recordid == 0) {
return;
}
vm.formState.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: "home-notify-subscription",
params: {
recordid: res.data.id,
obj: res.data // pass data object to new form
}
});
//Navigate to new record
this.$router.push({
name: "home-notify-subscription",
params: {
recordid: 0,
obj: this.obj
}
} catch (ex) {
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
vm.formState.loading = false;
}
});
}
}
};

View File

@@ -155,38 +155,76 @@ 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 (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.Reminder
// );
// vm.obj.startDate = defaultDates.start;
// vm.obj.stopDate = 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 a new record don't load one
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.Reminder
);
vm.obj.startDate = defaultDates.start;
vm.obj.stopDate = defaultDates.end;
//----------------------------------------------------------
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;
} else {
//----------------------------------------------------------
//NEW OBJECT DEFAULTS
let defaultDates = window.$gz.locale.defaultStartDateTime(
window.$gz.type.Reminder
);
vm.obj.startDate = defaultDates.start;
vm.obj.stopDate = defaultDates.end;
//----------------------------------------------------------
}
}
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true
loading: false,
dirty: setDirty,
valid: setValid
});
generateMenu(vm);
@@ -447,40 +485,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: "reminder-edit",
params: {
recordid: res.data.id,
obj: res.data // Pass data object to new form
}
});
//Navigate to new record
this.$router.push({
name: "reminder-edit",
params: {
recordid: 0,
obj: this.obj
}
} catch (ex) {
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
window.$gz.form.setFormState({
vm: vm,
loading: false
});
}
});
}
//end methods