This commit is contained in:
@@ -1,6 +1,42 @@
|
|||||||
/* ZZeslint-disable */
|
/* ZZeslint-disable */
|
||||||
//AyaNova Translation related utilities
|
//AyaNova Translation related utilities
|
||||||
export default {
|
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) {
|
get(key) {
|
||||||
//no translation for Wiki
|
//no translation for Wiki
|
||||||
if (key == "Wiki") {
|
if (key == "Wiki") {
|
||||||
@@ -35,7 +71,7 @@ export default {
|
|||||||
transData.data.forEach(function commitFetchedTranslationItemToStore(
|
transData.data.forEach(function commitFetchedTranslationItemToStore(
|
||||||
item
|
item
|
||||||
) {
|
) {
|
||||||
window.$gz.store.commit("addTranslationText", item);
|
window.$gz.store.commit("setTranslationText", item);
|
||||||
});
|
});
|
||||||
return resolve();
|
return resolve();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export default new Vuex.Store({
|
|||||||
addNavItem(state, data) {
|
addNavItem(state, data) {
|
||||||
state.navItems.push(data);
|
state.navItems.push(data);
|
||||||
},
|
},
|
||||||
addTranslationText(state, data) {
|
setTranslationText(state, data) {
|
||||||
state.translationText[data.key] = data.value;
|
state.translationText[data.key] = data.value;
|
||||||
},
|
},
|
||||||
setFormCustomTemplateItem(state, data) {
|
setFormCustomTemplateItem(state, data) {
|
||||||
|
|||||||
@@ -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**)
|
//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)
|
//Handle "put" of an existing record (UPDATE)
|
||||||
vm.obj.concurrency = res.data.concurrency;
|
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
|
//Update the form status
|
||||||
|
|||||||
Reference in New Issue
Block a user