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) {
reject(res.error); throw 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");
// return new Promise(function fetchLFN(resolve, reject) {
// var columnKeys = []; // var columnKeys = [];
// for (var i = 1; i < vm.fieldDefinitions.length; i++) { // for (var i = 1; i < vm.fieldDefinitions.length; i++) {
// var cm = vm.fieldDefinitions[i]; // var cm = vm.fieldDefinitions[i];
// columnKeys.push(cm.ltKey); // columnKeys.push(cm.ltKey);
// } // }
// //Now fetch all the keys and await the response before returning // //Now fetch all the keys and await the response before returning
// return window.$gz.locale.fetch(columnKeys).then(() => { // window.$gz.locale.fetch(columnKeys).then(() => {
// console.log("DONE fetchLTFN"); // console.log("DONE fetchLTFN");
// return; // 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();
});
});
}
///////////////////////////////// /////////////////////////////////
// //
// //