This commit is contained in:
2020-06-19 22:47:57 +00:00
parent 7067e26a24
commit 70f035f90e
5 changed files with 63 additions and 213 deletions

View File

@@ -17,30 +17,19 @@ function addDataKeyNames(obj) {
export default {
// cache the form customization data if it's not already present
//cache invalidation is hard, this needs it...hmmm....
//for now will rely on logout and back in to clear up any customization issues
get(formKey) {
return new Promise(function getFormTemplate(resolve) {
if (
!window.$gz._.has(window.$gz.store.state.formCustomTemplate, formKey)
) {
//fetch and populate the store
window.$gz.api.get("form-custom/" + formKey).then(res => {
if (res.error) {
throw res.error;
}
window.$gz.store.commit("setFormCustomTemplateItem", {
formKey: formKey,
concurrency: res.data.concurrency,
value: addDataKeyNames(JSON.parse(res.data.template))
});
resolve();
});
} else {
resolve();
async get(formKey) {
if (!window.$gz._.has(window.$gz.store.state.formCustomTemplate, formKey)) {
//fetch and populate the store
let res = await window.$gz.api.get("form-custom/" + formKey);
if (res.error) {
throw res.error;
}
});
window.$gz.store.commit("setFormCustomTemplateItem", {
formKey: formKey,
concurrency: res.data.concurrency,
value: addDataKeyNames(JSON.parse(res.data.template))
});
}
},
set(formKey, token, template) {
window.$gz.store.commit("setFormCustomTemplateItem", {