This commit is contained in:
2019-12-06 00:06:28 +00:00
parent 54e6eea0ab
commit bfb7d293d1
5 changed files with 81 additions and 53 deletions

View File

@@ -25,7 +25,7 @@
v-show="formState.errorBoxMessage"
color="error"
icon="fa-exclamation-circle "
:value="true"
value="true"
transition="scale-transition"
class="multi-line"
outlined
@@ -105,8 +105,9 @@ export default {
},
data() {
return {
obj: [],
formCustomTemplateKey: this.$route.params.formCustomTemplateKey,
formAvailableFields: {},
formState: {
ready: false,
dirty: false,
@@ -160,30 +161,31 @@ export default {
},
canDuplicate: function() {
return this.formState.valid && !this.formState.dirty;
},
getTemplateItemForField: function(customTemplateFieldKey) {
//first check template
var templateItem = window.$gz.formCustomTemplate.getFieldTemplateValue(
this.formCustomTemplateKey,
availableFieldItem.key
);
if(templateItem==undefined){
templateItem=
}
return templateItem;
},
fullName: {
// getter
get: function() {
return this.firstName + " " + this.lastName;
},
// setter
set: function(newValue) {
var names = newValue.split(" ");
this.firstName = names[0];
this.lastName = names[names.length - 1];
}
}
// ,
// getTemplateItemForField: function(customTemplateFieldKey) {
// //first check template
// var templateItem = window.$gz.formCustomTemplate.getFieldTemplateValue(
// this.formCustomTemplateKey,
// availableFieldItem.key
// );
// if(templateItem==undefined){
// templateItem=
// }
// return templateItem;
// },
// fullName: {
// // getter
// get: function() {
// return this.firstName + " " + this.lastName;
// },
// // setter
// set: function(newValue) {
// var names = newValue.split(" ");
// this.firstName = names[0];
// this.lastName = names[names.length - 1];
// }
// }
},
components: {},
methods: {
@@ -205,7 +207,7 @@ export default {
if (
templateItem &&
templateItem.required !== undefined &&
templateItem.required === "true" //it's text
templateItem.required === true //it's text
) {
templateSaysRequired = true;
}
@@ -252,25 +254,14 @@ function generateMenu(vm) {
window.$gz.eventBus.$emit("menu-change", menuOptions);
}
//////////////////////
//
//
// function initForm(vm) {
// return fetchLocaleText(vm).then(
// populatePickLists(vm).then(
// window.$gz.formcustomtemplate.get(FORM_CUSTOM_TEMPLATE_KEY)
// )
// );
// }
function initForm(vm) {
return ensureTemplateIsInStore(vm).then(getAvailableFields(vm));
//return getAvailableFields(vm).then(ensureTemplateIsInStore(vm));
return ensureTemplateIsInStore(vm).then(initDataObject(vm));
//return initDataObject(vm).then(ensureTemplateIsInStore(vm));
}
////////////////////
//
function getAvailableFields(vm) {
function initDataObject(vm) {
//http://localhost:7575/api/v8/FormCustom/AvailableFields/widget
var url =
@@ -279,7 +270,37 @@ function getAvailableFields(vm) {
if (res.error) {
throw res.error;
}
vm.formAvailableFields = res.data;
//set vm.obj to the combined synthesized snapshot array of template and availble fields for working data for this form
// - {key, ltdisplay, hideable, custom, required, hide, type}
//Iterate formAvailableFields
//create a new object based on the f.a.f. item and any existing template values for that item
for (var i = 0; i < res.data.length; i++) {
//get the formAvailableField record into an object to save typing
var faf = res.data[i];
//get the customTemplate record for this field if it exists
var templateItem = (templateItem = window.$gz.formCustomTemplate.getFieldTemplateValue(
vm.formCustomTemplateKey,
faf.key
));
//handle non-existent template item (expected)
if (templateItem === undefined || templateItem === null) {
templateItem = { required: false, hide: false };
}
var objItem = {
key: faf.key,
ltdisplay: window.$gz.locale.get(faf.key),
hideable: faf.hideable,
custom: faf.custom,
required: templateItem.required === true,
hide: templateItem.hide === true
};
}
// vm.formAvailableFields = res.data;
});
}

View File

@@ -10,7 +10,7 @@
v-show="formState.errorBoxMessage"
color="error"
icon="fa-exclamation-circle "
:value="true"
value="true"
transition="scale-transition"
class="multi-line"
outlined