This commit is contained in:
27
ayanova/src/api/form-custom-template.js
Normal file
27
ayanova/src/api/form-custom-template.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/* ZZeslint-disable */
|
||||
import store from "../store";
|
||||
import gzapi from "./gzapi";
|
||||
import _ from "../libs/lodash.min.js";
|
||||
|
||||
export default {
|
||||
get(formKey) {
|
||||
return new Promise(function getFormTemplate(resolve) {
|
||||
// debugger;
|
||||
if (!_.has(store.state.formCustom, formKey)) {
|
||||
//fetch and populate the store
|
||||
fetch(gzapi.APIUrl("formcustom/" + formKey))
|
||||
.then(gzapi.status)
|
||||
.then(gzapi.json)
|
||||
.then(response => {
|
||||
store.commit("addLocaleText", {
|
||||
formKey: formKey,
|
||||
value: response
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
resolve(store.state.formCustom[formKey]);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -4,8 +4,10 @@
|
||||
{{ this.$gzlocale.get("ObjectCustomFieldCustomGrid") }}
|
||||
</span>
|
||||
<div>
|
||||
<h5>FORMKEY: {{ formKey }}</h5>
|
||||
<h5>TEMPLATE: {{ this.$store.state.formSettings[formKey] }}</h5>
|
||||
<h5>CUSTOM FIELD DATA:</h5>
|
||||
<span class="caption">
|
||||
TODO: turn this into controls
|
||||
{{ value }}
|
||||
</span>
|
||||
</div>
|
||||
@@ -23,7 +25,8 @@ export default {
|
||||
};
|
||||
},
|
||||
props: {
|
||||
value: String
|
||||
value: String,
|
||||
formKey: String //used to grab template from store
|
||||
},
|
||||
watch: {
|
||||
value(val) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import locale from "./api/locale";
|
||||
import gzapi from "./api/gzapi";
|
||||
import gzreport from "./api/gzreport";
|
||||
import gzform from "./api/gzform";
|
||||
import gzformcustomtemplate from "./api/form-custom-template";
|
||||
import roles from "./api/authorizationroles";
|
||||
import gztype from "./api/ayatype";
|
||||
import "@/assets/css/main.css";
|
||||
@@ -49,6 +50,9 @@ Object.defineProperty(Vue.prototype, "$_", { value: lodash });
|
||||
Object.defineProperty(Vue.prototype, "$gzlocale", { value: locale });
|
||||
Object.defineProperty(Vue.prototype, "$gzapi", { value: gzapi });
|
||||
Object.defineProperty(Vue.prototype, "$gzform", { value: gzform });
|
||||
Object.defineProperty(Vue.prototype, "$gzformcustomtemplate", {
|
||||
value: gzformcustomtemplate
|
||||
});
|
||||
Object.defineProperty(Vue.prototype, "$gzreport", { value: gzreport });
|
||||
Object.defineProperty(Vue.prototype, "$gzHandleFormError", {
|
||||
value: errorHandler.handleFormError
|
||||
|
||||
@@ -28,7 +28,8 @@ export default new Vuex.Store({
|
||||
},
|
||||
navItems: [],
|
||||
logArray: [],
|
||||
formSettings: {} //this is the settings on forms that survive a refresh like grid number of items to show etc
|
||||
formSettings: {}, //this is the settings on forms that survive a refresh like grid number of items to show etc
|
||||
formCustomTemplate: {} //this is the custom fields settings for forms
|
||||
},
|
||||
mutations: {
|
||||
login(state, data) {
|
||||
@@ -40,6 +41,7 @@ export default new Vuex.Store({
|
||||
state.userName = data.userName;
|
||||
},
|
||||
logout(state) {
|
||||
//Things that are reset on logout
|
||||
state.apiToken = "-";
|
||||
state.authenticated = false;
|
||||
state.userId = 0;
|
||||
@@ -47,6 +49,7 @@ export default new Vuex.Store({
|
||||
state.roles = 0;
|
||||
state.navItems = [];
|
||||
state.localeText = {};
|
||||
state.formCustomTemplate = {};
|
||||
state.apiUrl = "";
|
||||
state.locale.decimalSeparator = ".";
|
||||
state.locale.currencySymbol = "$";
|
||||
@@ -61,6 +64,9 @@ export default new Vuex.Store({
|
||||
addLocaleText(state, data) {
|
||||
state.localeText[data.key] = data.value;
|
||||
},
|
||||
addFormCustom(state, data) {
|
||||
state.formCustom[data.formKey] = data.value;
|
||||
},
|
||||
setLocale(state, data) {
|
||||
// mutate state
|
||||
state.locale.decimalSeparator = data.decimalSeparator;
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
|
||||
<v-flex xs12 px-2>
|
||||
<gz-custom-fields
|
||||
:formKey="formCustomTemplateKey"
|
||||
v-model="obj.customFields"
|
||||
:readonly="this.formState.readOnly"
|
||||
ref="customFields"
|
||||
@@ -201,6 +202,7 @@
|
||||
|
||||
const FORM_KEY = "inventory-widget-edit";
|
||||
const FORM_BASE_URL = "Widget/";
|
||||
const FORM_CUSTOM_TEMPLATE_KEY = "widget";
|
||||
|
||||
export default {
|
||||
beforeCreate() {
|
||||
@@ -270,6 +272,7 @@ export default {
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||
pickLists: {
|
||||
roles: []
|
||||
},
|
||||
@@ -621,14 +624,24 @@ function initForm(vm) {
|
||||
//
|
||||
//
|
||||
function populatePickLists(vm) {
|
||||
return vm.$gzapi
|
||||
.get("AyaEnumPickList/list/authorizationroles") //roles
|
||||
.then(res => {
|
||||
if (res.error) {
|
||||
throw res.error;
|
||||
}
|
||||
vm.pickLists.roles = res.data;
|
||||
});
|
||||
return vm.$gzapi.get("AyaEnumPickList/list/authorizationroles").then(res => {
|
||||
if (res.error) {
|
||||
throw res.error;
|
||||
}
|
||||
vm.pickLists.roles = res.data;
|
||||
});
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
//
|
||||
//
|
||||
function fetchFormCustomTemplate(vm) {
|
||||
return vm.$gzformcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY).then(res => {
|
||||
if (res.error) {
|
||||
throw res.error;
|
||||
}
|
||||
vm.pickLists.roles = res.data;
|
||||
});
|
||||
}
|
||||
|
||||
//////////////////////
|
||||
|
||||
Reference in New Issue
Block a user