This commit is contained in:
2020-10-30 20:41:54 +00:00
parent b35ef49b6d
commit c0697ddd90
2 changed files with 56 additions and 2 deletions

View File

@@ -521,7 +521,20 @@ export default {
handleError("DELETE", error, route);
}
},
///////////////////////////////////
// PUT DATA TO API SERVER
// (used for puts that can't have a concurrency token like above)
async put(route, data) {
try {
let that = this;
let r = await fetch(that.APIUrl(route), that.fetchPutOptions(data));
that.statusEx(r);
r = await that.extractBodyEx(r);
return r;
} catch (error) {
handleError("UPSERT", error, route);
}
},
///////////////////////////////////
// POST FILE ATTACHMENTS
// @param {ayaId:objectid, ayaType:objectType, files:[array of files]}

View File

@@ -133,6 +133,7 @@ export default {
return;
}
this.effectiveView.splice(index, 1);
this.saveView();
},
dashRefresh: function(item) {
console.log(
@@ -146,7 +147,7 @@ export default {
addItem: function(item) {
this.showSelector = false;
this.effectiveView.push(item);
//save effective view as saved View
this.saveView();
},
availableItems: function() {
let allItems = DashRegistry.availableItems();
@@ -200,6 +201,46 @@ export default {
loading: false
});
}
},
async saveView() {
let vm = this;
if (vm.canSave == false) {
return;
}
try {
window.$gz.form.setFormState({
vm: vm,
loading: true
});
//clear any errors vm might be around from previous submit
window.$gz.form.deleteAllErrorBoxErrors(vm);
let res = await window.$gz.api.put(
"dashboard-view",
JSON.stringify(vm.effectiveView)
);
if (res.error) {
vm.formState.serverError = res.error;
window.$gz.form.setErrorBoxErrors(vm);
} else {
//Update the form status
window.$gz.form.setFormState({
vm: vm,
dirty: false,
valid: true
});
}
} catch (ex) {
window.$gz.errorHandler.handleFormError(ex, vm);
} finally {
window.$gz.form.setFormState({
vm: vm,
loading: false
});
}
}
},
data() {