all over the place with comments and console statements but now properly chains all the calls for login (except translation may have an issue)

This commit is contained in:
2020-06-10 21:05:45 +00:00
parent c0fcecb3f8
commit 0a43e53ab7
25 changed files with 1966 additions and 976 deletions

View File

@@ -11,8 +11,8 @@ export default {
}
return window.$gz.store.state.translationText[key];
},
fetch(keys) {
return new Promise(function fetchTranslationKeysFromServer(resolve) {
async cacheTranslations(keys) {
return new Promise(async function fetchTranslationKeysFromServer(resolve) {
//
//step 1: build an array of keys that we don't have already
//Note: this will ensure only unique keys go into the store so it's safe to call this with dupes as can happen
@@ -27,29 +27,74 @@ export default {
}
if (needIt.length == 0) {
resolve();
return;
return resolve();
}
//step 2: get it
fetch(
console.log("translation:cacheTranslations calling fetch via API");
let testres = await window.$gz.api.upsertEx("translation/subset", needIt);
console.log(testres);
console.log("translation:cacheTranslations calling fetch directly");
let response = await fetch(
window.$gz.api.APIUrl("translation/subset"),
window.$gz.api.fetchPostOptions(needIt)
)
.then(window.$gz.api.status)
.then(window.$gz.api.extractBody)
// eslint-disable-next-line
.then((response) => {
window.$gz._.forEach(
response.data,
function commitFetchedLTItemToStore(item) {
window.$gz.store.commit("addTranslationText", item);
}
);
resolve();
});
);
console.log("translation:fetch calling STATUS");
let data = await window.$gz.api.status(response);
console.log("translation:fetch calling extractBody");
let data2 = await window.$gz.api.extractBody(data);
console.log("translation:fetch calling processing into store");
window.$gz._.forEach(data2, function commitFetchedLTItemToStore(item) {
window.$gz.store.commit("addTranslationText", item);
});
console.log("translation:fetch done calling resolve");
return resolve();
});
},
// fetch(keys) {
// return new Promise(async function fetchTranslationKeysFromServer(resolve) {
// //
// //step 1: build an array of keys that we don't have already
// //Note: this will ensure only unique keys go into the store so it's safe to call this with dupes as can happen
// //for example datatables have dynamic column names so they need to fetch on demand
// let needIt = [];
// for (let i = 0; i < keys.length; i++) {
// if (
// !window.$gz._.has(window.$gz.store.state.translationText, keys[i])
// ) {
// needIt.push(keys[i]);
// }
// }
// if (needIt.length == 0) {
// resolve();
// return;
// }
// //step 2: get it
// await fetch(
// window.$gz.api.APIUrl("translation/subset"),
// window.$gz.api.fetchPostOptions(needIt)
// )
// .then(window.$gz.api.status)
// .then(window.$gz.api.extractBody)
// // eslint-disable-next-line
// .then((response) => {
// window.$gz._.forEach(
// response.data,
// function commitFetchedLTItemToStore(item) {
// window.$gz.store.commit("addTranslationText", item);
// }
// );
// console.log("translation:fetch calling resolve");
// resolve();
// });
// });
// },
//Keys that will always be required for any AyaNova work for any user
coreKeys: [
//main nav options