This commit is contained in:
2020-02-18 22:36:37 +00:00
parent d809b915b8
commit a494be3852

View File

@@ -318,7 +318,8 @@ function initForm(vm) {
//return Promise.resolve(); //return Promise.resolve();
return populateFieldDefinitions(vm) return populateFieldDefinitions(vm)
.then(fetchLocalizedFieldNames(vm)) .then(fetchLocalizedFieldNames(vm))
.then(setEffectiveListView(vm)); .then(setEffectiveListView(vm))
.then(initDataObject(vm));
} }
//////////////////// ////////////////////
@@ -379,7 +380,9 @@ function setEffectiveListView(vm) {
} else if (vm.listViewId == 0) { } else if (vm.listViewId == 0) {
//get default list view //get default list view
//http://localhost:7575/api/v8/DataListView/default/TestWidgetDataList //http://localhost:7575/api/v8/DataListView/default/TestWidgetDataList
window.$gz.api.get("DataListView/default/" + vm.dataListKey).then(res => { return window.$gz.api
.get("DataListView/default/" + vm.dataListKey)
.then(res => {
if (res.error != undefined) { if (res.error != undefined) {
throw res.error; throw res.error;
} else { } else {
@@ -396,7 +399,7 @@ function setEffectiveListView(vm) {
vm.effectiveListView = formSettings.temp.dataTable.cachedListView; vm.effectiveListView = formSettings.temp.dataTable.cachedListView;
} else { } else {
//fetch it and cache it //fetch it and cache it
window.$gz.api.get("DataListView/" + vm.listViewId).then(res => { return window.$gz.api.get("DataListView/" + vm.listViewId).then(res => {
if (res.error != undefined) { if (res.error != undefined) {
throw res.error; throw res.error;
} else { } else {
@@ -410,56 +413,52 @@ function setEffectiveListView(vm) {
//////////////////// ////////////////////
// //
function initDataObject(vm) { function initDataObject(vm) {
//http://localhost:7575/api/v8/ObjectFields/ObjectFields/widget //build the data object
/*
var url = "FormFieldsDefinitions/" + vm.$route.params.formCustomTemplateKey; - WORKING COPY ARRAY FORMAT
return window.$gz.api.get(url).then(res => { - Need all fields available in it.
if (res.error != undefined) { - Each field is in order determined in UI (user can re-arrange order so need UI method called with circular buffer)
window.$gz.errorHandler.handleFormError(res.error, vm); - Each field has
} else { - visible property
//set vm.obj to the combined synthesized snapshot array of template and availble fields for working data for this form - filter array (optional)
// - {key, ltdisplay, hideable, custom, required, hide, type} - Sort property -+ (optional)
//Iterate ObjectFields effectiveListView: [{"fld":"widgetname"},{"fld":"widgetserial"},{"fld":"widgetdollaramount"},{"fld":"widgetusertype"},{"fld":"widgetstartdate"},{"fld":"widgetactive"},{"fld":"username"}]
//create a new object based on the f.a.f. item and any existing template values for that item effectiveListView: [{"fld": "widgetname","filter": {"items": [{"op": "%-","value": "Awesome"}]}},{"fld":"widgetserial"},{"fld":"widgetdollaramount"},{"fld":"widgetusertype"},{"fld":"widgetstartdate"},{"fld":"widgetactive"},{"fld":"username"},{"fld":"widgettags"},{"fld":"widgetcustom1"},{"fld":"widgetcustom2"}]
*/
for (var i = 0; i < res.data.length; i++) { //Iterate the listview, add each field to working array
//get the formAvailableField record into an object to save typing //custom fields example
var faf = res.data[i]; // var objItem = {
//get the customTemplate record for this field if it exists // key: faf.fieldKey,
// title: window.$gz.locale.get(faf.ltKey),
var templateItem = window.$gz.formCustomTemplate.getFieldTemplateValue( // stockRequired: !faf.hideable,
vm.formCustomTemplateKey, // custom: faf.isCustomField,
faf.fieldKey // required: faf.hideable === false || templateItem.required === true,
); // visible: templateItem.hide !== true,
// type: templateItem.type
//handle non-existent template item (expected) // };
if (templateItem === undefined || templateItem === null) { /*
templateItem = { What I need here:
required: false, {
hide: faf.isCustomField ? true : false, //hide if custom because it's not set to display if it's not present, all others are stock fields key: fieldKey
type: "text" title: display as
}; visible: bool
isFilterable:bool,
isSortable:bool,
enumType:null or type,
ayaObjectType:int
uiFieldDataType:int
isCustomField:bool,
sort: "-","+" or null
filter:{any:bool,items:[]} same format as listview
} }
*/
// var canHide=faf.hideable && templateItem.required!==true; var o = [];
var objItem = { //Pass 1, iterate the listview first
key: faf.fieldKey, for (var i = 0; i < vm.effectiveListView.length; i++) {}
title: window.$gz.locale.get(faf.ltKey),
stockRequired: !faf.hideable,
custom: faf.isCustomField,
required: faf.hideable === false || templateItem.required === true,
visible: templateItem.hide !== true,
type: templateItem.type
};
vm.obj.push(objItem); //eoc
vm.concurrencyToken = window.$gz.formCustomTemplate.getTemplateConcurrencyToken(
vm.formCustomTemplateKey
);
}
}
});
} }
/* /*