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") }}
|
{{ this.$gzlocale.get("ObjectCustomFieldCustomGrid") }}
|
||||||
</span>
|
</span>
|
||||||
<div>
|
<div>
|
||||||
|
<h5>FORMKEY: {{ formKey }}</h5>
|
||||||
|
<h5>TEMPLATE: {{ this.$store.state.formSettings[formKey] }}</h5>
|
||||||
|
<h5>CUSTOM FIELD DATA:</h5>
|
||||||
<span class="caption">
|
<span class="caption">
|
||||||
TODO: turn this into controls
|
|
||||||
{{ value }}
|
{{ value }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -23,7 +25,8 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
value: String
|
value: String,
|
||||||
|
formKey: String //used to grab template from store
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value(val) {
|
value(val) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import locale from "./api/locale";
|
|||||||
import gzapi from "./api/gzapi";
|
import gzapi from "./api/gzapi";
|
||||||
import gzreport from "./api/gzreport";
|
import gzreport from "./api/gzreport";
|
||||||
import gzform from "./api/gzform";
|
import gzform from "./api/gzform";
|
||||||
|
import gzformcustomtemplate from "./api/form-custom-template";
|
||||||
import roles from "./api/authorizationroles";
|
import roles from "./api/authorizationroles";
|
||||||
import gztype from "./api/ayatype";
|
import gztype from "./api/ayatype";
|
||||||
import "@/assets/css/main.css";
|
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, "$gzlocale", { value: locale });
|
||||||
Object.defineProperty(Vue.prototype, "$gzapi", { value: gzapi });
|
Object.defineProperty(Vue.prototype, "$gzapi", { value: gzapi });
|
||||||
Object.defineProperty(Vue.prototype, "$gzform", { value: gzform });
|
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, "$gzreport", { value: gzreport });
|
||||||
Object.defineProperty(Vue.prototype, "$gzHandleFormError", {
|
Object.defineProperty(Vue.prototype, "$gzHandleFormError", {
|
||||||
value: errorHandler.handleFormError
|
value: errorHandler.handleFormError
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ export default new Vuex.Store({
|
|||||||
},
|
},
|
||||||
navItems: [],
|
navItems: [],
|
||||||
logArray: [],
|
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: {
|
mutations: {
|
||||||
login(state, data) {
|
login(state, data) {
|
||||||
@@ -40,6 +41,7 @@ export default new Vuex.Store({
|
|||||||
state.userName = data.userName;
|
state.userName = data.userName;
|
||||||
},
|
},
|
||||||
logout(state) {
|
logout(state) {
|
||||||
|
//Things that are reset on logout
|
||||||
state.apiToken = "-";
|
state.apiToken = "-";
|
||||||
state.authenticated = false;
|
state.authenticated = false;
|
||||||
state.userId = 0;
|
state.userId = 0;
|
||||||
@@ -47,6 +49,7 @@ export default new Vuex.Store({
|
|||||||
state.roles = 0;
|
state.roles = 0;
|
||||||
state.navItems = [];
|
state.navItems = [];
|
||||||
state.localeText = {};
|
state.localeText = {};
|
||||||
|
state.formCustomTemplate = {};
|
||||||
state.apiUrl = "";
|
state.apiUrl = "";
|
||||||
state.locale.decimalSeparator = ".";
|
state.locale.decimalSeparator = ".";
|
||||||
state.locale.currencySymbol = "$";
|
state.locale.currencySymbol = "$";
|
||||||
@@ -61,6 +64,9 @@ 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) {
|
||||||
|
state.formCustom[data.formKey] = data.value;
|
||||||
|
},
|
||||||
setLocale(state, data) {
|
setLocale(state, data) {
|
||||||
// mutate state
|
// mutate state
|
||||||
state.locale.decimalSeparator = data.decimalSeparator;
|
state.locale.decimalSeparator = data.decimalSeparator;
|
||||||
|
|||||||
@@ -164,6 +164,7 @@
|
|||||||
|
|
||||||
<v-flex xs12 px-2>
|
<v-flex xs12 px-2>
|
||||||
<gz-custom-fields
|
<gz-custom-fields
|
||||||
|
:formKey="formCustomTemplateKey"
|
||||||
v-model="obj.customFields"
|
v-model="obj.customFields"
|
||||||
:readonly="this.formState.readOnly"
|
:readonly="this.formState.readOnly"
|
||||||
ref="customFields"
|
ref="customFields"
|
||||||
@@ -201,6 +202,7 @@
|
|||||||
|
|
||||||
const FORM_KEY = "inventory-widget-edit";
|
const FORM_KEY = "inventory-widget-edit";
|
||||||
const FORM_BASE_URL = "Widget/";
|
const FORM_BASE_URL = "Widget/";
|
||||||
|
const FORM_CUSTOM_TEMPLATE_KEY = "widget";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
beforeCreate() {
|
beforeCreate() {
|
||||||
@@ -270,6 +272,7 @@ export default {
|
|||||||
components: {},
|
components: {},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
formCustomTemplateKey: FORM_CUSTOM_TEMPLATE_KEY,
|
||||||
pickLists: {
|
pickLists: {
|
||||||
roles: []
|
roles: []
|
||||||
},
|
},
|
||||||
@@ -621,14 +624,24 @@ function initForm(vm) {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
function populatePickLists(vm) {
|
function populatePickLists(vm) {
|
||||||
return vm.$gzapi
|
return vm.$gzapi.get("AyaEnumPickList/list/authorizationroles").then(res => {
|
||||||
.get("AyaEnumPickList/list/authorizationroles") //roles
|
if (res.error) {
|
||||||
.then(res => {
|
throw res.error;
|
||||||
if (res.error) {
|
}
|
||||||
throw res.error;
|
vm.pickLists.roles = res.data;
|
||||||
}
|
});
|
||||||
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