diff options
author | Lauri Ojansivu <x@xet7.org> | 2018-09-22 10:21:20 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2018-09-22 10:21:20 +0300 |
commit | f6db23b4697dba0618e92ba9fd9e570be6d08e41 (patch) | |
tree | 026fcbdb03f069e4768a8075a7d90feffd992245 | |
parent | 86e3df0e5f977d8b6d3d6f2ac1d4c11b6942b83a (diff) | |
parent | dba5de18828313711b245792d5c6da81fd60031e (diff) | |
download | wekan-f6db23b4697dba0618e92ba9fd9e570be6d08e41.tar.gz wekan-f6db23b4697dba0618e92ba9fd9e570be6d08e41.tar.bz2 wekan-f6db23b4697dba0618e92ba9fd9e570be6d08e41.zip |
Merge branch 'feature-rules' of https://github.com/Angtrim/wekan into Angtrim-feature-rules
-rw-r--r-- | client/components/boards/boardHeader.jade | 8 | ||||
-rw-r--r-- | client/components/rules/actions/cardActions.js | 8 | ||||
-rw-r--r-- | client/components/rules/rules.styl | 2 | ||||
-rw-r--r-- | client/components/rules/triggers/boardTriggers.jade | 7 | ||||
-rw-r--r-- | client/components/rules/triggers/boardTriggers.js | 13 | ||||
-rw-r--r-- | client/components/rules/triggers/cardTriggers.js | 10 | ||||
-rw-r--r-- | client/components/rules/triggers/checklistTriggers.js | 4 | ||||
-rw-r--r-- | i18n/en.i18n.json | 5 | ||||
-rw-r--r-- | models/cards.js | 6 | ||||
-rw-r--r-- | models/checklistItems.js | 4 | ||||
-rw-r--r-- | models/lists.js | 11 | ||||
-rw-r--r-- | server/rulesHelper.js | 16 | ||||
-rw-r--r-- | server/triggersDef.js | 4 |
13 files changed, 66 insertions, 32 deletions
diff --git a/client/components/boards/boardHeader.jade b/client/components/boards/boardHeader.jade index dfd281de..75b2f02b 100644 --- a/client/components/boards/boardHeader.jade +++ b/client/components/boards/boardHeader.jade @@ -87,10 +87,10 @@ template(name="boardHeaderBar") if Filter.isActive a.board-header-btn-close.js-filter-reset(title="{{_ 'filter-clear'}}") i.fa.fa-times-thin - - a.board-header-btn.js-open-rules-view(title="{{_ 'rules'}}") - i.fa.fa-magic - span {{_ 'rules'}} + if currentUser.isAdmin + a.board-header-btn.js-open-rules-view(title="{{_ 'rules'}}") + i.fa.fa-magic + span {{_ 'rules'}} a.board-header-btn.js-open-search-view(title="{{_ 'search'}}") i.fa.fa-search diff --git a/client/components/rules/actions/cardActions.js b/client/components/rules/actions/cardActions.js index a65407c1..b04440bd 100644 --- a/client/components/rules/actions/cardActions.js +++ b/client/components/rules/actions/cardActions.js @@ -58,14 +58,14 @@ BlazeComponent.extendComponent({ const ruleName = this.data().ruleName.get(); const trigger = this.data().triggerVar.get(); const actionSelected = this.find('#member-action').value; - const memberName = this.find('#member-name').value; + const username = this.find('#member-name').value; const boardId = Session.get('currentBoard'); const desc = Utils.getTriggerActionDesc(event, this); if (actionSelected === 'add') { const triggerId = Triggers.insert(trigger); const actionId = Actions.insert({ actionType: 'addMember', - memberName, + username, boardId, desc, }); @@ -81,7 +81,7 @@ BlazeComponent.extendComponent({ const triggerId = Triggers.insert(trigger); const actionId = Actions.insert({ actionType: 'removeMember', - memberName, + username, boardId, desc, }); @@ -101,7 +101,7 @@ BlazeComponent.extendComponent({ const boardId = Session.get('currentBoard'); const actionId = Actions.insert({ actionType: 'removeMember', - 'memberName': '*', + 'username': '*', boardId, desc, }); diff --git a/client/components/rules/rules.styl b/client/components/rules/rules.styl index 68d74d32..45ce4003 100644 --- a/client/components/rules/rules.styl +++ b/client/components/rules/rules.styl @@ -116,7 +116,7 @@ .trigger-dropdown display:inline-block select - width:100px + width:auto height:30px margin:0px margin-left:5px diff --git a/client/components/rules/triggers/boardTriggers.jade b/client/components/rules/triggers/boardTriggers.jade index 266f11f8..48b9345c 100644 --- a/client/components/rules/triggers/boardTriggers.jade +++ b/client/components/rules/triggers/boardTriggers.jade @@ -30,6 +30,13 @@ template(name="boardTriggers") div.trigger-item div.trigger-content div.trigger-text + | {{_'r-when-a-card-is-moved'}} + div.trigger-button.js-add-gen-moved-trigger.js-goto-action + i.fa.fa-plus + + div.trigger-item + div.trigger-content + div.trigger-text | {{_'r-when-a-card-is'}} div.trigger-dropdown select(id="move-action") diff --git a/client/components/rules/triggers/boardTriggers.js b/client/components/rules/triggers/boardTriggers.js index e4753642..40c5b07e 100644 --- a/client/components/rules/triggers/boardTriggers.js +++ b/client/components/rules/triggers/boardTriggers.js @@ -76,6 +76,19 @@ BlazeComponent.extendComponent({ }); } }, + 'click .js-add-gen-moved-trigger' (event){ + const datas = this.data(); + const desc = Utils.getTriggerActionDesc(event, this); + const boardId = Session.get('currentBoard'); + + datas.triggerVar.set({ + activityType: 'moveCard', + boardId, + 'listName':'*', + 'oldListName': '*', + desc, + }); + }, 'click .js-add-arc-trigger' (event) { const datas = this.data(); const desc = Utils.getTriggerActionDesc(event, this); diff --git a/client/components/rules/triggers/cardTriggers.js b/client/components/rules/triggers/cardTriggers.js index 704c7690..2303a85b 100644 --- a/client/components/rules/triggers/cardTriggers.js +++ b/client/components/rules/triggers/cardTriggers.js @@ -67,7 +67,7 @@ BlazeComponent.extendComponent({ datas.triggerVar.set({ activityType: 'joinMember', boardId, - 'memberId': '*', + 'username': '*', desc, }); } @@ -75,7 +75,7 @@ BlazeComponent.extendComponent({ datas.triggerVar.set({ activityType: 'unjoinMember', boardId, - 'memberId': '*', + 'username': '*', desc, }); } @@ -84,13 +84,13 @@ BlazeComponent.extendComponent({ const desc = Utils.getTriggerActionDesc(event, this); const datas = this.data(); const actionSelected = this.find('#spec-member-action').value; - const memberId = this.find('#spec-member').value; + const username = this.find('#spec-member').value; const boardId = Session.get('currentBoard'); if (actionSelected === 'added') { datas.triggerVar.set({ activityType: 'joinMember', boardId, - memberId, + username, desc, }); } @@ -98,7 +98,7 @@ BlazeComponent.extendComponent({ datas.triggerVar.set({ activityType: 'unjoinMember', boardId, - memberId, + username, desc, }); } diff --git a/client/components/rules/triggers/checklistTriggers.js b/client/components/rules/triggers/checklistTriggers.js index 01f3effe..2272be29 100644 --- a/client/components/rules/triggers/checklistTriggers.js +++ b/client/components/rules/triggers/checklistTriggers.js @@ -78,7 +78,7 @@ BlazeComponent.extendComponent({ const actionSelected = this.find('#spec-comp-check-action').value; const checklistId = this.find('#spec-comp-check-name').value; const boardId = Session.get('currentBoard'); - if (actionSelected === 'added') { + if (actionSelected === 'completed') { datas.triggerVar.set({ activityType: 'completeChecklist', boardId, @@ -86,7 +86,7 @@ BlazeComponent.extendComponent({ desc, }); } - if (actionSelected === 'removed') { + if (actionSelected === 'uncompleted') { datas.triggerVar.set({ activityType: 'uncompleteChecklist', boardId, diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 81206ae3..896c10a3 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -548,7 +548,7 @@ "r-when-the-label-is": "When the label is", "r-list-name": "List name", "r-when-a-member": "When a member is", - "r-when-the-member": "When the member is", + "r-when-the-member": "When the member", "r-name": "name", "r-is": "is", "r-when-a-attach": "When an attachment", @@ -606,5 +606,6 @@ "r-d-uncheck-one": "Uncheck item", "r-d-check-of-list": "of checklist", "r-d-add-checklist": "Add checklist", - "r-d-remove-checklist": "Remove checklist" + "r-d-remove-checklist": "Remove checklist", + "r-when-a-card-is-moved": "When a card is moved to another list" } diff --git a/models/cards.js b/models/cards.js index 346b4bdd..66bfbcf3 100644 --- a/models/cards.js +++ b/models/cards.js @@ -1165,10 +1165,11 @@ function cardMembers(userId, doc, fieldNames, modifier) { // Say hello to the new member if (modifier.$addToSet && modifier.$addToSet.members) { memberId = modifier.$addToSet.members; + const username = Users.findOne(memberId).username; if (!_.contains(doc.members, memberId)) { Activities.insert({ userId, - memberId, + username, activityType: 'joinMember', boardId: doc.boardId, cardId: doc._id, @@ -1179,11 +1180,12 @@ function cardMembers(userId, doc, fieldNames, modifier) { // Say goodbye to the former member if (modifier.$pull && modifier.$pull.members) { memberId = modifier.$pull.members; + const username = Users.findOne(memberId).username; // Check that the former member is member of the card if (_.contains(doc.members, memberId)) { Activities.insert({ userId, - memberId, + username, activityType: 'unjoinMember', boardId: doc.boardId, cardId: doc._id, diff --git a/models/checklistItems.js b/models/checklistItems.js index 8380bda7..7132bc7c 100644 --- a/models/checklistItems.js +++ b/models/checklistItems.js @@ -130,7 +130,7 @@ function publishChekListCompleted(userId, doc, fieldNames, modifier){ cardId: doc.cardId, boardId, checklistId: doc.checklistId, - checklistName:doc.title, + checklistName:checkList.title, }; Activities.insert(act); } @@ -148,7 +148,7 @@ function publishChekListUncompleted(userId, doc, fieldNames, modifier){ cardId: doc.cardId, boardId, checklistId: doc.checklistId, - checklistName:doc.title, + checklistName:checkList.title, }; Activities.insert(act); } diff --git a/models/lists.js b/models/lists.js index bf5aae3c..b99fe8f5 100644 --- a/models/lists.js +++ b/models/lists.js @@ -82,6 +82,17 @@ Lists.helpers({ }; if (swimlaneId) selector.swimlaneId = swimlaneId; + return Cards.find(Filter.mongoSelector(selector), + { sort: ['sort'] }); + }, + + cardsUnfiltered(swimlaneId) { + const selector = { + listId: this._id, + archived: false, + }; + if (swimlaneId) + selector.swimlaneId = swimlaneId; return Cards.find(selector, { sort: ['sort'] }); }, diff --git a/server/rulesHelper.js b/server/rulesHelper.js index e7e19b96..e9139933 100644 --- a/server/rulesHelper.js +++ b/server/rulesHelper.js @@ -36,27 +36,27 @@ RulesHelper = { if(action.actionType === 'moveCardToTop'){ let listId; let list; - if(activity.listTitle === '*'){ - listId = card.swimlaneId; + if(action.listTitle === '*'){ + listId = card.listId; list = card.list(); }else{ list = Lists.findOne({title: action.listTitle, boardId }); listId = list._id; } - const minOrder = _.min(list.cards(card.swimlaneId).map((c) => c.sort)); + const minOrder = _.min(list.cardsUnfiltered(card.swimlaneId).map((c) => c.sort)); card.move(card.swimlaneId, listId, minOrder - 1); } if(action.actionType === 'moveCardToBottom'){ let listId; let list; - if(activity.listTitle === '*'){ - listId = card.swimlaneId; + if(action.listTitle === '*'){ + listId = card.listId; list = card.list(); }else{ list = Lists.findOne({title: action.listTitle, boardId}); listId = list._id; } - const maxOrder = _.max(list.cards(card.swimlaneId).map((c) => c.sort)); + const maxOrder = _.max(list.cardsUnfiltered(card.swimlaneId).map((c) => c.sort)); card.move(card.swimlaneId, listId, maxOrder + 1); } if(action.actionType === 'sendEmail'){ @@ -87,7 +87,7 @@ RulesHelper = { card.removeLabel(action.labelId); } if(action.actionType === 'addMember'){ - const memberId = Users.findOne({username:action.memberName})._id; + const memberId = Users.findOne({username:action.username})._id; card.assignMember(memberId); } if(action.actionType === 'removeMember'){ @@ -97,7 +97,7 @@ RulesHelper = { card.unassignMember(members[i]); } }else{ - const memberId = Users.findOne({username:action.memberName})._id; + const memberId = Users.findOne({username:action.username})._id; card.unassignMember(memberId); } } diff --git a/server/triggersDef.js b/server/triggersDef.js index 81dc946f..f6d5333b 100644 --- a/server/triggersDef.js +++ b/server/triggersDef.js @@ -12,10 +12,10 @@ TriggersDef = { matchingFields: ['boardId'], }, joinMember:{ - matchingFields: ['boardId', 'memberId'], + matchingFields: ['boardId', 'username'], }, unjoinMember:{ - matchingFields: ['boardId', 'memberId'], + matchingFields: ['boardId', 'username'], }, addChecklist:{ matchingFields: ['boardId', 'checklistName'], |