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 | |
parent | fc73dc5bbcbbd203efc4f10ecb4bd1a66e0d9efb (diff) | |
download | wekan-30a3daa6af179009ac17b40a71bf3f9e9b1d698a.tar.gz wekan-30a3daa6af179009ac17b40a71bf3f9e9b1d698a.tar.bz2 wekan-30a3daa6af179009ac17b40a71bf3f9e9b1d698a.zip |
Finished alpha rules
-rw-r--r-- | client/components/rules/actions/boardActions.js | 16 | ||||
-rw-r--r-- | client/components/rules/actions/cardActions.js | 58 | ||||
-rw-r--r-- | client/components/rules/actions/checklistActions.js | 16 | ||||
-rw-r--r-- | client/components/rules/actions/mailActions.js | 3 | ||||
-rw-r--r-- | client/components/rules/ruleDetails.jade | 15 | ||||
-rw-r--r-- | client/components/rules/triggers/cardTriggers.js | 184 | ||||
-rw-r--r-- | client/components/rules/triggers/checklistTriggers.js | 36 | ||||
-rw-r--r-- | client/lib/utils.js | 6 | ||||
-rw-r--r-- | models/actions.js | 80 | ||||
-rw-r--r-- | models/triggers.js | 112 | ||||
-rw-r--r-- | server/rulesHelper.js | 11 |
11 files changed, 234 insertions, 303 deletions
diff --git a/client/components/rules/actions/boardActions.js b/client/components/rules/actions/boardActions.js index d1593a5b..0394f601 100644 --- a/client/components/rules/actions/boardActions.js +++ b/client/components/rules/actions/boardActions.js @@ -13,47 +13,49 @@ BlazeComponent.extendComponent({ const actionSelected = this.find('#move-spec-action').value; const listTitle = this.find('#listName').value; const boardId = Session.get('currentBoard'); - + const desc = Utils.getTriggerActionDesc(event,this); if(actionSelected == "top"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":listTitle,"boardId":boardId}); + const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":listTitle,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } if(actionSelected == "bottom"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "moveCardToBottom","listTitle":listTitle,"boardId":boardId}); + const actionId = Actions.insert({actionType: "moveCardToBottom","listTitle":listTitle,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } }, 'click .js-add-gen-move-action'(event) { + const desc = Utils.getTriggerActionDesc(event,this); const boardId = Session.get('currentBoard'); const ruleName = this.data().ruleName.get(); const trigger = this.data().triggerVar.get(); const actionSelected = this.find('#move-gen-action').value; if(actionSelected == "top"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":"*","boardId":boardId}); + const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":"*","boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } if(actionSelected == "bottom"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "moveCardToBottom","listTitle":"*","boardId":boardId}); + const actionId = Actions.insert({actionType: "moveCardToBottom","listTitle":"*","boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } }, 'click .js-add-arch-action'(event) { + const desc = Utils.getTriggerActionDesc(event,this); const boardId = Session.get('currentBoard'); const ruleName = this.data().ruleName.get(); const trigger = this.data().triggerVar.get(); const actionSelected = this.find('#arch-action').value; if(actionSelected == "archive"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "archive","boardId":boardId}); + const actionId = Actions.insert({actionType: "archive","boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } if(actionSelected == "unarchive"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "unarchive","boardId":boardId}); + const actionId = Actions.insert({actionType: "unarchive","boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } }, diff --git a/client/components/rules/actions/cardActions.js b/client/components/rules/actions/cardActions.js index 3f4b4442..0bf7428a 100644 --- a/client/components/rules/actions/cardActions.js +++ b/client/components/rules/actions/cardActions.js @@ -24,45 +24,47 @@ BlazeComponent.extendComponent({ const actionSelected = this.find('#label-action').value; const labelId = this.find('#label-id').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: "addLabel","labelId":labelId,"boardId":boardId}); + const actionId = Actions.insert({actionType: "addLabel","labelId":labelId,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } if(actionSelected == "remove"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "removeLabel","labelId":labelId,"boardId":boardId}); + const actionId = Actions.insert({actionType: "removeLabel","labelId":labelId,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } }, 'click .js-add-member-action'(event) { - 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 boardId = Session.get('currentBoard'); - if(actionSelected == "add"){ - const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "addMember","memberName":memberName,"boardId":boardId}); - Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); - } - if(actionSelected == "remove"){ - const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "removeMember","memberName":memberName,"boardId":boardId}); - Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); - } - }, - 'click .js-add-removeall-action'(event) { - const ruleName = this.data().ruleName.get(); - const trigger = this.data().triggerVar.get(); - const triggerId = Triggers.insert(trigger); - const boardId = Session.get('currentBoard'); - const actionId = Actions.insert({actionType: "removeMember","memberName":"*","boardId":boardId}); - Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); - }, - }]; + 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 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":memberName,"boardId":boardId,"desc":desc}); + Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId,"desc":desc}); + } + if(actionSelected == "remove"){ + const triggerId = Triggers.insert(trigger); + const actionId = Actions.insert({actionType: "removeMember","memberName":memberName,"boardId":boardId,"desc":desc}); + Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); + } + }, + 'click .js-add-removeall-action'(event) { + const ruleName = this.data().ruleName.get(); + const trigger = this.data().triggerVar.get(); + const triggerId = Triggers.insert(trigger); + const desc = Utils.getTriggerActionDesc(event,this); + const boardId = Session.get('currentBoard'); + const actionId = Actions.insert({actionType: "removeMember","memberName":"*","boardId":boardId,"desc":desc}); + Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); +}, +}]; }, }).register('cardActions');
\ No newline at end of file diff --git a/client/components/rules/actions/checklistActions.js b/client/components/rules/actions/checklistActions.js index e6989fc6..bfc07623 100644 --- a/client/components/rules/actions/checklistActions.js +++ b/client/components/rules/actions/checklistActions.js @@ -10,15 +10,15 @@ BlazeComponent.extendComponent({ const actionSelected = this.find('#check-action').value; const checklistName = this.find('#checklist-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: "addChecklist","checklistName":checklistName,"boardId":boardId}); + const actionId = Actions.insert({actionType: "addChecklist","checklistName":checklistName,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } if(actionSelected == "remove"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "removeChecklist","checklistName":checklistName,"boardId":boardId}); + const actionId = Actions.insert({actionType: "removeChecklist","checklistName":checklistName,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } @@ -29,14 +29,15 @@ BlazeComponent.extendComponent({ const actionSelected = this.find('#checkall-action').value; const checklistName = this.find('#checklist-name2').value; const boardId = Session.get('currentBoard'); + const desc = Utils.getTriggerActionDesc(event,this); if(actionSelected == "check"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "checkAll","checklistName":checklistName,"boardId":boardId}); + const actionId = Actions.insert({actionType: "checkAll","checklistName":checklistName,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } if(actionSelected == "uncheck"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "uncheckAll","checklistName":checklistName,"boardId":boardId}); + const actionId = Actions.insert({actionType: "uncheckAll","checklistName":checklistName,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } }, @@ -47,14 +48,15 @@ BlazeComponent.extendComponent({ const checklistName = this.find("#checklist-name3"); const actionSelected = this.find('#check-item-action').value; const boardId = Session.get('currentBoard'); + const desc = Utils.getTriggerActionDesc(event,this); if(actionSelected == "check"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "checkItem","checklistName":checklistName,"checkItemName":checkItemName,"boardId":boardId}); + const actionId = Actions.insert({actionType: "checkItem","checklistName":checklistName,"checkItemName":checkItemName,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } if(actionSelected == "uncheck"){ const triggerId = Triggers.insert(trigger); - const actionId = Actions.insert({actionType: "uncheckItem","checklistName":checklistName,"checkItemName":checkItemName,"boardId":boardId}); + const actionId = Actions.insert({actionType: "uncheckItem","checklistName":checklistName,"checkItemName":checkItemName,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); } }, diff --git a/client/components/rules/actions/mailActions.js b/client/components/rules/actions/mailActions.js index 74f6659b..65b8a2d8 100644 --- a/client/components/rules/actions/mailActions.js +++ b/client/components/rules/actions/mailActions.js @@ -13,7 +13,8 @@ BlazeComponent.extendComponent({ const ruleName = this.data().ruleName.get(); const triggerId = Triggers.insert(trigger); const boardId = Session.get('currentBoard'); - const actionId = Actions.insert({actionType: "sendEmail","emailTo":emailTo,"emailSubject":emailSubject,"emailMsg":emailMsg,"boardId":boardId}); + const desc = Utils.getTriggerActionDesc(event,this); + const actionId = Actions.insert({actionType: "sendEmail","emailTo":emailTo,"emailSubject":emailSubject,"emailMsg":emailMsg,"boardId":boardId,"desc":desc}); Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); }, }]; diff --git a/client/components/rules/ruleDetails.jade b/client/components/rules/ruleDetails.jade index 479553d1..b9a1351c 100644 --- a/client/components/rules/ruleDetails.jade +++ b/client/components/rules/ruleDetails.jade @@ -3,5 +3,16 @@ template(name="ruleDetails") h2 i.fa.fa-magic | {{{_ 'r-rule-details' }}} - = trigger - = action
\ No newline at end of file + .triggers-content + .triggers-body + .triggers-main-body + div.trigger-item + div.trigger-content + div.trigger-text + = trigger + div.trigger-item + div.trigger-content + div.trigger-text + = action + +
\ No newline at end of file diff --git a/client/components/rules/triggers/cardTriggers.js b/client/components/rules/triggers/cardTriggers.js index e860d806..c0a5ec1a 100644 --- a/client/components/rules/triggers/cardTriggers.js +++ b/client/components/rules/triggers/cardTriggers.js @@ -2,12 +2,11 @@ BlazeComponent.extendComponent({ onCreated() { this.subscribe('allRules'); }, - - labels(){ + labels() { const labels = Boards.findOne(Session.get('currentBoard')).labels; console.log(labels); - for(let i = 0;i<labels.length;i++){ - if(labels[i].name == "" || labels[i].name == undefined){ + for (let i = 0; i < labels.length; i++) { + if (labels[i].name == "" || labels[i].name == undefined) { labels[i].name = labels[i].color.toUpperCase(); } } @@ -15,70 +14,117 @@ BlazeComponent.extendComponent({ return labels; }, events() { - return [ - {'click .js-add-gen-label-trigger'(event) { - - let datas = this.data(); - const actionSelected = this.find('#label-action').value; - const boardId = Session.get('currentBoard') - if(actionSelected == "added"){ - datas.triggerVar.set({activityType: "addedLabel","boardId":boardId,"labelId":"*"}); - } - if(actionSelected == "removed"){ - datas.triggerVar.set({activityType: "removedLabel","boardId":boardId,"labelId":"*"}); - } - }, - 'click .js-add-spec-label-trigger'(event) { - let datas = this.data(); - const actionSelected = this.find('#spec-label-action').value; - const labelId = this.find('#spec-label').value; - const boardId = Session.get('currentBoard') - if(actionSelected == "added"){ - datas.triggerVar.set({activityType: "addedLabel","boardId":boardId,"labelId":labelId}); - } - if(actionSelected == "removed"){ - datas.triggerVar.set({activityType: "removedLabel","boardId":boardId,"labelId":labelId}); - } - }, - 'click .js-add-gen-member-trigger'(event) { - - let datas = this.data(); - const actionSelected = this.find('#gen-member-action').value; - const boardId = Session.get('currentBoard') - if(actionSelected == "added"){ - datas.triggerVar.set({activityType: "joinMember","boardId":boardId,"memberId":"*"}); - } - if(actionSelected == "removed"){ - datas.triggerVar.set({activityType: "unjoinMember","boardId":boardId,"memberId":"*"}); - } - }, - 'click .js-add-spec-member-trigger'(event) { - let datas = this.data(); - const actionSelected = this.find('#spec-member-action').value; - const memberId = this.find('#spec-member').value; - const boardId = Session.get('currentBoard') - if(actionSelected == "added"){ - datas.triggerVar.set({activityType: "joinMember","boardId":boardId,"memberId":memberId}); - } - if(actionSelected == "removed"){ - datas.triggerVar.set({activityType: "unjoinMember","boardId":boardId,"memberId":memberId}); - } - }, - 'click .js-add-attachment-trigger'(event) { - - let datas = this.data(); - const actionSelected = this.find('#attach-action').value; - const boardId = Session.get('currentBoard') - if(actionSelected == "added"){ - datas.triggerVar.set({activityType: "addAttachment","boardId":boardId}); - } - if(actionSelected == "removed"){ - datas.triggerVar.set({activityType: "deleteAttachment","boardId":boardId}); - } - }, + return [{ + 'click .js-add-gen-label-trigger' (event) { + const desc = Utils.getTriggerActionDesc(event, this); + let datas = this.data(); + const actionSelected = this.find('#label-action').value; + const boardId = Session.get('currentBoard') + if (actionSelected == "added") { + datas.triggerVar.set({ + activityType: "addedLabel", + "boardId": boardId, + "labelId": "*", + "desc": desc + }); + } + if (actionSelected == "removed") { + datas.triggerVar.set({ + activityType: "removedLabel", + "boardId": boardId, + "labelId": "*", + "desc": desc + }); + } + }, + 'click .js-add-spec-label-trigger' (event) { + const desc = Utils.getTriggerActionDesc(event, this); + let datas = this.data(); + const actionSelected = this.find('#spec-label-action').value; + const labelId = this.find('#spec-label').value; + const boardId = Session.get('currentBoard') + if (actionSelected == "added") { + datas.triggerVar.set({ + activityType: "addedLabel", + "boardId": boardId, + "labelId": labelId, + "desc": desc + }); + } + if (actionSelected == "removed") { + datas.triggerVar.set({ + activityType: "removedLabel", + "boardId": boardId, + "labelId": labelId, + "desc": desc + }); + } + }, + 'click .js-add-gen-member-trigger' (event) { + const desc = Utils.getTriggerActionDesc(event, this); + let datas = this.data(); + const actionSelected = this.find('#gen-member-action').value; + const boardId = Session.get('currentBoard') + if (actionSelected == "added") { + datas.triggerVar.set({ + activityType: "joinMember", + "boardId": boardId, + "memberId": "*", + "desc": desc + }); + } + if (actionSelected == "removed") { + datas.triggerVar.set({ + activityType: "unjoinMember", + "boardId": boardId, + "memberId": "*", + "desc": desc + }); + } + }, + 'click .js-add-spec-member-trigger' (event) { + const desc = Utils.getTriggerActionDesc(event, this); + let datas = this.data(); + const actionSelected = this.find('#spec-member-action').value; + const memberId = this.find('#spec-member').value; + const boardId = Session.get('currentBoard') + if (actionSelected == "added") { + datas.triggerVar.set({ + activityType: "joinMember", + "boardId": boardId, + "memberId": memberId, + "desc": desc + }); + } + if (actionSelected == "removed") { + datas.triggerVar.set({ + activityType: "unjoinMember", + "boardId": boardId, + "memberId": memberId, + "desc": desc + }); + } + }, + 'click .js-add-attachment-trigger' (event) { + const desc = Utils.getTriggerActionDesc(event, this); + let datas = this.data(); + const actionSelected = this.find('#attach-action').value; + const boardId = Session.get('currentBoard') + if (actionSelected == "added") { + datas.triggerVar.set({ + activityType: "addAttachment", + "boardId": boardId, + "desc": desc + }); + } + if (actionSelected == "removed") { + datas.triggerVar.set({ + activityType: "deleteAttachment", + "boardId": boardId, + "desc": desc + }); + } + }, }]; }, - -}).register('cardTriggers'); - - +}).register('cardTriggers');
\ No newline at end of file diff --git a/client/components/rules/triggers/checklistTriggers.js b/client/components/rules/triggers/checklistTriggers.js index b790aff4..15a1cf34 100644 --- a/client/components/rules/triggers/checklistTriggers.js +++ b/client/components/rules/triggers/checklistTriggers.js @@ -5,79 +5,83 @@ BlazeComponent.extendComponent({ events() { return [ {'click .js-add-gen-check-trigger'(event) { - + const desc = Utils.getTriggerActionDesc(event,this); let datas = this.data(); const actionSelected = this.find('#gen-check-action').value; const boardId = Session.get('currentBoard') if(actionSelected == "created"){ - datas.triggerVar.set({activityType: "addChecklist","boardId":boardId,"checklistName":"*"}); + datas.triggerVar.set({activityType: "addChecklist","boardId":boardId,"checklistName":"*","desc":desc}); } if(actionSelected == "removed"){ - datas.triggerVar.set({activityType: "removeChecklist","boardId":boardId,"checklistName":"*"}); + datas.triggerVar.set({activityType: "removeChecklist","boardId":boardId,"checklistName":"*","desc":desc}); } }, 'click .js-add-spec-check-trigger'(event) { + const desc = Utils.getTriggerActionDesc(event,this); let datas = this.data(); const actionSelected = this.find('#spec-check-action').value; const checklistId = this.find('#check-name').value; const boardId = Session.get('currentBoard') if(actionSelected == "created"){ - datas.triggerVar.set({activityType: "addChecklist","boardId":boardId,"checklistName":checklistId}); + datas.triggerVar.set({activityType: "addChecklist","boardId":boardId,"checklistName":checklistId,"desc":desc}); } if(actionSelected == "removed"){ - datas.triggerVar.set({activityType: "removeChecklist","boardId":boardId,"checklistName":checklistId}); + datas.triggerVar.set({activityType: "removeChecklist","boardId":boardId,"checklistName":checklistId,"desc":desc}); } }, 'click .js-add-gen-comp-trigger'(event) { + const desc = Utils.getTriggerActionDesc(event,this); let datas = this.data(); const actionSelected = this.find('#gen-comp-check-action').value; const boardId = Session.get('currentBoard') if(actionSelected == "completed"){ - datas.triggerVar.set({activityType: "completeChecklist","boardId":boardId,"checklistName":"*"}); + datas.triggerVar.set({activityType: "completeChecklist","boardId":boardId,"checklistName":"*","desc":desc}); } if(actionSelected == "uncompleted"){ - datas.triggerVar.set({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":"*"}); + datas.triggerVar.set({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":"*","desc":desc}); } }, 'click .js-add-spec-comp-trigger'(event) { + const desc = Utils.getTriggerActionDesc(event,this); let datas = this.data(); 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"){ - datas.triggerVar.set({activityType: "completeChecklist","boardId":boardId,"checklistName":checklistId}); + datas.triggerVar.set({activityType: "completeChecklist","boardId":boardId,"checklistName":checklistId,"desc":desc}); } if(actionSelected == "removed"){ - datas.triggerVar.set({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":checklistId}); + datas.triggerVar.set({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":checklistId,"desc":desc}); } }, 'click .js-add-gen-check-item-trigger'(event) { - + const desc = Utils.getTriggerActionDesc(event,this); let datas = this.data(); const actionSelected = this.find('#check-item-gen-action').value; const boardId = Session.get('currentBoard') if(actionSelected == "checked"){ - datas.triggerVar.set({activityType: "checkedItem","boardId":boardId,"checklistItemName":"*"}); + datas.triggerVar.set({activityType: "checkedItem","boardId":boardId,"checklistItemName":"*","desc":desc}); } if(actionSelected == "unchecked"){ - datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":"*"}); + datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":"*","desc":desc}); } }, 'click .js-add-spec-check-item-trigger'(event) { + const desc = Utils.getTriggerActionDesc(event,this); let datas = this.data(); const actionSelected = this.find('#check-item-spec-action').value; const checklistItemId = this.find('#check-item-name').value; const boardId = Session.get('currentBoard') if(actionSelected == "checked"){ - datas.triggerVar.set({activityType: "checkedItem","boardId":boardId,"checklistItemName":checklistItemId}); + datas.triggerVar.set({activityType: "checkedItem","boardId":boardId,"checklistItemName":checklistItemId,"desc":desc}); } if(actionSelected == "unchecked"){ - datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":checklistItemId}); + datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":checklistItemId,"desc":desc}); } }, - }]; - }, + }]; +}, }).register('checklistTriggers'); diff --git a/client/lib/utils.js b/client/lib/utils.js index 1b5ad1f3..e6dc7d85 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -152,9 +152,9 @@ Utils = { for(let i = 0;i< triggerEls.length;i++){ const element = tempInstance.$(triggerEls[i]); if(element.hasClass("trigger-text")){ - finalString += element.text(); + finalString += element.text().toLowerCase(); }else if(element.find("select").length > 0){ - finalString += element.find("select option:selected").text(); + finalString += element.find("select option:selected").text().toLowerCase(); }else if(element.find("input").length > 0){ finalString += element.find("input").val(); } @@ -163,7 +163,7 @@ Utils = { finalString += " "; } } - return finalString.toLowerCase(); + return finalString; }, }; diff --git a/models/actions.js b/models/actions.js index fd1d03e0..8062b545 100644 --- a/models/actions.js +++ b/models/actions.js @@ -16,85 +16,7 @@ Actions.allow({ Actions.helpers({ description() { - if(this.actionType == "moveCardToTop"){ - if(this.listTitle == "*"){ - return TAPi18n.__('r-d-move-to-top-gen'); - }else{ - return TAPi18n.__('r-d-move-to-top-spec') + " " + this.listTitle; - } - } - if(this.actionType == "moveCardToBottom"){ - if(this.listTitle == "*"){ - return TAPi18n.__('r-d-move-to-bottom-gen'); - }else{ - return TAPi18n.__('r-d-move-to-bottom-spec') + " " + this.listTitle; - } - } - if(this.actionType == "sendEmail"){ - const to = " " + TAPi18n.__('r-d-send-email-to') + ": " + this.emailTo + ", "; - const subject = TAPi18n.__('r-d-send-email-subject') + ": " + this.emailSubject + ", "; - const message = TAPi18n.__('r-d-send-email-message') + ": " + this.emailMsg; - const total = TAPi18n.__('r-d-send-email') + to + subject + message; - return total; - } - if(this.actionType == "archive"){ - return TAPi18n.__('r-d-archive'); - } - if(this.actionType == "unarchive"){ - return TAPi18n.__('r-d-unarchive'); - } - if(this.actionType == "addLabel"){ - 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; - } - - return TAPi18n.__('r-d-add-label') + ": "+name; - } - if(this.actionType == "removeLabel"){ - 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; - } - return TAPi18n.__('r-d-remove-label') + ": " + name; - } - if(this.actionType == "addMember"){ - return TAPi18n.__('r-d-add-member') + ": " + this.memberName; - } - if(this.actionType == "removeMember"){ - if(this.memberName == "*"){ - return TAPi18n.__('r-d-remove-all-member'); - } - return TAPi18n.__('r-d-remove-member') + ": "+ this.memberName; - } - if(this.actionType == "checkAll"){ - return TAPi18n.__('r-d-check-all') + ": " + this.checklistName; - } - if(this.actionType == "uncheckAll"){ - return TAPi18n.__('r-d-uncheck-all') + ": "+ this.checklistName; - } - if(this.actionType == "checkItem"){ - return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName; - } - if(this.actionType == "uncheckItem"){ - return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName; - } - if(this.actionType == "addChecklist"){ - return TAPi18n.__('r-d-add-checklist') + ": "+ this.checklistName; - } - if(this.actionType == "removeChecklist"){ - return TAPi18n.__('r-d-remove-checklist') + ": "+ this.checklistName; - } - - return "Ops not trigger description"; + return this.desc; } }); 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 diff --git a/server/rulesHelper.js b/server/rulesHelper.js index 28fa59d9..d56b70aa 100644 --- a/server/rulesHelper.js +++ b/server/rulesHelper.js @@ -1,10 +1,7 @@ RulesHelper = { executeRules(activity){ const matchingRules = this.findMatchingRules(activity); - console.log("Matching rules:") - console.log(matchingRules); for(let i = 0;i< matchingRules.length;i++){ - console.log(matchingRules[i]); const action = matchingRules[i].getAction(); this.performAction(activity,action); } @@ -34,11 +31,6 @@ RulesHelper = { return matchingMap; }, performAction(activity,action){ - - console.log("Performing action - Activity"); - console.log(activity); - console.log("Performing action - Action"); - console.log(action); const card = Cards.findOne({_id:activity.cardId}); const boardId = activity.boardId; if(action.actionType == "moveCardToTop"){ @@ -96,14 +88,11 @@ RulesHelper = { } if(action.actionType == "addMember"){ const memberId = Users.findOne({username:action.memberName})._id; - console.log(memberId); card.assignMember(memberId); } if(action.actionType == "removeMember"){ if(action.memberName == "*"){ - console.log(card); const members = card.members; - console.log(members); for(let i = 0;i< members.length;i++){ card.unassignMember(members[i]); } |