diff options
author | Angelo Gallarello <angelo.gallarell@gmail.com> | 2018-09-14 17:39:37 +0200 |
---|---|---|
committer | Angelo Gallarello <angelo.gallarell@gmail.com> | 2018-09-14 17:39:37 +0200 |
commit | 25da8376ca2ee3b7bedadf924557d4d7bb6c6771 (patch) | |
tree | a96f00a3a050ea90385e6cd56cf15516cf4e437e /client/components/rules/actions/cardActions.js | |
parent | 30a3daa6af179009ac17b40a71bf3f9e9b1d698a (diff) | |
download | wekan-25da8376ca2ee3b7bedadf924557d4d7bb6c6771.tar.gz wekan-25da8376ca2ee3b7bedadf924557d4d7bb6c6771.tar.bz2 wekan-25da8376ca2ee3b7bedadf924557d4d7bb6c6771.zip |
Beautyfied
Diffstat (limited to 'client/components/rules/actions/cardActions.js')
-rw-r--r-- | client/components/rules/actions/cardActions.js | 155 |
1 files changed, 102 insertions, 53 deletions
diff --git a/client/components/rules/actions/cardActions.js b/client/components/rules/actions/cardActions.js index 0bf7428a..a6e74fe9 100644 --- a/client/components/rules/actions/cardActions.js +++ b/client/components/rules/actions/cardActions.js @@ -3,10 +3,10 @@ BlazeComponent.extendComponent({ this.subscribe('allRules'); }, - labels(){ + labels() { const labels = Boards.findOne(Session.get('currentBoard')).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(); } } @@ -14,57 +14,106 @@ BlazeComponent.extendComponent({ return labels; }, - - events() { - return [ - {'click .js-add-label-action'(event) { - const ruleName = this.data().ruleName.get(); - const trigger = this.data().triggerVar.get(); - 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,"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,"desc":desc}); - Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); - } + return [{ + 'click .js-add-label-action' (event) { + const ruleName = this.data().ruleName.get(); + const trigger = this.data().triggerVar.get(); + 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, + "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, + "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'); - 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}); -}, -}]; -}, + }, + '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'); + 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 |