summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorAngelo Gallarello <angelo.gallarell@gmail.com>2018-08-16 00:32:31 +0200
committerAngelo Gallarello <angelo.gallarell@gmail.com>2018-08-16 00:32:31 +0200
commit6828ccd7f17d14f178e6742d78bdd14428ec6e07 (patch)
treebca97277f80b29bf224e92b73e5fa6ec630f53c9 /models
parent9b0eb0a9f1973e05df7199cf2bff7518f2fa98dc (diff)
downloadwekan-6828ccd7f17d14f178e6742d78bdd14428ec6e07.tar.gz
wekan-6828ccd7f17d14f178e6742d78bdd14428ec6e07.tar.bz2
wekan-6828ccd7f17d14f178e6742d78bdd14428ec6e07.zip
Main flow implemented
Diffstat (limited to 'models')
-rw-r--r--models/actions.js8
-rw-r--r--models/activities.js10
-rw-r--r--models/lists.js2
-rw-r--r--models/rules.js5
-rw-r--r--models/triggers.js6
5 files changed, 17 insertions, 14 deletions
diff --git a/models/actions.js b/models/actions.js
index 0961abbb..93d45928 100644
--- a/models/actions.js
+++ b/models/actions.js
@@ -43,14 +43,6 @@ Actions.helpers({
-if (Meteor.isServer) {
- Meteor.startup(() => {
- const rules = Triggers.findOne({});
- if(!rules){
- Actions.insert({actionType: "moveCardToTop"});
- }
- });
-}
diff --git a/models/activities.js b/models/activities.js
index beb741bc..fe24c9c4 100644
--- a/models/activities.js
+++ b/models/activities.js
@@ -60,13 +60,13 @@ Activities.before.insert((userId, doc) => {
Activities.after.insert((userId, doc) => {
const activity = Activities._transform(doc);
- const matchedTriggers = Triggers.find(activity);
- if(matchedTriggers.count() > 0){
- const card = activity.card();
- Cards.direct.update({_id: card._id},{$set: {title: "ciaooo"}});
- }
+ RulesHelper.executeRules(activity);
+
});
+
+
+
if (Meteor.isServer) {
// For efficiency create indexes on the date of creation, and on the date of
// creation in conjunction with the card or board id, as corresponding views
diff --git a/models/lists.js b/models/lists.js
index 6f6996cb..ceda9ad1 100644
--- a/models/lists.js
+++ b/models/lists.js
@@ -82,7 +82,7 @@ Lists.helpers({
};
if (swimlaneId)
selector.swimlaneId = swimlaneId;
- return Cards.find(Filter.mongoSelector(selector),
+ return Cards.find(selector,
{ sort: ['sort'] });
},
diff --git a/models/rules.js b/models/rules.js
index 778622c4..271e6b52 100644
--- a/models/rules.js
+++ b/models/rules.js
@@ -21,6 +21,11 @@ Rules.mutations({
},
});
+Rules.helpers({
+ getAction(){
+ return Actions.findOne({_id:this.actionId});
+ },
+});
diff --git a/models/triggers.js b/models/triggers.js
index 660d8b94..e4e5ac46 100644
--- a/models/triggers.js
+++ b/models/triggers.js
@@ -21,6 +21,12 @@ Triggers.allow({
Triggers.helpers({
+
+
+ getRule(){
+ return Rules.findOne({triggerId:this._id});
+ },
+
fromList() {
return Lists.findOne(this.fromId);
},