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() {
await populateFieldDefinitions(vm);
await fetchLocalizedFieldNames(vm);
await setEffectiveListView(vm);
await initDataObject(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) {
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();
}
});
//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");
}
});
}
//////////////////////////////////////////////////////////
//
// 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) {
// 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;
// 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();
// });
// });
// }
//////////////////////////////////////////////////////////
//
// 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();
});
});
}
/////////////////////////////////
//
//