This commit is contained in:
2019-07-12 19:22:16 +00:00
parent 276c7f334f
commit b5d5c25d59
4 changed files with 20 additions and 24 deletions

View File

@@ -1,4 +1,4 @@
/* ZZeslint-disable */ /* eslint-disable */
import store from "../store"; import store from "../store";
import gzapi from "./gzapi"; import gzapi from "./gzapi";
import _ from "../libs/lodash.min.js"; import _ from "../libs/lodash.min.js";
@@ -6,21 +6,20 @@ import _ from "../libs/lodash.min.js";
export default { export default {
get(formKey) { get(formKey) {
return new Promise(function getFormTemplate(resolve) { return new Promise(function getFormTemplate(resolve) {
// debugger; if (!_.has(store.state.formCustom, formKey)) {
if (!_.has(store.state.formCustom, formKey)) {
//fetch and populate the store //fetch and populate the store
fetch(gzapi.APIUrl("formcustom/" + formKey)) gzapi.get("formcustom/" + formKey).then(res => {
.then(gzapi.status) debugger;
.then(gzapi.json) if (res.error) {
.then(response => { throw res.error;
store.commit("addLocaleText", { }
formKey: formKey,
value: response store.commit("addFormCustomTemplateItem", {
}); formKey: formKey,
resolve(); value: JSON.parse(res.data.template)
}); });
} else { resolve();
resolve(store.state.formCustom[formKey]); });
} }
}); });
} }

View File

@@ -5,7 +5,7 @@
</span> </span>
<div> <div>
<h5>FORMKEY: {{ formKey }}</h5> <h5>FORMKEY: {{ formKey }}</h5>
<h5>TEMPLATE: {{ this.$store.state.formSettings[formKey] }}</h5> <h5>TEMPLATE: {{ this.$store.state.formCustomTemplate[formKey] }}</h5>
<h5>CUSTOM FIELD DATA:</h5> <h5>CUSTOM FIELD DATA:</h5>
<span class="caption"> <span class="caption">
{{ value }} {{ value }}

View File

@@ -64,8 +64,8 @@ export default new Vuex.Store({
addLocaleText(state, data) { addLocaleText(state, data) {
state.localeText[data.key] = data.value; state.localeText[data.key] = data.value;
}, },
addFormCustom(state, data) { addFormCustomTemplateItem(state, data) {
state.formCustom[data.formKey] = data.value; state.formCustomTemplate[data.formKey] = data.value;
}, },
setLocale(state, data) { setLocale(state, data) {
// mutate state // mutate state

View File

@@ -617,7 +617,9 @@ var JUST_DELETED = false;
// //
// //
function initForm(vm) { function initForm(vm) {
return fetchLocaleText(vm).then(populatePickLists(vm)); return fetchLocaleText(vm).then(
populatePickLists(vm).then(fetchFormCustomTemplate(vm))
);
} }
////////////////////// //////////////////////
@@ -636,12 +638,7 @@ function populatePickLists(vm) {
// //
// //
function fetchFormCustomTemplate(vm) { function fetchFormCustomTemplate(vm) {
return vm.$gzformcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY).then(res => { return vm.$gzformcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY);
if (res.error) {
throw res.error;
}
vm.pickLists.roles = res.data;
});
} }
////////////////////// //////////////////////