all apparently working and cleaned up

This commit is contained in:
2020-06-10 21:40:05 +00:00
parent 0a43e53ab7
commit 3dd7e05549
9 changed files with 12 additions and 985 deletions

View File

@@ -31,70 +31,18 @@ export default {
}
//step 2: get it
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)
let transData = await window.$gz.api.upsertEx(
"translation/subset",
needIt
);
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) {
transData.data.forEach(function commitFetchedTranslationItemToStore(
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