diff options
author | Angelo Gallarello <angelo.gallarell@gmail.com> | 2018-08-03 19:47:20 +0200 |
---|---|---|
committer | Angelo Gallarello <angelo.gallarell@gmail.com> | 2018-08-03 19:47:20 +0200 |
commit | f63482b58775a2f52fdd5f932ce7d14f16757133 (patch) | |
tree | 886fdeae889b05ea009d67ed2181a5c46985f48a /models | |
parent | d5870472fbc988d1a4a4fcec0aa46544bbedefab (diff) | |
download | wekan-f63482b58775a2f52fdd5f932ce7d14f16757133.tar.gz wekan-f63482b58775a2f52fdd5f932ce7d14f16757133.tar.bz2 wekan-f63482b58775a2f52fdd5f932ce7d14f16757133.zip |
UI for rules list
Diffstat (limited to 'models')
-rw-r--r-- | models/.DS_Store | bin | 0 -> 6148 bytes | |||
-rw-r--r-- | models/cards.js | 1 | ||||
-rw-r--r-- | models/rules.js | 38 | ||||
-rw-r--r-- | models/triggers.js | 74 |
4 files changed, 113 insertions, 0 deletions
diff --git a/models/.DS_Store b/models/.DS_Store Binary files differnew file mode 100644 index 00000000..5008ddfc --- /dev/null +++ b/models/.DS_Store diff --git a/models/cards.js b/models/cards.js index b6a7b4c6..618c191e 100644 --- a/models/cards.js +++ b/models/cards.js @@ -806,3 +806,4 @@ if (Meteor.isServer) { }); } + diff --git a/models/rules.js b/models/rules.js new file mode 100644 index 00000000..2304d2dc --- /dev/null +++ b/models/rules.js @@ -0,0 +1,38 @@ +Rules = new Mongo.Collection('rules'); + +Rules.attachSchema(new SimpleSchema({ + title: { + type: String, + optional: true, + }, + description: { + type: String, + optional: true, + }, +})); + +Rules.mutations({ + rename(description) { + return { $set: { description } }; + }, +}); + +Rules.allow({ + update: function () { + // add custom authentication code here + return true; + }, +}); + + + + +if (Meteor.isServer) { + Meteor.startup(() => { + const rules = Rules.findOne({}); + if(!rules){ + Rules.insert({title: "regola1", description: "bella"}); + Rules.insert({title: "regola2", description: "bella2"}); + } + }); +} diff --git a/models/triggers.js b/models/triggers.js new file mode 100644 index 00000000..f8dbb50d --- /dev/null +++ b/models/triggers.js @@ -0,0 +1,74 @@ +Triggers = new Mongo.Collection('triggers'); + + + +Triggers.mutations({ + rename(description) { + return { $set: { description } }; + }, +}); + +Triggers.allow({ + update: function () { + // add custom authentication code here + return true; + }, + insert: function () { + // add custom authentication code here + return true; + } +}); + + +Triggers.helpers({ + fromList() { + return Lists.findOne(this.fromId); + }, + + toList() { + return Lists.findOne(this.toId); + }, + + findList(title) { + return Lists.findOne({title:title}); + }, + + labels() { + const boardLabels = this.board().labels; + const cardLabels = _.filter(boardLabels, (label) => { + return _.contains(this.labelIds, label._id); + }); + return cardLabels; + }}); + + + +if (Meteor.isServer) { + Meteor.startup(() => { + const rules = Triggers.findOne({}); + if(!rules){ + Triggers.insert({group: "cards", activityType: "moveCard","fromId":-1,"toId":-1 }); + } + }); +} + + + + Activities.after.insert((userId, doc) => { + const activity = Activities._transform(doc); + const matchedTriggers = Triggers.find({activityType: activity.activityType,fromId:activity.oldListId,toId:activity.listId}) + if(matchedTriggers.count() > 0){ + const card = activity.card(); + const oldTitle = card.title; + const fromListTitle = activity.oldList().title; + Cards.direct.update({_id: card._id, listId: card.listId, boardId: card.boardId, archived: false}, + {$set: {title: "[From "+fromListTitle +"] "+ oldTitle}}); + } + }); + + + + + + + |