This commit is contained in:
2020-06-24 21:12:48 +00:00
parent e99ccd0ebe
commit 162f542150
3 changed files with 41 additions and 2 deletions

View File

@@ -1,6 +1,42 @@
/* ZZeslint-disable */
//AyaNova Translation related utilities
export default {
////////////////////////////////
// Update the local cache
//
//
async updateCache(editedTranslation) {
//This function is only called if there is a requirement to refresh the local cache
//either they just changed translations and saved it in user settings
//or they just edited a translation and saved it in translation editor and it's also their own local translation
if (editedTranslation) {
//iterate the keys that are cached and set them from whatever is in editedTranslation for that key
window.$gz._.forOwn(window.$gz.store.state.translationText, function(
cacheval,
cachekey
) {
//find match
let display = window.$gz._.find(editedTranslation.translationItems, {
key: cachekey
}).display;
window.$gz.store.commit("setTranslationText", {
key: cachekey,
value: display
});
});
} else {
//gather up the keys that are cached and fetch the latest and then replace them
}
//if editedTranslation is empty that means just fetch the existing ones freshly again
//refetch all the keys and update
//if edited translation is not empty that means update cache from the editedTranslation if it's the same one as is currently in use
//check if current translation is the same one passed in
//if it is, update all the currently cached local keys with the copy passed
//TODO: call this from translation editor if same (add fetch for in use translation for editor initform) and from local settings on change of translation
},
get(key) {
//no translation for Wiki
if (key == "Wiki") {
@@ -35,7 +71,7 @@ export default {
transData.data.forEach(function commitFetchedTranslationItemToStore(
item
) {
window.$gz.store.commit("addTranslationText", item);
window.$gz.store.commit("setTranslationText", item);
});
return resolve();
});

View File

@@ -86,7 +86,7 @@ export default new Vuex.Store({
addNavItem(state, data) {
state.navItems.push(data);
},
addTranslationText(state, data) {
setTranslationText(state, data) {
state.translationText[data.key] = data.value;
},
setFormCustomTemplateItem(state, data) {

View File

@@ -333,6 +333,9 @@ export default {
//PUT - only concurrency token is returned (**warning, if server changes object other fields then this needs to act more like POST above but is more efficient this way**)
//Handle "put" of an existing record (UPDATE)
vm.obj.concurrency = res.data.concurrency;
//Update local copy of translations if that's the same one in use
await window.$gz.translation.updateCache(vm.obj);
}
//Update the form status