From edb3ea42d5c9329107b0f26be8af12bf07119f6c Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 19 Feb 2020 00:49:43 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 4 +- ayanova/src/views/ay-data-list-view.vue | 392 ++---------------------- 2 files changed, 35 insertions(+), 361 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index 04d6d161..8bf576b5 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -263,7 +263,9 @@ TAGS - At server if equality compare value is an array of strings then it's assu ---------------------- NON DATALISTVIEW STUFF ---------------------------- - +TODO: ay-data-list-view initform code shows proper way to initialize and await each step + - Take that model and look at all the other forms and ensure they work the same way + TODO: Custom fields test it out with grid, will likely need some field type code etc or is that already in the columns, not sure TODO: Tags in grid display, currently shows as an array of raw text with quotes, could be better displayed diff --git a/ayanova/src/views/ay-data-list-view.vue b/ayanova/src/views/ay-data-list-view.vue index c1a66c2c..6c4c06ca 100644 --- a/ayanova/src/views/ay-data-list-view.vue +++ b/ayanova/src/views/ay-data-list-view.vue @@ -70,9 +70,7 @@ ///////////////////////////////////////////////////////////////////////////////////////////////////////////// /* Xeslint-disable */ //////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -//NOTE: This is a simple form with no need for business rules or validation so stripped out any extraneous code related to all that -// + const FORM_KEY = "ay-data-list-view"; const API_BASE_URL = "DataListView/"; export default { @@ -81,17 +79,6 @@ export default { window.$gz.locale.fetch(ltKeysRequired).then(next); }, - beforeCreate() { - // var vm = this; - // initForm(vm) - // .then(() => { - // vm.formState.ready = true; - // }) - // .catch(err => { - // vm.formState.ready = true; - // window.$gz.errorHandler.handleFormError(err); - // }); - }, beforeRouteLeave(to, from, next) { //var vm = this; if (this.formState.dirty) { @@ -116,10 +103,10 @@ export default { vm.dataListKey = this.$route.params.dataListKey; vm.listViewId = this.$route.params.listViewId; vm.formKey = this.$route.params.formKey; - console.log("Created TOP calling initform..."); + //console.log("Created TOP calling initform..."); initForm(vm) .then(() => { - console.log("CREATED: back from initform"); + //console.log("CREATED: back from initform"); // path: "/ay-data-list-view/:listViewId/:dataListKey", vm.formState.ready = true; @@ -131,7 +118,7 @@ export default { window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save"); }) .catch(err => { - console.log("CREATED: ERROR back from initform with error"); + //console.log("CREATED: ERROR back from initform with error"); vm.formState.ready = true; window.$gz.errorHandler.handleFormError(err); }); @@ -317,21 +304,17 @@ function generateMenu(vm) { // // function initForm(vm) { - //return Promise.resolve(); - // return new Promise(function fetchLFN(resolve, reject) { - // return populateFieldDefinitions(vm); - // }).then(fetchLocalizedFieldNames(vm)); - //.then(resolve()); - // .then(setEffectiveListView(vm)) - // .then(initDataObject(vm)); - //return test(); return new Promise(function(resolve, reject) { (async function() { - await populateFieldDefinitions(vm); - await fetchLocalizedFieldNames(vm); - await setEffectiveListView(vm); - await initDataObject(vm); + try { + await populateFieldDefinitions(vm); + await fetchLocalizedFieldNames(vm); + await setEffectiveListView(vm); + await initDataObject(vm); + } catch (err) { + reject(err); + } resolve(); ////////// })(); @@ -341,7 +324,7 @@ function initForm(vm) { //////////////////// // function populateFieldDefinitions(vm) { - console.log("called populatefieldDefinitions"); + //console.log("called populatefieldDefinitions"); //http://localhost:7575/api/v8/DataList/ListFields?DataListKey=TestWidgetDataList return window.$gz.api .get("DataList/ListFields?DataListKey=" + vm.dataListKey) @@ -350,7 +333,7 @@ function populateFieldDefinitions(vm) { throw res.error; } else { vm.fieldDefinitions = res.data; - console.log("DONE populatefieldDefinitions"); + //console.log("DONE populatefieldDefinitions"); } }); } @@ -360,7 +343,7 @@ function populateFieldDefinitions(vm) { // Ensures column names are present in locale table // function fetchLocalizedFieldNames(vm) { - console.log("called fetchLTFN"); + //console.log("called fetchLTFN"); var columnKeys = []; for (var i = 1; i < vm.fieldDefinitions.length; i++) { var cm = vm.fieldDefinitions[i]; @@ -368,7 +351,8 @@ function fetchLocalizedFieldNames(vm) { } //Now fetch all the keys and await the response before returning return window.$gz.locale.fetch(columnKeys).then(() => { - console.log("DONE fetchLTFN"); + //console.log("DONE fetchLTFN"); + return; }); } @@ -377,8 +361,8 @@ function fetchLocalizedFieldNames(vm) { // // function setEffectiveListView(vm) { - console.log("called setEffectiveListView"); - //return Promise.resolve(); + //console.log("called setEffectiveListView"); + /* effectiveListView - Second get the ListView that is currently in use so can setup the page view @@ -397,7 +381,7 @@ function setEffectiveListView(vm) { if (vm.listViewId == -1) { if (formSettings.saved.dataTable.editedListView != null) { vm.effectiveListView = formSettings.saved.dataTable.editedListView; - console.log("DONE setEffectiveListView (resolved with saved, lvid=-1)"); + //console.log("DONE setEffectiveListView (resolved with saved, lvid=-1)"); return Promise.resolve(); } } else if (vm.listViewId == 0) { @@ -410,7 +394,7 @@ function setEffectiveListView(vm) { throw res.error; } else { vm.effectiveListView = JSON.parse(res.data); - console.log("DONE setEffectiveListView (fetched default, lvid=0)"); + //console.log("DONE setEffectiveListView (fetched default, lvid=0)"); } }); } else { @@ -421,7 +405,7 @@ function setEffectiveListView(vm) { formSettings.temp.dataTable.cachedListView != null ) { vm.effectiveListView = formSettings.temp.dataTable.cachedListView; - console.log("DONE setEffectiveListView (resolved with cached,lvid>0)"); + //console.log("DONE setEffectiveListView (resolved with cached,lvid>0)"); return Promise.resolve(); } else { //fetch it and cache it @@ -430,7 +414,7 @@ function setEffectiveListView(vm) { throw res.error; } else { vm.effectiveListView = JSON.parse(res.data.listView); - console.log("DONE setEffectiveListView (fetched listView, lvid>0)"); + //console.log("DONE setEffectiveListView (fetched listView, lvid>0)"); } }); } @@ -440,44 +424,14 @@ function setEffectiveListView(vm) { //////////////////// // function initDataObject(vm) { - console.log("called initDataObject"); - //build the data object + //console.log("called initDataObject"); + if (vm.effectiveListView == null) { throw "ay-data-list::initDataObject - effectiveListView is not set"; } if (vm.fieldDefinitions == null) { throw "ay-data-list::initDataObject - fieldDefinitions are not set"; } - /* - - 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 - - /* -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 -} -vm.fieldDefinitions -*/ var ret = []; @@ -530,297 +484,15 @@ vm.fieldDefinitions } } vm.obj = ret; - console.log("DONE InitDataObject"); + //console.log("DONE InitDataObject"); + + if (window.$gz.errorHandler.devMode) { + if (vm.obj.length != vm.fieldDefinitions.length - 1) { + throw "ay-data-list-view::initDataObject - working array length not equal to total field definition length"; + } + } return Promise.resolve(); //eoc } - -/* - { - "data": [ - { - "fieldKey": "df", - "ltKey": null, - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 2 - }, - { - "fieldKey": "widgetname", - "ltKey": "WidgetName", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 4, - "enumType": null, - "ayaObjectType": 2 - }, - { - "fieldKey": "widgetserial", - "ltKey": "WidgetSerial", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 5, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetdollaramount", - "ltKey": "WidgetDollarAmount", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 8, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcount", - "ltKey": "WidgetCount", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 5, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetusertype", - "ltKey": "WidgetUserType", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 10, - "enumType": "UserType", - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetstartdate", - "ltKey": "WidgetStartDate", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 1, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetenddate", - "ltKey": "WidgetEndDate", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 1, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetnotes", - "ltKey": "WidgetNotes", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 4, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "username", - "ltKey": "User", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 4, - "enumType": null, - "ayaObjectType": 3 - }, - { - "fieldKey": "widgetactive", - "ltKey": "Active", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 6, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgettags", - "ltKey": "Tags", - "isCustomField": false, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 9, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom1", - "ltKey": "WidgetCustom1", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom2", - "ltKey": "WidgetCustom2", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom3", - "ltKey": "WidgetCustom3", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom4", - "ltKey": "WidgetCustom4", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom5", - "ltKey": "WidgetCustom5", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom6", - "ltKey": "WidgetCustom6", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom7", - "ltKey": "WidgetCustom7", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom8", - "ltKey": "WidgetCustom8", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom9", - "ltKey": "WidgetCustom9", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom10", - "ltKey": "WidgetCustom10", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom11", - "ltKey": "WidgetCustom11", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom12", - "ltKey": "WidgetCustom12", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom13", - "ltKey": "WidgetCustom13", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom14", - "ltKey": "WidgetCustom14", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom15", - "ltKey": "WidgetCustom15", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - }, - { - "fieldKey": "widgetcustom16", - "ltKey": "WidgetCustom16", - "isCustomField": true, - "isFilterable": true, - "isSortable": true, - "uiFieldDataType": 0, - "enumType": null, - "ayaObjectType": 0 - } - ], - "readOnly": true -} -*/