This commit is contained in:
2020-02-19 00:03:13 +00:00
parent 34dd599f69
commit 4231675e25

View File

@@ -330,68 +330,48 @@ function initForm(vm) {
(async function() { (async function() {
await populateFieldDefinitions(vm); await populateFieldDefinitions(vm);
await fetchLocalizedFieldNames(vm); await fetchLocalizedFieldNames(vm);
await setEffectiveListView(vm);
await initDataObject(vm);
resolve(); 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) { function populateFieldDefinitions(vm) {
console.log("called populatefieldDefinitions"); console.log("called populatefieldDefinitions");
return new Promise(function populate(resolve, reject) { //http://localhost:7575/api/v8/DataList/ListFields?DataListKey=TestWidgetDataList
//http://localhost:7575/api/v8/DataList/ListFields?DataListKey=TestWidgetDataList return window.$gz.api
return window.$gz.api .get("DataList/ListFields?DataListKey=" + vm.dataListKey)
.get("DataList/ListFields?DataListKey=" + vm.dataListKey) .then(res => {
.then(res => { if (res.error != undefined) {
if (res.error != undefined) { throw res.error;
reject(res.error); } else {
} else { vm.fieldDefinitions = res.data;
vm.fieldDefinitions = res.data; console.log("DONE populatefieldDefinitions");
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;
}); });
} }
@@ -401,38 +381,20 @@ function populateFieldDefinitions(vm) {
// // // //
// function fetchLocalizedFieldNames(vm) { // function fetchLocalizedFieldNames(vm) {
// console.log("called fetchLTFN"); // console.log("called fetchLTFN");
// var columnKeys = []; // return new Promise(function fetchLFN(resolve, reject) {
// for (var i = 1; i < vm.fieldDefinitions.length; i++) { // var columnKeys = [];
// var cm = vm.fieldDefinitions[i]; // for (var i = 1; i < vm.fieldDefinitions.length; i++) {
// columnKeys.push(cm.ltKey); // 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(() => { // //Now fetch all the keys and await the response before returning
// console.log("DONE fetchLTFN"); // window.$gz.locale.fetch(columnKeys).then(() => {
// return; // console.log("DONE fetchLTFN");
// resolve();
// });
// }); // });
// } // }
//////////////////////////////////////////////////////////
//
// Ensures column names are present in locale table
//
function fetchLocalizedFieldNames(vm) {
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();
});
});
}
///////////////////////////////// /////////////////////////////////
// //
// //