diff options
author | Angelo Gallarello <angelo.gallarell@gmail.com> | 2018-09-14 17:35:14 +0200 |
---|---|---|
committer | Angelo Gallarello <angelo.gallarell@gmail.com> | 2018-09-14 17:35:14 +0200 |
commit | 30a3daa6af179009ac17b40a71bf3f9e9b1d698a (patch) | |
tree | 16e2ecdc589aa67367f3d53a44c1eaba8ba1f637 /models/triggers.js | |
parent | fc73dc5bbcbbd203efc4f10ecb4bd1a66e0d9efb (diff) | |
download | wekan-30a3daa6af179009ac17b40a71bf3f9e9b1d698a.tar.gz wekan-30a3daa6af179009ac17b40a71bf3f9e9b1d698a.tar.bz2 wekan-30a3daa6af179009ac17b40a71bf3f9e9b1d698a.zip |
Finished alpha rules
Diffstat (limited to 'models/triggers.js')
-rw-r--r-- | models/triggers.js | 112 |
1 files changed, 32 insertions, 80 deletions
diff --git a/models/triggers.js b/models/triggers.js index c5ed849e..c8e4cc75 100644 --- a/models/triggers.js +++ b/models/triggers.js @@ -1,10 +1,12 @@ Triggers = new Mongo.Collection('triggers'); - - Triggers.mutations({ rename(description) { - return { $set: { description } }; + return { + $set: { + description + } + }; }, }); @@ -20,87 +22,37 @@ Triggers.allow({ } }); - Triggers.helpers({ + description() { + return this.desc; + }, - description(){ - if(this.activityType == "createCard"){ - if(this.listName == "*"){ - return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-added-to').toLowerCase() + " " + TAPi18n.__('r-the-board'); - }else{ - return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-added-to').toLowerCase() + " " + TAPi18n.__('r-list') + " " +this.listName; - } - } - if(this.activityType == "removeCard"){ - if(this.listName == "*"){ - return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-removed-from') + " " + TAPi18n.__('r-the-board'); - }else{ - return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-removed-from') + " " + TAPi18n.__('r-list') + " " +this.listName; - } - } - if(this.activityType == "moveCard"){ - if(this.listName = "*"){ - return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-moved-from') + " " + this.oldListName; - }else{ - return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-moved-to') + " " + this.listName; - } - - } - if(this.activityType = "archivedCard"){ - return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-archived'); - } - if(this.activityType = "restoredCard"){ - return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-unarchived'); - } - if(this.activityType = "addedLabel"){ - if(this.labelId == "*"){ - return TAPi18n.__('r-when-a-label-is') + " " + TAPi18n.__('r-added-to') + " " + TAPi18n.__('r-a-card'); - }else{ - const board = Boards.findOne(Session.get('currentBoard')); - const label = board.getLabelById(this.labelId); - let name; - if(label.name == "" || label.name == undefined){ - name = label.color.toUpperCase(); - }else{ - name = label.name; - } - } - } - if(this.activityType = "restoredCard"){ - return TAPi18n.__('r-when-a-card-is') + " " + TAPi18n.__('r-unarchived'); - } - - - - return "No description found"; -}, - -getRule(){ - return Rules.findOne({triggerId:this._id}); -}, - -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; -}}); - + getRule() { + return Rules.findOne({ + triggerId: this._id + }); + }, + 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; + } +});
\ No newline at end of file |