This commit is contained in:
@@ -318,7 +318,8 @@ function initForm(vm) {
|
||||
//return Promise.resolve();
|
||||
return populateFieldDefinitions(vm)
|
||||
.then(fetchLocalizedFieldNames(vm))
|
||||
.then(setEffectiveListView(vm));
|
||||
.then(setEffectiveListView(vm))
|
||||
.then(initDataObject(vm));
|
||||
}
|
||||
|
||||
////////////////////
|
||||
@@ -379,13 +380,15 @@ function setEffectiveListView(vm) {
|
||||
} else if (vm.listViewId == 0) {
|
||||
//get default list view
|
||||
//http://localhost:7575/api/v8/DataListView/default/TestWidgetDataList
|
||||
window.$gz.api.get("DataListView/default/" + vm.dataListKey).then(res => {
|
||||
if (res.error != undefined) {
|
||||
throw res.error;
|
||||
} else {
|
||||
vm.effectiveListView = res.data;
|
||||
}
|
||||
});
|
||||
return window.$gz.api
|
||||
.get("DataListView/default/" + vm.dataListKey)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
throw res.error;
|
||||
} else {
|
||||
vm.effectiveListView = res.data;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//listview has an id value
|
||||
//check if cached, if not then fetch, cache and set
|
||||
@@ -396,7 +399,7 @@ function setEffectiveListView(vm) {
|
||||
vm.effectiveListView = formSettings.temp.dataTable.cachedListView;
|
||||
} else {
|
||||
//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) {
|
||||
throw res.error;
|
||||
} else {
|
||||
@@ -410,56 +413,52 @@ function setEffectiveListView(vm) {
|
||||
////////////////////
|
||||
//
|
||||
function initDataObject(vm) {
|
||||
//http://localhost:7575/api/v8/ObjectFields/ObjectFields/widget
|
||||
//build the data object
|
||||
/*
|
||||
- WORKING COPY ARRAY FORMAT
|
||||
- Need all fields available in it.
|
||||
- Each field is in order determined in UI (user can re-arrange order so need UI method called with circular buffer)
|
||||
- Each field has
|
||||
- visible property
|
||||
- filter array (optional)
|
||||
- Sort property -+ (optional)
|
||||
effectiveListView: [{"fld":"widgetname"},{"fld":"widgetserial"},{"fld":"widgetdollaramount"},{"fld":"widgetusertype"},{"fld":"widgetstartdate"},{"fld":"widgetactive"},{"fld":"username"}]
|
||||
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"}]
|
||||
*/
|
||||
//Iterate the listview, add each field to working array
|
||||
//custom fields example
|
||||
// var objItem = {
|
||||
// key: faf.fieldKey,
|
||||
// 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
|
||||
// };
|
||||
/*
|
||||
What I need here:
|
||||
{
|
||||
key: fieldKey
|
||||
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 url = "FormFieldsDefinitions/" + vm.$route.params.formCustomTemplateKey;
|
||||
return window.$gz.api.get(url).then(res => {
|
||||
if (res.error != undefined) {
|
||||
window.$gz.errorHandler.handleFormError(res.error, vm);
|
||||
} else {
|
||||
//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 ObjectFields
|
||||
//create a new object based on the f.a.f. item and any existing template values for that item
|
||||
var o = [];
|
||||
|
||||
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
|
||||
//Pass 1, iterate the listview first
|
||||
for (var i = 0; i < vm.effectiveListView.length; i++) {}
|
||||
|
||||
var templateItem = window.$gz.formCustomTemplate.getFieldTemplateValue(
|
||||
vm.formCustomTemplateKey,
|
||||
faf.fieldKey
|
||||
);
|
||||
|
||||
//handle non-existent template item (expected)
|
||||
if (templateItem === undefined || templateItem === null) {
|
||||
templateItem = {
|
||||
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
|
||||
type: "text"
|
||||
};
|
||||
}
|
||||
|
||||
// var canHide=faf.hideable && templateItem.required!==true;
|
||||
|
||||
var objItem = {
|
||||
key: faf.fieldKey,
|
||||
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);
|
||||
vm.concurrencyToken = window.$gz.formCustomTemplate.getTemplateConcurrencyToken(
|
||||
vm.formCustomTemplateKey
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
//eoc
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user