This commit is contained in:
@@ -116,9 +116,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...");
|
||||
initForm(vm)
|
||||
.then(() => {
|
||||
console.log("CREATED: back from initform");
|
||||
// path: "/ay-data-list-view/:listViewId/:dataListKey",
|
||||
vm.formState.ready = true;
|
||||
|
||||
@@ -130,6 +131,7 @@ export default {
|
||||
window.$gz.eventBus.$emit("menu-disable-item", FORM_KEY + ":save");
|
||||
})
|
||||
.catch(err => {
|
||||
console.log("CREATED: ERROR back from initform with error");
|
||||
vm.formState.ready = true;
|
||||
window.$gz.errorHandler.handleFormError(err);
|
||||
});
|
||||
@@ -316,40 +318,118 @@ function generateMenu(vm) {
|
||||
//
|
||||
function initForm(vm) {
|
||||
//return Promise.resolve();
|
||||
return populateFieldDefinitions(vm)
|
||||
.then(fetchLocalizedFieldNames(vm))
|
||||
.then(setEffectiveListView(vm))
|
||||
.then(initDataObject(vm));
|
||||
// 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);
|
||||
resolve();
|
||||
//////////
|
||||
})();
|
||||
});
|
||||
}
|
||||
|
||||
function test() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
setTimeout(() => resolve(1), 1000); // (*)
|
||||
})
|
||||
.then(function(result) {
|
||||
// (**)
|
||||
|
||||
console.log(result); // 1
|
||||
return result * 2;
|
||||
})
|
||||
.then(function(result) {
|
||||
// (***)
|
||||
|
||||
console.log(result); // 2
|
||||
return result * 2;
|
||||
})
|
||||
.then(function(result) {
|
||||
console.log(result); // 4
|
||||
return result * 2;
|
||||
});
|
||||
}
|
||||
|
||||
// ////////////////////
|
||||
// //
|
||||
// function populateFieldDefinitions(vm) {
|
||||
// console.log("called populatefieldDefinitions");
|
||||
// //http://localhost:7575/api/v8/DataList/ListFields?DataListKey=TestWidgetDataList
|
||||
// return window.$gz.api
|
||||
// .get("DataList/ListFields?DataListKey=" + vm.dataListKey)
|
||||
// .then(res => {
|
||||
// if (res.error != undefined) {
|
||||
// throw res.error;
|
||||
// } else {
|
||||
// vm.fieldDefinitions = res.data;
|
||||
// console.log("DONE populatefieldDefinitions");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
////////////////////
|
||||
//
|
||||
function populateFieldDefinitions(vm) {
|
||||
//http://localhost:7575/api/v8/DataList/ListFields?DataListKey=TestWidgetDataList
|
||||
return window.$gz.api
|
||||
.get("DataList/ListFields?DataListKey=" + vm.dataListKey)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
throw res.error;
|
||||
} else {
|
||||
vm.fieldDefinitions = res.data;
|
||||
}
|
||||
});
|
||||
console.log("called populatefieldDefinitions");
|
||||
return new Promise(function populate(resolve, reject) {
|
||||
//http://localhost:7575/api/v8/DataList/ListFields?DataListKey=TestWidgetDataList
|
||||
return window.$gz.api
|
||||
.get("DataList/ListFields?DataListKey=" + vm.dataListKey)
|
||||
.then(res => {
|
||||
if (res.error != undefined) {
|
||||
reject(res.error);
|
||||
} else {
|
||||
vm.fieldDefinitions = res.data;
|
||||
console.log("DONE populatefieldDefinitions");
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// //////////////////////////////////////////////////////////
|
||||
// //
|
||||
// // Ensures column names are present in locale table
|
||||
// //
|
||||
// function fetchLocalizedFieldNames(vm) {
|
||||
// console.log("called fetchLTFN");
|
||||
// var columnKeys = [];
|
||||
// for (var i = 1; i < vm.fieldDefinitions.length; i++) {
|
||||
// var cm = vm.fieldDefinitions[i];
|
||||
// columnKeys.push(cm.ltKey);
|
||||
// }
|
||||
// //Now fetch all the keys and await the response before returning
|
||||
// return window.$gz.locale.fetch(columnKeys).then(() => {
|
||||
// console.log("DONE fetchLTFN");
|
||||
// return;
|
||||
// });
|
||||
// }
|
||||
|
||||
//////////////////////////////////////////////////////////
|
||||
//
|
||||
// Ensures column names are present in locale table
|
||||
//
|
||||
function fetchLocalizedFieldNames(vm) {
|
||||
var columnKeys = [];
|
||||
for (var i = 1; i < vm.fieldDefinitions.length; i++) {
|
||||
var cm = vm.fieldDefinitions[i];
|
||||
columnKeys.push(cm.ltKey);
|
||||
}
|
||||
//Now fetch all the keys and await the response before returning
|
||||
return window.$gz.locale.fetch(columnKeys).then(() => {
|
||||
return;
|
||||
console.log("called fetchLTFN");
|
||||
return new Promise(function fetchLFN(resolve, reject) {
|
||||
var columnKeys = [];
|
||||
for (var i = 1; i < vm.fieldDefinitions.length; i++) {
|
||||
var cm = vm.fieldDefinitions[i];
|
||||
columnKeys.push(cm.ltKey);
|
||||
}
|
||||
//Now fetch all the keys and await the response before returning
|
||||
window.$gz.locale.fetch(columnKeys).then(() => {
|
||||
console.log("DONE fetchLTFN");
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -357,6 +437,7 @@ function fetchLocalizedFieldNames(vm) {
|
||||
//
|
||||
//
|
||||
function setEffectiveListView(vm) {
|
||||
console.log("called setEffectiveListView");
|
||||
//return Promise.resolve();
|
||||
/*
|
||||
effectiveListView
|
||||
@@ -376,6 +457,8 @@ 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)");
|
||||
return Promise.resolve();
|
||||
}
|
||||
} else if (vm.listViewId == 0) {
|
||||
//get default list view
|
||||
@@ -387,6 +470,7 @@ function setEffectiveListView(vm) {
|
||||
throw res.error;
|
||||
} else {
|
||||
vm.effectiveListView = res.data;
|
||||
console.log("DONE setEffectiveListView (fetched default, lvid=0)");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -397,6 +481,8 @@ function setEffectiveListView(vm) {
|
||||
formSettings.temp.dataTable.cachedListView != null
|
||||
) {
|
||||
vm.effectiveListView = formSettings.temp.dataTable.cachedListView;
|
||||
console.log("DONE setEffectiveListView (resolved with cached,lvid>0)");
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
//fetch it and cache it
|
||||
return window.$gz.api.get("DataListView/" + vm.listViewId).then(res => {
|
||||
@@ -404,6 +490,7 @@ function setEffectiveListView(vm) {
|
||||
throw res.error;
|
||||
} else {
|
||||
vm.effectiveListView = res.data.listView;
|
||||
console.log("DONE setEffectiveListView (fetched listView, lvid>0)");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -413,7 +500,14 @@ function setEffectiveListView(vm) {
|
||||
////////////////////
|
||||
//
|
||||
function initDataObject(vm) {
|
||||
console.log("called initDataObject");
|
||||
//build the data object
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user