This commit is contained in:
@@ -47,6 +47,9 @@ CURRENT TODOs
|
||||
TODO: Form customization
|
||||
- Init of form: synthesize a single working collection array of objects in the vue data() for the session to play with not live data
|
||||
- customize form should work with a *copy* of all data and only access the store to update after successful save and on init to make copy
|
||||
- Format: Must be all fields in formavailable fields and also their current template value on form init
|
||||
- {key, hideable, custom, required, hide, type}
|
||||
{"data":{"id":100,"concurrencyToken":3793054,"name":"Rustic Wooden Table 122","serial":100,"dollarAmount":461.84000,"active":true,"roles":1024,"startDate":"2019-12-05T15:12:27.989787Z","endDate":"2019-12-05T19:42:09.458793Z","notes":"Et quasi sint repellat. Perferendis qui asperiores provident odio quia cupiditate aut velit ipsum. Vero eum est illum voluptas vel debitis sapiente cupiditate. Repellendus ut provident libero necessitatibus voluptatibus aut quia. Vitae veniam vero reprehenderit autem et nihil asperiores alias. Omnis nam nihil et harum provident qui vel aut officiis.\n\nOmnis voluptatum ut incidunt. Praesentium eos unde modi omnis iste id sunt provident repellat. Vero saepe dolorum illum officiis architecto maxime voluptatibus beatae voluptatibus. Eos nemo ipsum repellat qui alias rerum minus eum consequuntur. Consequatur dolore magni blanditiis libero tempora aut. Eum aspernatur provident.\n\nBeatae aliquam doloribus quia deleniti qui veniam voluptatem recusandae iste. Et ab omnis odit animi sed quibusdam et. Exercitationem necessitatibus autem nobis quam ea occaecati officiis reiciendis. Et id porro numquam. Adipisci perferendis error aliquam expedita voluptas velit quasi est voluptate.","count":0,"customFields":"{\"c1\":\"2019-12-05T18:44:27.6070689Z\",\"c2\":\"Sint est distinctio consectetur debitis. Ut architecto quia velit ipsum. Facere sed cupiditate fugiat harum voluptates officia rerum ut. Accusantium rerum illum nobis minima quia temporibus nulla accusamus deleniti. Et est asperiores iste qui voluptatem quo.\",\"c3\":65949398,\"c4\":true,\"c5\":0.447373016480064}","tags":["brown","black","yellow"]}}
|
||||
- When go to save then synthesize the record to send back
|
||||
- Update the Store on success
|
||||
- Do not add any custom fields not set to be displayed, their mere presence in teh template means they are to be displayed
|
||||
|
||||
@@ -358,8 +358,8 @@ export default {
|
||||
formCustomTemplateFieldName
|
||||
]);
|
||||
|
||||
//templateItem.required is a string value, not a boolean value
|
||||
if (templateItem === undefined || templateItem.required !== "true") {
|
||||
//templateItem.required
|
||||
if (templateItem === undefined || templateItem.required !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -395,15 +395,14 @@ export default {
|
||||
// dataKey: "c2"
|
||||
// fld: "WidgetCustom2"
|
||||
// hide: "false"
|
||||
// required: "true"
|
||||
// required: true
|
||||
// type: "text"
|
||||
|
||||
if (vm.formState.loading) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//templateItem.required is a string value, not a boolean value
|
||||
if (templateItem.required !== "true") {
|
||||
if (templateItem.required !== true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -535,12 +534,12 @@ export default {
|
||||
formCustomTemplateFieldName
|
||||
]);
|
||||
|
||||
//templateItem.required is a string value, not a boolean value
|
||||
if (templateItem === undefined || templateItem.hide !== "true") {
|
||||
|
||||
if (templateItem === undefined || templateItem.hide !== true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//Only here if we have a record in the custom template for this particular field and it's set to hide:"true"
|
||||
//Only here if we have a record in the custom template for this particular field and it's set to hide:true
|
||||
return false;
|
||||
},
|
||||
|
||||
|
||||
@@ -160,9 +160,14 @@
|
||||
public const string Number = "number"; //decimal regardless
|
||||
public const string Bool = "bool";
|
||||
|
||||
|
||||
FORMKEY: widget
|
||||
TEMPLATE: [ { "fld": "WidgetNotes", "required": "true" }, { "fld": "WidgetCustom1", "hide": "false", "required": "false", "type": "datetime" }, { "fld": "WidgetCustom2", "hide": "false", "required": "true", "type": "text" }, { "fld": "WidgetCustom3", "hide": "false", "required": "false", "type": "number" }, { "fld": "WidgetCustom4", "hide": "false", "required": "false", "type": "bool" }, { "fld": "WidgetCustom5", "hide": "false", "required": "false", "type": "currency" }, { "fld": "WidgetCustom6", "hide": "false", "required": "false", "type": "date" }, { "fld": "WidgetCustom7", "hide": "false", "required": "false", "type": "time" } ]
|
||||
{
|
||||
"data": {
|
||||
"id": 1,
|
||||
"concurrencyToken": 3794970,
|
||||
"formKey": "widget",
|
||||
"template": "[{\"fld\":\"WidgetNotes\",\"required\":true},{\"fld\":\"WidgetCustom1\",\"required\":false,\"type\":\"datetime\"},{\"fld\":\"WidgetCustom2\",\"required\":true,\"type\":\"text\"},{\"fld\":\"WidgetCustom3\",\"required\":false,\"type\":\"number\"},{\"fld\":\"WidgetCustom4\",\"required\":false,\"type\":\"bool\"},{\"fld\":\"WidgetCustom5\",\"required\":false,\"type\":\"currency\"},{\"fld\":\"WidgetCustom6\",\"required\":false,\"type\":\"date\"},{\"fld\":\"WidgetCustom7\",\"required\":false,\"type\":\"time\"}]"
|
||||
}
|
||||
}
|
||||
CUSTOM FIELD DATA:
|
||||
{"c1":"2020-03-12T16:37:39.9094856Z","c2":"Sint laborum quisquam dolorem ipsum architecto voluptate consequatur tempora praesentium. Nemo aliquam amet aut aliquid perspiciatis adipisci excepturi. Officia ea voluptatem dolore suscipit ipsa itaque. Quaerat nostrum ut qui dignissimos nesciunt quasi laudantium dicta. Ut nihil doloribus illum rem quas sed.","c3":30453626,"c4":false,"c5":0.529134196010015}
|
||||
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user