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