mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01: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() {
|
action() {
|
||||||
const ruleId = this.data().ruleId;
|
const ruleId = this.data().ruleId;
|
||||||
const rule = ReactiveCache.getRule(ruleId.get());
|
const rule = ReactiveCache.getRule(ruleId.get());
|
||||||
const action = Actions.findOne({
|
const action = ReactiveCache.getAction(rule.actionId);
|
||||||
_id: rule.actionId,
|
|
||||||
});
|
|
||||||
const desc = action.description();
|
const desc = action.description();
|
||||||
const upperdesc = desc.charAt(0).toUpperCase() + desc.substr(1);
|
const upperdesc = desc.charAt(0).toUpperCase() + desc.substr(1);
|
||||||
return upperdesc;
|
return upperdesc;
|
||||||
|
|
|
||||||
|
|
@ -115,6 +115,14 @@ ReactiveCacheServer = {
|
||||||
const ret = Rules.find(selector, options).fetch();
|
const ret = Rules.find(selector, options).fetch();
|
||||||
return ret;
|
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() {
|
getCurrentSetting() {
|
||||||
const ret = Settings.findOne();
|
const ret = Settings.findOne();
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -465,6 +473,30 @@ ReactiveCacheClient = {
|
||||||
const ret = this.__rules.get(Jsons.stringify(select));
|
const ret = this.__rules.get(Jsons.stringify(select));
|
||||||
return ret;
|
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() {
|
getCurrentSetting() {
|
||||||
if (!this.__currentSetting || !this.__currentSetting.get()) {
|
if (!this.__currentSetting || !this.__currentSetting.get()) {
|
||||||
this.__currentSetting = new DataCache(() => {
|
this.__currentSetting = new DataCache(() => {
|
||||||
|
|
@ -746,6 +778,24 @@ ReactiveCache = {
|
||||||
}
|
}
|
||||||
return ret;
|
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() {
|
getCurrentSetting() {
|
||||||
let ret;
|
let ret;
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ Rules.mutations({
|
||||||
|
|
||||||
Rules.helpers({
|
Rules.helpers({
|
||||||
getAction() {
|
getAction() {
|
||||||
return Actions.findOne({ _id: this.actionId });
|
return ReactiveCache.getAction(this.actionId);
|
||||||
},
|
},
|
||||||
getTrigger() {
|
getTrigger() {
|
||||||
return Triggers.findOne({ _id: this.triggerId });
|
return Triggers.findOne({ _id: this.triggerId });
|
||||||
|
|
@ -70,7 +70,7 @@ Rules.helpers({
|
||||||
return Triggers.findOne({ _id: this.triggerId });
|
return Triggers.findOne({ _id: this.triggerId });
|
||||||
},
|
},
|
||||||
action() {
|
action() {
|
||||||
return Actions.findOne({ _id: this.actionId });
|
return ReactiveCache.getAction(this.actionId);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue