mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Move every Actions.findOne(idOrFirstObjectSelector, options) to the ReactiveCache
This commit is contained in:
parent
c262620993
commit
b48297df22
3 changed files with 53 additions and 5 deletions
|
@ -20,9 +20,7 @@ BlazeComponent.extendComponent({
|
|||
action() {
|
||||
const ruleId = this.data().ruleId;
|
||||
const rule = ReactiveCache.getRule(ruleId.get());
|
||||
const action = Actions.findOne({
|
||||
_id: rule.actionId,
|
||||
});
|
||||
const action = ReactiveCache.getAction(rule.actionId);
|
||||
const desc = action.description();
|
||||
const upperdesc = desc.charAt(0).toUpperCase() + desc.substr(1);
|
||||
return upperdesc;
|
||||
|
|
|
@ -115,6 +115,14 @@ ReactiveCacheServer = {
|
|||
const ret = Rules.find(selector, options).fetch();
|
||||
return ret;
|
||||
},
|
||||
getAction(idOrFirstObjectSelector, options) {
|
||||
const ret = Actions.findOne(idOrFirstObjectSelector, options);
|
||||
return ret;
|
||||
},
|
||||
getActions(selector, options) {
|
||||
const ret = Actions.find(selector, options).fetch();
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
const ret = Settings.findOne();
|
||||
return ret;
|
||||
|
@ -465,6 +473,30 @@ ReactiveCacheClient = {
|
|||
const ret = this.__rules.get(Jsons.stringify(select));
|
||||
return ret;
|
||||
},
|
||||
getAction(idOrFirstObjectSelector, options) {
|
||||
const idOrFirstObjectSelect = {idOrFirstObjectSelector, options}
|
||||
if (!this.__action) {
|
||||
this.__action = new DataCache(_idOrFirstObjectSelect => {
|
||||
const __select = Jsons.parse(_idOrFirstObjectSelect);
|
||||
const _ret = Actions.findOne(__select.idOrFirstObjectSelector, __select.options);
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__action.get(Jsons.stringify(idOrFirstObjectSelect));
|
||||
return ret;
|
||||
},
|
||||
getActions(selector, options) {
|
||||
const select = {selector, options}
|
||||
if (!this.__actions) {
|
||||
this.__actions = new DataCache(_select => {
|
||||
const __select = Jsons.parse(_select);
|
||||
const _ret = Actions.find(__select.selector, __select.options).fetch();
|
||||
return _ret;
|
||||
});
|
||||
}
|
||||
const ret = this.__actions.get(Jsons.stringify(select));
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
if (!this.__currentSetting || !this.__currentSetting.get()) {
|
||||
this.__currentSetting = new DataCache(() => {
|
||||
|
@ -746,6 +778,24 @@ ReactiveCache = {
|
|||
}
|
||||
return ret;
|
||||
},
|
||||
getAction(idOrFirstObjectSelector, options) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getAction(idOrFirstObjectSelector, options);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getAction(idOrFirstObjectSelector, options);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getActions(selector, options) {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
ret = ReactiveCacheServer.getActions(selector, options);
|
||||
} else {
|
||||
ret = ReactiveCacheClient.getActions(selector, options);
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
getCurrentSetting() {
|
||||
let ret;
|
||||
if (Meteor.isServer) {
|
||||
|
|
|
@ -58,7 +58,7 @@ Rules.mutations({
|
|||
|
||||
Rules.helpers({
|
||||
getAction() {
|
||||
return Actions.findOne({ _id: this.actionId });
|
||||
return ReactiveCache.getAction(this.actionId);
|
||||
},
|
||||
getTrigger() {
|
||||
return Triggers.findOne({ _id: this.triggerId });
|
||||
|
@ -70,7 +70,7 @@ Rules.helpers({
|
|||
return Triggers.findOne({ _id: this.triggerId });
|
||||
},
|
||||
action() {
|
||||
return Actions.findOne({ _id: this.actionId });
|
||||
return ReactiveCache.getAction(this.actionId);
|
||||
},
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue