This commit is contained in:
@@ -266,10 +266,10 @@ export default {
|
||||
wiki: null,
|
||||
customFields: "{}",
|
||||
tags: [],
|
||||
viewed: null,
|
||||
replied: null,
|
||||
fromId: null,
|
||||
toId: null,
|
||||
viewed: false,
|
||||
replied: false,
|
||||
fromId: 1,
|
||||
toId: 1,
|
||||
sent: null,
|
||||
fromName: null
|
||||
},
|
||||
@@ -427,9 +427,13 @@ export default {
|
||||
},
|
||||
async submit() {
|
||||
let vm = this;
|
||||
if (vm.canSave == false) {
|
||||
console.log("Can save is false");
|
||||
return;
|
||||
let userIdList = [];
|
||||
if (vm.toUsers.length > 0) {
|
||||
vm.toUsers.forEach(z => {
|
||||
userIdList.push(z.id);
|
||||
});
|
||||
} else {
|
||||
throw "No users selected";
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -440,38 +444,28 @@ export default {
|
||||
let url = API_BASE_URL; // + vm.$route.params.recordid;
|
||||
//clear any errors vm might be around from previous submit
|
||||
window.$gz.form.deleteAllErrorBoxErrors(vm);
|
||||
|
||||
let res = await window.$gz.api.upsert(url, vm.obj);
|
||||
vm.obj.sent = window.$gz.locale.nowUTC8601String();
|
||||
let res = await window.$gz.api.post(url, {
|
||||
users: userIdList,
|
||||
memo: vm.obj
|
||||
});
|
||||
|
||||
if (res.error) {
|
||||
vm.formState.serverError = res.error;
|
||||
window.$gz.form.setErrorBoxErrors(vm);
|
||||
} else {
|
||||
//Logic for detecting if a post or put: if id then it was a post, if no id then it was a put
|
||||
if (res.data.id) {
|
||||
//POST - whole new object returned
|
||||
vm.obj = res.data;
|
||||
//Change URL to new record
|
||||
//NOTE: will not cause a page re-render, almost nothing does unless forced with a KEY property or using router.GO()
|
||||
|
||||
this.$router.push({
|
||||
name: "memo-edit",
|
||||
params: {
|
||||
recordid: res.data.id,
|
||||
obj: res.data // Pass data object to new form
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//PUT - only concurrency token is returned (**warning, if server changes object other fields then this needs to act more like POST above but is more efficient this way**)
|
||||
//Handle "put" of an existing record (UPDATE)
|
||||
vm.obj.concurrency = res.data.concurrency;
|
||||
}
|
||||
//Update the form status
|
||||
window.$gz.form.setFormState({
|
||||
vm: vm,
|
||||
dirty: false,
|
||||
valid: true
|
||||
});
|
||||
vm.$router.go(-1);
|
||||
// vm.pickListSelectedUserId = null;
|
||||
// vm.items = [];
|
||||
// vm.toUsers = [];
|
||||
// vm.obj.notes = null;
|
||||
// vm.obj.name = null;
|
||||
// //Only a post, no data returned
|
||||
// window.$gz.form.setFormState({
|
||||
// vm: vm,
|
||||
// dirty: false
|
||||
// });
|
||||
// vm.updateSave();
|
||||
}
|
||||
} catch (ex) {
|
||||
window.$gz.errorHandler.handleFormError(ex, vm);
|
||||
|
||||
Reference in New Issue
Block a user