mirror of
https://github.com/wekan/wekan.git
synced 2026-03-05 13:20:15 +01:00
Merge pull request #5094 from mfilser/reactiveCache-full_implementation_collection_translation
ReactiveCache, full implementation of the collection "Translation"
This commit is contained in:
commit
da28af516d
1 changed files with 52 additions and 7 deletions
|
|
@ -255,6 +255,17 @@ ReactiveCacheServer = {
|
||||||
const ret = Meteor.user();
|
const ret = Meteor.user();
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
|
getTranslation(idOrFirstObjectSelector = {}, options = {}) {
|
||||||
|
const ret = Translation.findOne(idOrFirstObjectSelector, options);
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getTranslations(selector = {}, options = {}, getQuery = false) {
|
||||||
|
let ret = Translation.find(selector, options);
|
||||||
|
if (getQuery !== true) {
|
||||||
|
ret = ret.fetch();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only the Client is reactive
|
// only the Client is reactive
|
||||||
|
|
@ -847,6 +858,33 @@ ReactiveCacheClient = {
|
||||||
}
|
}
|
||||||
const ret = this.__currentUser.get();
|
const ret = this.__currentUser.get();
|
||||||
return ret;
|
return ret;
|
||||||
|
},
|
||||||
|
getTranslation(idOrFirstObjectSelector = {}, options = {}) {
|
||||||
|
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
||||||
|
if (!this.__translation) {
|
||||||
|
this.__translation = new DataCache(_idOrFirstObjectSelect => {
|
||||||
|
const __select = EJSON.parse(_idOrFirstObjectSelect);
|
||||||
|
const _ret = Translation.findOne(__select.idOrFirstObjectSelector, __select.options);
|
||||||
|
return _ret;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const ret = this.__translation.get(EJSON.stringify(idOrFirstObjectSelect));
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
getTranslations(selector = {}, options = {}, getQuery = false) {
|
||||||
|
const select = {selector, options, getQuery}
|
||||||
|
if (!this.__translations) {
|
||||||
|
this.__translations = new DataCache(_select => {
|
||||||
|
const __select = EJSON.parse(_select);
|
||||||
|
let _ret = Translation.find(__select.selector, __select.options);
|
||||||
|
if (__select.getQuery !== true) {
|
||||||
|
_ret = _ret.fetch();
|
||||||
|
}
|
||||||
|
return _ret;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const ret = this.__translations.get(EJSON.stringify(select));
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1263,17 +1301,24 @@ ReactiveCache = {
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
getTranslations(selector, options, getQuery) {
|
getTranslation(idOrFirstObjectSelector = {}, options = {}) {
|
||||||
let ret = Translation.find(selector, options);
|
let ret;
|
||||||
if (getQuery !== true) {
|
if (Meteor.isServer) {
|
||||||
ret = ret.fetch();
|
ret = ReactiveCacheServer.getTranslation(idOrFirstObjectSelector, options);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveCacheClient.getTranslation(idOrFirstObjectSelector, options);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
getTranslation(idOrFirstObjectSelector, options) {
|
getTranslations(selector = {}, options = {}, getQuery = false) {
|
||||||
const ret = Translation.findOne(idOrFirstObjectSelector, options);
|
let ret;
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
ret = ReactiveCacheServer.getTranslations(selector, options, getQuery);
|
||||||
|
} else {
|
||||||
|
ret = ReactiveCacheClient.getTranslations(selector, options, getQuery);
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client side little MiniMongo DB "Index"
|
// Client side little MiniMongo DB "Index"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue