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 | |
parent | 30a3daa6af179009ac17b40a71bf3f9e9b1d698a (diff) | |
download | wekan-25da8376ca2ee3b7bedadf924557d4d7bb6c6771.tar.gz wekan-25da8376ca2ee3b7bedadf924557d4d7bb6c6771.tar.bz2 wekan-25da8376ca2ee3b7bedadf924557d4d7bb6c6771.zip |
Beautyfied
Diffstat (limited to 'client')
-rw-r--r-- | client/components/rules/actions/boardActions.js | 170 | ||||
-rw-r--r-- | client/components/rules/actions/cardActions.js | 155 | ||||
-rw-r--r-- | client/components/rules/actions/checklistActions.js | 178 | ||||
-rw-r--r-- | client/components/rules/actions/mailActions.js | 42 | ||||
-rw-r--r-- | client/components/rules/ruleDetails.js | 33 | ||||
-rw-r--r-- | client/components/rules/rulesActions.js | 37 | ||||
-rw-r--r-- | client/components/rules/rulesList.js | 6 | ||||
-rw-r--r-- | client/components/rules/rulesMain.js | 72 | ||||
-rw-r--r-- | client/components/rules/rulesTriggers.js | 29 | ||||
-rw-r--r-- | client/components/rules/triggers/boardTriggers.js | 140 | ||||
-rw-r--r-- | client/components/rules/triggers/checklistTriggers.js | 220 | ||||
-rw-r--r-- | client/lib/utils.js | 52 |
12 files changed, 702 insertions, 432 deletions
diff --git a/client/components/rules/actions/boardActions.js b/client/components/rules/actions/boardActions.js index 0394f601..3eda039f 100644 --- a/client/components/rules/actions/boardActions.js +++ b/client/components/rules/actions/boardActions.js @@ -3,63 +3,119 @@ BlazeComponent.extendComponent({ }, - - events() { - return [ - {'click .js-add-spec-move-action'(event) { - const ruleName = this.data().ruleName.get(); - const trigger = this.data().triggerVar.get(); - 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,"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,"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,"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,"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,"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,"desc":desc}); - Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); - } -}, -}]; -}, + return [{ + 'click .js-add-spec-move-action' (event) { + const ruleName = this.data().ruleName.get(); + const trigger = this.data().triggerVar.get(); + 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, + "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, + "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, + "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, + "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, + "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, + "desc": desc + }); + Rules.insert({ + title: ruleName, + triggerId: triggerId, + actionId: actionId, + "boardId": boardId + }); + } + }, + }]; + }, }).register('boardActions');
\ No newline at end of file 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 diff --git a/client/components/rules/actions/checklistActions.js b/client/components/rules/actions/checklistActions.js index bfc07623..0b4c2167 100644 --- a/client/components/rules/actions/checklistActions.js +++ b/client/components/rules/actions/checklistActions.js @@ -3,64 +3,126 @@ BlazeComponent.extendComponent({ this.subscribe('allRules'); }, events() { - return [ - {'click .js-add-checklist-action'(event) { - const ruleName = this.data().ruleName.get(); - const trigger = this.data().triggerVar.get(); - 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,"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,"desc":desc}); - Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); - } + return [{ + 'click .js-add-checklist-action' (event) { + const ruleName = this.data().ruleName.get(); + const trigger = this.data().triggerVar.get(); + 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, + "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, + "desc": desc + }); + Rules.insert({ + title: ruleName, + triggerId: triggerId, + actionId: actionId, + "boardId": boardId + }); + } - }, - 'click .js-add-checkall-action'(event) { - const ruleName = this.data().ruleName.get(); - const trigger = this.data().triggerVar.get(); - 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,"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,"desc":desc}); - Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); - } - }, - 'click .js-add-check-item-action'(event) { - const ruleName = this.data().ruleName.get(); - const trigger = this.data().triggerVar.get(); - const checkItemName = this.find("#checkitem-name"); - 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,"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,"desc":desc}); - Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId}); - } -}, -}]; -}, + }, + 'click .js-add-checkall-action' (event) { + const ruleName = this.data().ruleName.get(); + const trigger = this.data().triggerVar.get(); + 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, + "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, + "desc": desc + }); + Rules.insert({ + title: ruleName, + triggerId: triggerId, + actionId: actionId, + "boardId": boardId + }); + } + }, + 'click .js-add-check-item-action' (event) { + const ruleName = this.data().ruleName.get(); + const trigger = this.data().triggerVar.get(); + const checkItemName = this.find("#checkitem-name"); + 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, + "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, + "desc": desc + }); + Rules.insert({ + title: ruleName, + triggerId: triggerId, + actionId: actionId, + "boardId": boardId + }); + } + }, + }]; + }, }).register('checklistActions');
\ No newline at end of file diff --git a/client/components/rules/actions/mailActions.js b/client/components/rules/actions/mailActions.js index 65b8a2d8..dae7d08d 100644 --- a/client/components/rules/actions/mailActions.js +++ b/client/components/rules/actions/mailActions.js @@ -4,20 +4,32 @@ BlazeComponent.extendComponent({ }, events() { - return [ - {'click .js-mail-action'(event) { - const emailTo = this.find('#email-to').value; - const emailSubject = this.find('#email-subject').value; - const emailMsg = this.find('#email-msg').value; - const trigger = this.data().triggerVar.get(); - const ruleName = this.data().ruleName.get(); - const triggerId = Triggers.insert(trigger); - const boardId = Session.get('currentBoard'); - 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}); - }, - }]; -}, + return [{ + 'click .js-mail-action' (event) { + const emailTo = this.find('#email-to').value; + const emailSubject = this.find('#email-subject').value; + const emailMsg = this.find('#email-msg').value; + const trigger = this.data().triggerVar.get(); + const ruleName = this.data().ruleName.get(); + const triggerId = Triggers.insert(trigger); + const boardId = Session.get('currentBoard'); + 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 + }); + }, + }]; + }, }).register('mailActions');
\ No newline at end of file diff --git a/client/components/rules/ruleDetails.js b/client/components/rules/ruleDetails.js index 872fec2d..385b0bae 100644 --- a/client/components/rules/ruleDetails.js +++ b/client/components/rules/ruleDetails.js @@ -6,32 +6,31 @@ BlazeComponent.extendComponent({ }, - trigger(){ + trigger() { const ruleId = this.data().ruleId; - const rule = Rules.findOne({_id: ruleId.get()}); - const trigger = Triggers.findOne({_id:rule.triggerId}); + const rule = Rules.findOne({ + _id: ruleId.get() + }); + const trigger = Triggers.findOne({ + _id: rule.triggerId + }); console.log(trigger); return trigger.description(); }, - action(){ + action() { const ruleId = this.data().ruleId; - const rule = Rules.findOne({_id: ruleId.get()}); - const action = Actions.findOne({_id:rule.actionId}); + const rule = Rules.findOne({ + _id: ruleId.get() + }); + const action = Actions.findOne({ + _id: rule.actionId + }); console.log(action); return action.description(); }, events() { - return [{ - }]; + return [{}]; }, -}).register('ruleDetails'); - - - - - - - - +}).register('ruleDetails');
\ No newline at end of file diff --git a/client/components/rules/rulesActions.js b/client/components/rules/rulesActions.js index bf8d222d..d492cbd5 100644 --- a/client/components/rules/rulesActions.js +++ b/client/components/rules/rulesActions.js @@ -3,29 +3,28 @@ BlazeComponent.extendComponent({ this.currentActions = new ReactiveVar("board"); }, - - setBoardActions(){ + setBoardActions() { this.currentActions.set("board"); $('.js-set-card-actions').removeClass('active'); $('.js-set-board-actions').addClass('active'); $('.js-set-checklist-actions').removeClass('active'); $('.js-set-mail-actions').removeClass('active'); }, - setCardActions(){ + setCardActions() { this.currentActions.set("card"); $('.js-set-card-actions').addClass('active'); $('.js-set-board-actions').removeClass('active'); $('.js-set-checklist-actions').removeClass('active'); $('.js-set-mail-actions').removeClass('active'); }, - setChecklistActions(){ + setChecklistActions() { this.currentActions.set("checklist"); $('.js-set-card-actions').removeClass('active'); $('.js-set-board-actions').removeClass('active'); $('.js-set-checklist-actions').addClass('active'); $('.js-set-mail-actions').removeClass('active'); }, - setMailActions(){ + setMailActions() { this.currentActions.set("mail"); $('.js-set-card-actions').removeClass('active'); $('.js-set-board-actions').removeClass('active'); @@ -37,21 +36,23 @@ BlazeComponent.extendComponent({ return Rules.find({}); }, - name(){ + name() { console.log(this.data()); }, events() { - return [{'click .js-set-board-actions'(event) { - this.setBoardActions(); - }, - 'click .js-set-card-actions'(event) { - this.setCardActions(); - }, - 'click .js-set-mail-actions'(event) { - this.setMailActions(); - }, - 'click .js-set-checklist-actions'(event) { - this.setChecklistActions(); - },}]; + return [{ + 'click .js-set-board-actions' (event) { + this.setBoardActions(); + }, + 'click .js-set-card-actions' (event) { + this.setCardActions(); + }, + 'click .js-set-mail-actions' (event) { + this.setMailActions(); + }, + 'click .js-set-checklist-actions' (event) { + this.setChecklistActions(); + }, + }]; }, }).register('rulesActions');
\ No newline at end of file diff --git a/client/components/rules/rulesList.js b/client/components/rules/rulesList.js index 9b97a7c8..e7b4660a 100644 --- a/client/components/rules/rulesList.js +++ b/client/components/rules/rulesList.js @@ -4,8 +4,10 @@ BlazeComponent.extendComponent({ }, rules() { - const boardId = Session.get('currentBoard'); - return Rules.find({"boardId":boardId}); + const boardId = Session.get('currentBoard'); + return Rules.find({ + "boardId": boardId + }); }, events() { return [{}]; diff --git a/client/components/rules/rulesMain.js b/client/components/rules/rulesMain.js index d16b9a41..e4cac03d 100644 --- a/client/components/rules/rulesMain.js +++ b/client/components/rules/rulesMain.js @@ -22,45 +22,37 @@ BlazeComponent.extendComponent({ }, events() { - return [{'click .js-delete-rule'(event) { - const rule = this.currentData(); - Rules.remove(rule._id); - Actions.remove(rule.actionId); - Triggers.remove(rule.triggerId); - - }, - 'click .js-goto-trigger'(event) { - event.preventDefault(); - const ruleTitle = this.find('#ruleTitle').value; - this.find('#ruleTitle').value = ""; - this.ruleName.set(ruleTitle) - this.setTrigger(); - }, - 'click .js-goto-action'(event) { - event.preventDefault(); - this.setAction(); - }, - 'click .js-goto-rules'(event) { - event.preventDefault(); - this.setRulesList(); - }, - 'click .js-goto-details'(event) { - event.preventDefault(); - const rule = this.currentData(); - this.ruleId.set(rule._id) - this.setRuleDetails(); - }, - - - }]; + return [{ + 'click .js-delete-rule' (event) { + const rule = this.currentData(); + Rules.remove(rule._id); + Actions.remove(rule.actionId); + Triggers.remove(rule.triggerId); + + }, + 'click .js-goto-trigger' (event) { + event.preventDefault(); + const ruleTitle = this.find('#ruleTitle').value; + this.find('#ruleTitle').value = ""; + this.ruleName.set(ruleTitle) + this.setTrigger(); + }, + 'click .js-goto-action' (event) { + event.preventDefault(); + this.setAction(); + }, + 'click .js-goto-rules' (event) { + event.preventDefault(); + this.setRulesList(); + }, + 'click .js-goto-details' (event) { + event.preventDefault(); + const rule = this.currentData(); + this.ruleId.set(rule._id) + this.setRuleDetails(); + }, + + }]; }, -}).register('rulesMain'); - - - - - - - - +}).register('rulesMain');
\ No newline at end of file diff --git a/client/components/rules/rulesTriggers.js b/client/components/rules/rulesTriggers.js index 0a4abd66..f9dd4ecc 100644 --- a/client/components/rules/rulesTriggers.js +++ b/client/components/rules/rulesTriggers.js @@ -5,8 +5,7 @@ BlazeComponent.extendComponent({ this.showChecklistTrigger = new ReactiveVar(false); }, - - setBoardTriggers(){ + setBoardTriggers() { this.showBoardTrigger.set(true); this.showCardTrigger.set(false); this.showChecklistTrigger.set(false); @@ -14,7 +13,7 @@ BlazeComponent.extendComponent({ $('.js-set-board-triggers').addClass('active'); $('.js-set-checklist-triggers').removeClass('active'); }, - setCardTriggers(){ + setCardTriggers() { this.showBoardTrigger.set(false); this.showCardTrigger.set(true); this.showChecklistTrigger.set(false); @@ -22,7 +21,7 @@ BlazeComponent.extendComponent({ $('.js-set-board-triggers').removeClass('active'); $('.js-set-checklist-triggers').removeClass('active'); }, - setChecklistTriggers(){ + setChecklistTriggers() { this.showBoardTrigger.set(false); this.showCardTrigger.set(false); this.showChecklistTrigger.set(true); @@ -35,18 +34,20 @@ BlazeComponent.extendComponent({ return Rules.find({}); }, - name(){ + name() { console.log(this.data()); }, events() { - return [{'click .js-set-board-triggers'(event) { - this.setBoardTriggers(); - }, - 'click .js-set-card-triggers'(event) { - this.setCardTriggers(); - }, - 'click .js-set-checklist-triggers'(event) { - this.setChecklistTriggers(); - },}]; + return [{ + 'click .js-set-board-triggers' (event) { + this.setBoardTriggers(); + }, + 'click .js-set-card-triggers' (event) { + this.setCardTriggers(); + }, + 'click .js-set-checklist-triggers' (event) { + this.setChecklistTriggers(); + }, + }]; }, }).register('rulesTriggers');
\ No newline at end of file diff --git a/client/components/rules/triggers/boardTriggers.js b/client/components/rules/triggers/boardTriggers.js index 067c1df8..95c10a5b 100644 --- a/client/components/rules/triggers/boardTriggers.js +++ b/client/components/rules/triggers/boardTriggers.js @@ -4,60 +4,98 @@ BlazeComponent.extendComponent({ }, events() { - return [ - {'click .js-add-gen-trigger'(event) { - const desc = Utils.getTriggerActionDesc(event,this); - let datas = this.data(); - const actionSelected = this.find('#gen-action').value; - const boardId = Session.get('currentBoard') - if(actionSelected == "created"){ - datas.triggerVar.set({activityType: "createCard","boardId":boardId,"listName":"*","desc":desc}); - } - if(actionSelected == "removed"){ - datas.triggerVar.set({activityType: "removeCard","boardId":boardId,"desc":desc}); - } - + return [{ + 'click .js-add-gen-trigger' (event) { + const desc = Utils.getTriggerActionDesc(event, this); + let datas = this.data(); + const actionSelected = this.find('#gen-action').value; + const boardId = Session.get('currentBoard') + if (actionSelected == "created") { + datas.triggerVar.set({ + activityType: "createCard", + "boardId": boardId, + "listName": "*", + "desc": desc + }); + } + if (actionSelected == "removed") { + datas.triggerVar.set({ + activityType: "removeCard", + "boardId": boardId, + "desc": desc + }); + } - }, - 'click .js-add-create-trigger'(event) { - const desc = Utils.getTriggerActionDesc(event,this); - let datas = this.data(); - const actionSelected = this.find('#create-action').value; - const listName = this.find('#create-list-name').value; - const boardId = Session.get('currentBoard') - if(actionSelected == "created"){ - datas.triggerVar.set({activityType: "createCard","boardId":boardId,"listName":listName,"desc":desc}); - } - if(actionSelected == "removed"){ - datas.triggerVar.set({activityType: "removeCard","boardId":boardId,"listName":listName,"desc":desc}); - } - }, - 'click .js-add-moved-trigger'(event) { - let datas = this.data(); - const desc = Utils.getTriggerActionDesc(event,this); + }, + 'click .js-add-create-trigger' (event) { + const desc = Utils.getTriggerActionDesc(event, this); + let datas = this.data(); + const actionSelected = this.find('#create-action').value; + const listName = this.find('#create-list-name').value; + const boardId = Session.get('currentBoard') + if (actionSelected == "created") { + datas.triggerVar.set({ + activityType: "createCard", + "boardId": boardId, + "listName": listName, + "desc": desc + }); + } + if (actionSelected == "removed") { + datas.triggerVar.set({ + activityType: "removeCard", + "boardId": boardId, + "listName": listName, + "desc": desc + }); + } + }, + 'click .js-add-moved-trigger' (event) { + let datas = this.data(); + const desc = Utils.getTriggerActionDesc(event, this); - const actionSelected = this.find('#move-action').value; - const listName = this.find('#move-list-name').value; - const boardId = Session.get('currentBoard') - if(actionSelected == "moved-to"){ - datas.triggerVar.set({activityType: "moveCard","boardId":boardId,"listName":listName,"oldListName":"*","desc":desc}); - } - if(actionSelected == "moved-from"){ - datas.triggerVar.set({activityType: "moveCard","boardId":boardId,"listName":"*","oldListName":listName,"desc":desc}); - } - }, - 'click .js-add-arc-trigger'(event) { - let datas = this.data(); - const desc = Utils.getTriggerActionDesc(event,this); - const actionSelected = this.find('#arch-action').value; - const boardId = Session.get('currentBoard') - if(actionSelected == "archived"){ - datas.triggerVar.set({activityType: "archivedCard","boardId":boardId,"desc":desc}); - } - if(actionSelected == "unarchived"){ - datas.triggerVar.set({activityType: "restoredCard","boardId":boardId,"desc":desc}); + const actionSelected = this.find('#move-action').value; + const listName = this.find('#move-list-name').value; + const boardId = Session.get('currentBoard') + if (actionSelected == "moved-to") { + datas.triggerVar.set({ + activityType: "moveCard", + "boardId": boardId, + "listName": listName, + "oldListName": "*", + "desc": desc + }); + } + if (actionSelected == "moved-from") { + datas.triggerVar.set({ + activityType: "moveCard", + "boardId": boardId, + "listName": "*", + "oldListName": listName, + "desc": desc + }); + } + }, + 'click .js-add-arc-trigger' (event) { + let datas = this.data(); + const desc = Utils.getTriggerActionDesc(event, this); + const actionSelected = this.find('#arch-action').value; + const boardId = Session.get('currentBoard') + if (actionSelected == "archived") { + datas.triggerVar.set({ + activityType: "archivedCard", + "boardId": boardId, + "desc": desc + }); + } + if (actionSelected == "unarchived") { + datas.triggerVar.set({ + activityType: "restoredCard", + "boardId": boardId, + "desc": desc + }); + } } - } }]; }, diff --git a/client/components/rules/triggers/checklistTriggers.js b/client/components/rules/triggers/checklistTriggers.js index 15a1cf34..6e7b3445 100644 --- a/client/components/rules/triggers/checklistTriggers.js +++ b/client/components/rules/triggers/checklistTriggers.js @@ -3,86 +3,144 @@ BlazeComponent.extendComponent({ this.subscribe('allRules'); }, 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":"*","desc":desc}); - } - if(actionSelected == "removed"){ - 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,"desc":desc}); - } - if(actionSelected == "removed"){ - 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":"*","desc":desc}); - } - if(actionSelected == "uncompleted"){ - 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,"desc":desc}); - } - if(actionSelected == "removed"){ - 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":"*","desc":desc}); - } - if(actionSelected == "unchecked"){ - 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,"desc":desc}); - } - if(actionSelected == "unchecked"){ - datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":checklistItemId,"desc":desc}); - } - }, - }]; -}, - -}).register('checklistTriggers'); + 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": "*", + "desc": desc + }); + } + if (actionSelected == "removed") { + 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, + "desc": desc + }); + } + if (actionSelected == "removed") { + 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": "*", + "desc": desc + }); + } + if (actionSelected == "uncompleted") { + 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, + "desc": desc + }); + } + if (actionSelected == "removed") { + 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": "*", + "desc": desc + }); + } + if (actionSelected == "unchecked") { + 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, + "desc": desc + }); + } + if (actionSelected == "unchecked") { + datas.triggerVar.set({ + activityType: "uncheckedItem", + "boardId": boardId, + "checklistItemName": checklistItemId, + "desc": desc + }); + } + }, + }]; + }, +}).register('checklistTriggers');
\ No newline at end of file diff --git a/client/lib/utils.js b/client/lib/utils.js index e6dc7d85..44ca3a4a 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -39,15 +39,15 @@ Utils = { if (!prevData && !nextData) { base = 0; increment = 1; - // If we drop the card in the first position - } else if (!prevData) { - base = nextData.sort - 1; - increment = -1; - // If we drop the card in the last position - } else if (!nextData) { - base = prevData.sort + 1; - increment = 1; - } + // If we drop the card in the first position + } else if (!prevData) { + base = nextData.sort - 1; + increment = -1; + // If we drop the card in the last position + } else if (!nextData) { + base = prevData.sort + 1; + increment = 1; + } // In the general case take the average of the previous and next element // sort indexes. else { @@ -71,15 +71,15 @@ Utils = { if (!prevCardDomElement && !nextCardDomElement) { base = 0; increment = 1; - // If we drop the card in the first position - } else if (!prevCardDomElement) { - base = Blaze.getData(nextCardDomElement).sort - 1; - increment = -1; - // If we drop the card in the last position - } else if (!nextCardDomElement) { - base = Blaze.getData(prevCardDomElement).sort + 1; - increment = 1; - } + // If we drop the card in the first position + } else if (!prevCardDomElement) { + base = Blaze.getData(nextCardDomElement).sort - 1; + increment = -1; + // If we drop the card in the last position + } else if (!nextCardDomElement) { + base = Blaze.getData(prevCardDomElement).sort + 1; + increment = 1; + } // In the general case take the average of the previous and next element // sort indexes. else { @@ -121,7 +121,7 @@ Utils = { return Math.sqrt( Math.pow(touchA.screenX - touchB.screenX, 2) + Math.pow(touchA.screenY - touchB.screenY, 2) - ); + ); }, enableClickOnTouch(selector) { @@ -145,21 +145,21 @@ Utils = { }); }, - getTriggerActionDesc(event,tempInstance){ + getTriggerActionDesc(event, tempInstance) { const jqueryEl = tempInstance.$(event.currentTarget.parentNode); const triggerEls = jqueryEl.find(".trigger-content").children(); let finalString = ""; - for(let i = 0;i< triggerEls.length;i++){ + for (let i = 0; i < triggerEls.length; i++) { const element = tempInstance.$(triggerEls[i]); - if(element.hasClass("trigger-text")){ + if (element.hasClass("trigger-text")) { finalString += element.text().toLowerCase(); - }else if(element.find("select").length > 0){ + } else if (element.find("select").length > 0) { finalString += element.find("select option:selected").text().toLowerCase(); - }else if(element.find("input").length > 0){ + } else if (element.find("input").length > 0) { finalString += element.find("input").val(); } // Add space - if(i != length - 1){ + if (i != length - 1) { finalString += " "; } } @@ -171,4 +171,4 @@ Utils = { // resized. This is used to reactively re-calculate the popup position in case // of a window resize. This is the equivalent of a "Signal" in some other // programming environments (eg, elm). -$(window).on('resize', () => Utils.windowResizeDep.changed()); +$(window).on('resize', () => Utils.windowResizeDep.changed());
\ No newline at end of file |