summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/components/rules/actions/boardActions.jade30
-rw-r--r--client/components/rules/actions/boardActions.js53
-rw-r--r--client/components/rules/actions/cardActions.jade43
-rw-r--r--client/components/rules/actions/cardActions.js66
-rw-r--r--client/components/rules/actions/checklistActions.jade51
-rw-r--r--client/components/rules/actions/checklistActions.js61
-rw-r--r--client/components/rules/actions/mailActions.jade11
-rw-r--r--client/components/rules/actions/mailActions.js21
-rw-r--r--client/components/rules/rules.styl16
-rw-r--r--client/components/rules/rulesActions.jade18
-rw-r--r--client/components/rules/rulesActions.js69
-rw-r--r--client/components/rules/rulesMain.jade4
-rw-r--r--client/components/rules/rulesMain.js2
-rw-r--r--client/components/rules/triggers/boardTriggers.js32
-rw-r--r--client/components/rules/triggers/cardTriggers.js40
-rw-r--r--client/components/rules/triggers/checklistTriggers.js52
-rw-r--r--models/actions.js4
-rw-r--r--models/checklistItems.js6
-rw-r--r--models/checklists.js12
-rw-r--r--server/notifications/email.js2
-rw-r--r--server/rulesHelper.js119
21 files changed, 553 insertions, 159 deletions
diff --git a/client/components/rules/actions/boardActions.jade b/client/components/rules/actions/boardActions.jade
index fe56c3ee..81b2023d 100644
--- a/client/components/rules/actions/boardActions.jade
+++ b/client/components/rules/actions/boardActions.jade
@@ -4,16 +4,40 @@ template(name="boardActions")
div.trigger-text
| Move card to
div.trigger-dropdown
- select(id="action")
+ select(id="move-gen-action")
+ option(value="top") Top of
+ option(value="bottom") Bottom of
+ div.trigger-text
+ | its list
+ div.trigger-button.js-add-gen-move-action.js-goto-rules
+ i.fa.fa-plus
+
+ div.trigger-item
+ div.trigger-content
+ div.trigger-text
+ | Move card to
+ div.trigger-dropdown
+ select(id="move-spec-action")
option(value="top") Top of
option(value="bottom") Bottom of
div.trigger-text
| list
div.trigger-dropdown
- input(type=text,placeholder="List Name")
- div.trigger-button.js-add-move-action.js-goto-rules
+ input(id="listName",type=text,placeholder="List Name")
+ div.trigger-button.js-add-spec-move-action.js-goto-rules
i.fa.fa-plus
+ div.trigger-item
+ div.trigger-content
+ div.trigger-dropdown
+ select(id="arch-action")
+ option(value="archive") Archive
+ option(value="unarchive") Unarchive
+ div.trigger-text
+ | card
+ div.trigger-button.js-add-arch-action.js-goto-rules
+ i.fa.fa-plus
+
diff --git a/client/components/rules/actions/boardActions.js b/client/components/rules/actions/boardActions.js
index 53325ca0..94c2778d 100644
--- a/client/components/rules/actions/boardActions.js
+++ b/client/components/rules/actions/boardActions.js
@@ -7,23 +7,50 @@ BlazeComponent.extendComponent({
events() {
return [
- {'click .js-add-move-action'(event) {
-
- console.log(this.data());
- console.log(this.data().triggerIdVar.get());
+ {'click .js-add-spec-move-action'(event) {
const ruleName = this.data().ruleName.get();
- const triggerId = this.data().triggerIdVar.get();
- const actionSelected = this.find('#action').value;
-
+ const trigger = this.data().triggerVar.get();
+ const actionSelected = this.find('#move-spec-action').value;
+ const listTitle = this.find('#listName').value;
+ if(actionSelected == "top"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":listTitle});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ if(actionSelected == "bottom"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "moveCardToBottom","listTitle":listTitle});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ },
+ 'click .js-add-gen-move-action'(event) {
+ const ruleName = this.data().ruleName.get();
+ const trigger = this.data().triggerVar.get();
+ const actionSelected = this.find('#move-gen-action').value;
if(actionSelected == "top"){
- Actions.insert({actionType: "moveCardToTop"},function(err,id){
- Rules.insert({title: ruleName, triggerId: triggerId, actionId: id});
- });
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":"*"});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
}
if(actionSelected == "bottom"){
- Actions.insert({actionType: "moveCardToBottom"},function(err,id){
- Rules.insert({title: ruleName, triggerId: triggerId, actionId: id});
- });
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "moveCardToBottom","listTitle":"*"});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ },
+ 'click .js-add-arch-action'(event) {
+ 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"});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ if(actionSelected == "unarchive"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "unarchive"});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
}
},
}];
diff --git a/client/components/rules/actions/cardActions.jade b/client/components/rules/actions/cardActions.jade
new file mode 100644
index 00000000..8d218a49
--- /dev/null
+++ b/client/components/rules/actions/cardActions.jade
@@ -0,0 +1,43 @@
+template(name="cardActions")
+ div.trigger-item
+ div.trigger-content
+ div.trigger-dropdown
+ select(id="label-action")
+ option(value="add") Add
+ option(value="remove") Remove
+ div.trigger-text
+ | label
+ div.trigger-dropdown
+ select(id="label-id")
+ each labels
+ option(value="#{_id}")
+ = name
+ div.trigger-button.js-add-label-action.js-goto-rules
+ i.fa.fa-plus
+
+ div.trigger-item
+ div.trigger-content
+ div.trigger-dropdown
+ select(id="member-action")
+ option(value="add") Add
+ option(value="remove") Removed
+ div.trigger-text
+ | member
+ div.trigger-dropdown
+ input(id="member-name",type=text,placeholder="Member name")
+ div.trigger-button.js-add-member-action.js-goto-rules
+ i.fa.fa-plus
+
+ div.trigger-item
+ div.trigger-content
+ div.trigger-text
+ | Remove all member from the card
+ div.trigger-button.js-add-removeall-action.js-goto-rules
+ i.fa.fa-plus
+
+
+
+
+
+
+
diff --git a/client/components/rules/actions/cardActions.js b/client/components/rules/actions/cardActions.js
new file mode 100644
index 00000000..48120d91
--- /dev/null
+++ b/client/components/rules/actions/cardActions.js
@@ -0,0 +1,66 @@
+BlazeComponent.extendComponent({
+ onCreated() {
+ this.subscribe('allRules');
+ },
+
+ 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){
+ labels[i].name = labels[i].color.toUpperCase();
+ }
+ }
+ console.log(labels);
+ 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;
+
+ if(actionSelected == "add"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "addLabel","labelId":labelId});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ if(actionSelected == "remove"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "removeLabel","labelId":labelId});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+
+ },
+ '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;
+ if(actionSelected == "add"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "addMember","memberName":memberName});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ if(actionSelected == "remove"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "removeMember","memberName":memberName});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ },
+ 'click .js-add-removeall-action'(event) {
+ const ruleName = this.data().ruleName.get();
+ const trigger = this.data().triggerVar.get();
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "removeMember","memberName":"*"});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ },
+ }];
+},
+
+}).register('cardActions'); \ No newline at end of file
diff --git a/client/components/rules/actions/checklistActions.jade b/client/components/rules/actions/checklistActions.jade
new file mode 100644
index 00000000..c85ec078
--- /dev/null
+++ b/client/components/rules/actions/checklistActions.jade
@@ -0,0 +1,51 @@
+template(name="checklistActions")
+ div.trigger-item
+ div.trigger-content
+ div.trigger-dropdown
+ select(id="check-action")
+ option(value="add") Add
+ option(value="remove") Remove
+ div.trigger-text
+ | checklist
+ div.trigger-dropdown
+ input(id="checklist-name",type=text,placeholder="name")
+ div.trigger-button.js-add-checklist-action.js-goto-rules
+ i.fa.fa-plus
+
+ div.trigger-item
+ div.trigger-content
+ div.trigger-dropdown
+ select(id="checkall-action")
+ option(value="check") Check all
+ option(value="uncheck") Unchek all
+ div.trigger-text
+ | items of checklist
+ div.trigger-dropdown
+ input(id="checklist-name2",type=text,placeholder="name")
+ div.trigger-button.js-add-checkall-action.js-goto-rules
+ i.fa.fa-plus
+
+
+ div.trigger-item
+ div.trigger-content
+ div.trigger-dropdown
+ select(id="check-item-action")
+ option(value="check") Check
+ option(value="uncheck") Unchek
+ div.trigger-text
+ | item
+ div.trigger-dropdown
+ input(id="checkitem-name",type=text,placeholder="name")
+ div.trigger-text
+ | of checklist
+ div.trigger-dropdown
+ input(id="checklist-name3",type=text,placeholder="name")
+ div.trigger-button.js-add-check-item-action.js-goto-rules
+ i.fa.fa-plus
+
+
+
+
+
+
+
diff --git a/client/components/rules/actions/checklistActions.js b/client/components/rules/actions/checklistActions.js
new file mode 100644
index 00000000..2a70ca7f
--- /dev/null
+++ b/client/components/rules/actions/checklistActions.js
@@ -0,0 +1,61 @@
+BlazeComponent.extendComponent({
+ onCreated() {
+ 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;
+
+ if(actionSelected == "add"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "addChecklist","checklistName":checklistName});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ if(actionSelected == "remove"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "removeChecklist","checklistName":checklistName});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+
+ },
+ '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;
+ if(actionSelected == "check"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "checkAll","checklistName":checklistName});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ if(actionSelected == "uncheck"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "uncheckAll","checklistName":checklistName});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ },
+ '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;
+ if(actionSelected == "check"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "checkItem","checklistName":checklistName,"checkItemName":checkItemName});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+ if(actionSelected == "uncheck"){
+ const triggerId = Triggers.insert(trigger);
+ const actionId = Actions.insert({actionType: "uncheckItem","checklistName":checklistName,"checkItemName":checkItemName});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ }
+},
+}];
+},
+
+}).register('checklistActions'); \ No newline at end of file
diff --git a/client/components/rules/actions/mailActions.jade b/client/components/rules/actions/mailActions.jade
new file mode 100644
index 00000000..5680d430
--- /dev/null
+++ b/client/components/rules/actions/mailActions.jade
@@ -0,0 +1,11 @@
+template(name="mailActions")
+ div.trigger-item.trigger-item-mail
+ div.trigger-content.trigger-content-mail
+ div.trigger-text.trigger-text-email
+ | Send an email
+ div.trigger-dropdown-mail
+ input(id="email-to",type=text,placeholder="to")
+ input(id="email-subject",type=text,placeholder="subject")
+ textarea(id="email-msg")
+ div.trigger-button.trigger-button-email.js-mail-action.js-goto-rules
+ i.fa.fa-plus \ No newline at end of file
diff --git a/client/components/rules/actions/mailActions.js b/client/components/rules/actions/mailActions.js
new file mode 100644
index 00000000..0e4b539e
--- /dev/null
+++ b/client/components/rules/actions/mailActions.js
@@ -0,0 +1,21 @@
+BlazeComponent.extendComponent({
+ onCreated() {
+
+ },
+
+ 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 actionId = Actions.insert({actionType: "sendEmail","emailTo":emailTo,"emailSubject":emailSubject,"emailMsg":emailMsg});
+ Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId});
+ },
+ }];
+},
+
+}).register('mailActions'); \ No newline at end of file
diff --git a/client/components/rules/rules.styl b/client/components/rules/rules.styl
index c9684709..68d74d32 100644
--- a/client/components/rules/rules.styl
+++ b/client/components/rules/rules.styl
@@ -40,6 +40,8 @@
display: -ms-flexbox
display: flex
+
+
.triggers-content
color: #727479
background: #dedede
@@ -107,6 +109,10 @@
.trigger-text
font-size: 16px
display:inline-block
+ .trigger-text.trigger-text-email
+ margin-left: 5px;
+ margin-top: 10px;
+ margin-bottom: 10px;
.trigger-dropdown
display:inline-block
select
@@ -118,6 +124,9 @@
display: inline-block
width: 80px;
margin: 0;
+ .trigger-content-mail
+ left:20px
+ right:100px
.trigger-button
position:absolute
top:50%
@@ -138,3 +147,10 @@
transform: translate(-50%,-50%)
&:hover, &.is-active
box-shadow: 0 0 0 2px darken(white, 60%) inset
+ .trigger-button.trigger-button-email
+ top:30px
+ .trigger-item.trigger-item-mail
+ height:300px
+
+
+
diff --git a/client/components/rules/rulesActions.jade b/client/components/rules/rulesActions.jade
index 35b070fc..9fcecf46 100644
--- a/client/components/rules/rulesActions.jade
+++ b/client/components/rules/rulesActions.jade
@@ -6,12 +6,20 @@ template(name="rulesActions")
.triggers-body
.triggers-side-menu
ul
- li.active.js-set-board-triggers
+ li.active.js-set-board-actions
i.fa.fa-columns
- li.js-set-card-triggers
+ li.js-set-card-actions
i.fa.fa-sticky-note
- li.js-set-checklist-triggers
+ li.js-set-checklist-actions
i.fa.fa-check
+ li.js-set-mail-actions
+ i.fa.fa-at
.triggers-main-body
- if showBoardActions.get
- +boardActions(ruleName=data.ruleName triggerIdVar=data.triggerIdVar) \ No newline at end of file
+ if ($eq currentActions.get 'board')
+ +boardActions(ruleName=data.ruleName triggerVar=data.triggerVar)
+ else if ($eq currentActions.get 'card')
+ +cardActions(ruleName=data.ruleName triggerVar=data.triggerVar)
+ else if ($eq currentActions.get 'checklist')
+ +checklistActions(ruleName=data.ruleName triggerVar=data.triggerVar)
+ else if ($eq currentActions.get 'mail')
+ +mailActions(ruleName=data.ruleName triggerVar=data.triggerVar) \ No newline at end of file
diff --git a/client/components/rules/rulesActions.js b/client/components/rules/rulesActions.js
index 297fc806..bf8d222d 100644
--- a/client/components/rules/rulesActions.js
+++ b/client/components/rules/rulesActions.js
@@ -1,34 +1,36 @@
BlazeComponent.extendComponent({
onCreated() {
- this.showBoardActions = new ReactiveVar(true);
- this.showCardActions = new ReactiveVar(false);
- this.showChecklistAction = new ReactiveVar(false);
+ this.currentActions = new ReactiveVar("board");
},
- setBoardTriggers(){
- this.showBoardActions.set(true);
- this.showCardActions.set(false);
- this.showChecklistActionsr.set(false);
- $('.js-set-card-triggers').removeClass('active');
- $('.js-set-board-triggers').addClass('active');
- $('.js-set-checklist-triggers').removeClass('active');
- },
- setCardTriggers(){
- this.showBoardActions.set(false);
- this.showCardActions.set(true);
- this.showChecklistActions.set(false);
- $('.js-set-card-triggers').addClass('active');
- $('.js-set-board-triggers').removeClass('active');
- $('.js-set-checklist-triggers').removeClass('active');
- },
- setChecklistTriggers(){
- this.showBoardActions.set(false);
- this.showCardActions.set(false);
- this.showChecklistActions.set(true);
- $('.js-set-card-triggers').removeClass('active');
- $('.js-set-board-triggers').removeClass('active');
- $('.js-set-checklist-triggers').addClass('active');
+ 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(){
+ 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(){
+ 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(){
+ this.currentActions.set("mail");
+ $('.js-set-card-actions').removeClass('active');
+ $('.js-set-board-actions').removeClass('active');
+ $('.js-set-checklist-actions').removeClass('active');
+ $('.js-set-mail-actions').addClass('active');
},
rules() {
@@ -39,14 +41,17 @@ BlazeComponent.extendComponent({
console.log(this.data());
},
events() {
- return [{'click .js-set-board-triggers'(event) {
- this.setBoardTriggers();
+ return [{'click .js-set-board-actions'(event) {
+ this.setBoardActions();
+ },
+ 'click .js-set-card-actions'(event) {
+ this.setCardActions();
},
- 'click .js-set-card-triggers'(event) {
- this.setCardTriggers();
+ 'click .js-set-mail-actions'(event) {
+ this.setMailActions();
},
- 'click .js-set-checklist-triggers'(event) {
- this.setChecklistTriggers();
+ 'click .js-set-checklist-actions'(event) {
+ this.setChecklistActions();
},}];
},
}).register('rulesActions'); \ No newline at end of file
diff --git a/client/components/rules/rulesMain.jade b/client/components/rules/rulesMain.jade
index 8e0efd63..2c308223 100644
--- a/client/components/rules/rulesMain.jade
+++ b/client/components/rules/rulesMain.jade
@@ -2,6 +2,6 @@ template(name="rulesMain")
if rulesListVar.get
+rulesList
else if rulesTriggerVar.get
- +rulesTriggers(ruleName=ruleName triggerIdVar=triggerIdVar)
+ +rulesTriggers(ruleName=ruleName triggerVar=triggerVar)
else if rulesActionVar.get
- +rulesActions(ruleName=ruleName triggerIdVar=triggerIdVar) \ No newline at end of file
+ +rulesActions(ruleName=ruleName triggerVar=triggerVar) \ No newline at end of file
diff --git a/client/components/rules/rulesMain.js b/client/components/rules/rulesMain.js
index 5a4b612a..ee4886b6 100644
--- a/client/components/rules/rulesMain.js
+++ b/client/components/rules/rulesMain.js
@@ -4,7 +4,7 @@ BlazeComponent.extendComponent({
this.rulesTriggerVar = new ReactiveVar(false);
this.rulesActionVar = new ReactiveVar(false);
this.ruleName = new ReactiveVar("");
- this.triggerIdVar = new ReactiveVar("");
+ this.triggerVar = new ReactiveVar();
},
setTrigger() {
diff --git a/client/components/rules/triggers/boardTriggers.js b/client/components/rules/triggers/boardTriggers.js
index 49c00c16..dcc1c187 100644
--- a/client/components/rules/triggers/boardTriggers.js
+++ b/client/components/rules/triggers/boardTriggers.js
@@ -11,14 +11,10 @@ BlazeComponent.extendComponent({
const actionSelected = this.find('#gen-action').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "created"){
- Triggers.insert({activityType: "createCard","boardId":boardId,"listName":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "createCard","boardId":boardId,"listName":"*"});
}
if(actionSelected == "removed"){
- Triggers.insert({activityType: "removeCard","boardId":boardId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "removeCard","boardId":boardId});
}
},
'click .js-add-create-trigger'(event) {
@@ -28,14 +24,10 @@ BlazeComponent.extendComponent({
const listName = this.find('#create-list-name').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "created"){
- Triggers.insert({activityType: "createCard","boardId":boardId,"listName":listName},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "createCard","boardId":boardId,"listName":listName});
}
if(actionSelected == "removed"){
- Triggers.insert({activityType: "removeCard","boardId":boardId,"listName":listName},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "removeCard","boardId":boardId,"listName":listName});
}
},
'click .js-add-moved-trigger'(event) {
@@ -44,14 +36,10 @@ BlazeComponent.extendComponent({
const listName = this.find('#move-list-name').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "moved-to"){
- Triggers.insert({activityType: "moveCard","boardId":boardId,"listName":listName,"oldListName":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "moveCard","boardId":boardId,"listName":listName,"oldListName":"*"});
}
if(actionSelected == "moved-from"){
- Triggers.insert({activityType: "moveCard","boardId":boardId,"listName":"*","oldListName":listName},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "moveCard","boardId":boardId,"listName":"*","oldListName":listName});
}
},
'click .js-add-arc-trigger'(event) {
@@ -59,14 +47,10 @@ BlazeComponent.extendComponent({
const actionSelected = this.find('#arch-action').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "archived"){
- Triggers.insert({activityType: "archivedCard","boardId":boardId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "archivedCard","boardId":boardId});
}
if(actionSelected == "unarchived"){
- Triggers.insert({activityType: "restoredCard","boardId":boardId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "restoredCard","boardId":boardId});
}
}
diff --git a/client/components/rules/triggers/cardTriggers.js b/client/components/rules/triggers/cardTriggers.js
index a9940e07..e860d806 100644
--- a/client/components/rules/triggers/cardTriggers.js
+++ b/client/components/rules/triggers/cardTriggers.js
@@ -22,14 +22,10 @@ BlazeComponent.extendComponent({
const actionSelected = this.find('#label-action').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "added"){
- Triggers.insert({activityType: "addedLabel","boardId":boardId,"labelId":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "addedLabel","boardId":boardId,"labelId":"*"});
}
if(actionSelected == "removed"){
- Triggers.insert({activityType: "removedLabel","boardId":boardId,"labelId":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "removedLabel","boardId":boardId,"labelId":"*"});
}
},
'click .js-add-spec-label-trigger'(event) {
@@ -38,14 +34,10 @@ BlazeComponent.extendComponent({
const labelId = this.find('#spec-label').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "added"){
- Triggers.insert({activityType: "addedLabel","boardId":boardId,"labelId":labelId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "addedLabel","boardId":boardId,"labelId":labelId});
}
if(actionSelected == "removed"){
- Triggers.insert({activityType: "removedLabel","boardId":boardId,"labelId":labelId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "removedLabel","boardId":boardId,"labelId":labelId});
}
},
'click .js-add-gen-member-trigger'(event) {
@@ -54,14 +46,10 @@ BlazeComponent.extendComponent({
const actionSelected = this.find('#gen-member-action').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "added"){
- Triggers.insert({activityType: "joinMember","boardId":boardId,"memberId":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "joinMember","boardId":boardId,"memberId":"*"});
}
if(actionSelected == "removed"){
- Triggers.insert({activityType: "unjoinMember","boardId":boardId,"memberId":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "unjoinMember","boardId":boardId,"memberId":"*"});
}
},
'click .js-add-spec-member-trigger'(event) {
@@ -70,14 +58,10 @@ BlazeComponent.extendComponent({
const memberId = this.find('#spec-member').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "added"){
- Triggers.insert({activityType: "joinMember","boardId":boardId,"memberId":memberId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "joinMember","boardId":boardId,"memberId":memberId});
}
if(actionSelected == "removed"){
- Triggers.insert({activityType: "unjoinMember","boardId":boardId,"memberId":memberId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "unjoinMember","boardId":boardId,"memberId":memberId});
}
},
'click .js-add-attachment-trigger'(event) {
@@ -86,14 +70,10 @@ BlazeComponent.extendComponent({
const actionSelected = this.find('#attach-action').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "added"){
- Triggers.insert({activityType: "addAttachment","boardId":boardId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "addAttachment","boardId":boardId});
}
if(actionSelected == "removed"){
- Triggers.insert({activityType: "deleteAttachment","boardId":boardId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "deleteAttachment","boardId":boardId});
}
},
}];
diff --git a/client/components/rules/triggers/checklistTriggers.js b/client/components/rules/triggers/checklistTriggers.js
index 9880e3bb..b790aff4 100644
--- a/client/components/rules/triggers/checklistTriggers.js
+++ b/client/components/rules/triggers/checklistTriggers.js
@@ -10,14 +10,10 @@ BlazeComponent.extendComponent({
const actionSelected = this.find('#gen-check-action').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "created"){
- Triggers.insert({activityType: "addChecklist","boardId":boardId,"checklistName":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "addChecklist","boardId":boardId,"checklistName":"*"});
}
if(actionSelected == "removed"){
- Triggers.insert({activityType: "removeChecklist","boardId":boardId,"checklistName":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "removeChecklist","boardId":boardId,"checklistName":"*"});
}
},
'click .js-add-spec-check-trigger'(event) {
@@ -26,14 +22,10 @@ BlazeComponent.extendComponent({
const checklistId = this.find('#check-name').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "created"){
- Triggers.insert({activityType: "addChecklist","boardId":boardId,"checklistName":checklistId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "addChecklist","boardId":boardId,"checklistName":checklistId});
}
if(actionSelected == "removed"){
- Triggers.insert({activityType: "removeChecklist","boardId":boardId,"checklistName":checklistId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "removeChecklist","boardId":boardId,"checklistName":checklistId});
}
},
'click .js-add-gen-comp-trigger'(event) {
@@ -42,14 +34,10 @@ BlazeComponent.extendComponent({
const actionSelected = this.find('#gen-comp-check-action').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "completed"){
- Triggers.insert({activityType: "completeChecklist","boardId":boardId,"checklistName":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "completeChecklist","boardId":boardId,"checklistName":"*"});
}
if(actionSelected == "uncompleted"){
- Triggers.insert({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":"*"});
}
},
'click .js-add-spec-comp-trigger'(event) {
@@ -58,14 +46,10 @@ BlazeComponent.extendComponent({
const checklistId = this.find('#spec-comp-check-name').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "added"){
- Triggers.insert({activityType: "joinMember","boardId":boardId,"checklistName":checklistId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "completeChecklist","boardId":boardId,"checklistName":checklistId});
}
if(actionSelected == "removed"){
- Triggers.insert({activityType: "unjoinMember","boardId":boardId,"checklistName":checklistId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":checklistId});
}
},
'click .js-add-gen-check-item-trigger'(event) {
@@ -74,14 +58,10 @@ BlazeComponent.extendComponent({
const actionSelected = this.find('#check-item-gen-action').value;
const boardId = Session.get('currentBoard')
if(actionSelected == "checked"){
- Triggers.insert({activityType: "checkedItem","boardId":boardId,"checklistItemName":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "checkedItem","boardId":boardId,"checklistItemName":"*"});
}
if(actionSelected == "unchecked"){
- Triggers.insert({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":"*"},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":"*"});
}
},
'click .js-add-spec-check-item-trigger'(event) {
@@ -89,15 +69,11 @@ BlazeComponent.extendComponent({
const actionSelected = this.find('#check-item-spec-action').value;
const checklistItemId = this.find('#check-item-name').value;
const boardId = Session.get('currentBoard')
- if(actionSelected == "added"){
- Triggers.insert({activityType: "joinMember","boardId":boardId,"checklistItemName":checklistItemId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ if(actionSelected == "checked"){
+ datas.triggerVar.set({activityType: "checkedItem","boardId":boardId,"checklistItemName":checklistItemId});
}
- if(actionSelected == "removed"){
- Triggers.insert({activityType: "unjoinMember","boardId":boardId,"checklistItemName":checklistItemId},function(error,id){
- datas.triggerIdVar.set(id);
- });
+ if(actionSelected == "unchecked"){
+ datas.triggerVar.set({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":checklistItemId});
}
},
}];
diff --git a/models/actions.js b/models/actions.js
index 93d45928..daa5cc96 100644
--- a/models/actions.js
+++ b/models/actions.js
@@ -16,6 +16,10 @@ Actions.allow({
insert: function () {
// add custom authentication code here
return true;
+ },
+ remove: function () {
+ // add custom authentication code here
+ return true;
}
});
diff --git a/models/checklistItems.js b/models/checklistItems.js
index 669003bb..e24f0cbd 100644
--- a/models/checklistItems.js
+++ b/models/checklistItems.js
@@ -44,6 +44,12 @@ ChecklistItems.mutations({
setTitle(title) {
return { $set: { title } };
},
+ check(){
+ return { $set: { isFinished: true } };
+ },
+ uncheck(){
+ return { $set: { isFinished: false } };
+ },
toggleItem() {
return { $set: { isFinished: !this.isFinished } };
},
diff --git a/models/checklists.js b/models/checklists.js
index 4a43818c..26429092 100644
--- a/models/checklists.js
+++ b/models/checklists.js
@@ -47,6 +47,18 @@ Checklists.helpers({
isFinished() {
return 0 !== this.itemCount() && this.itemCount() === this.finishedCount();
},
+ checkAllItems(){
+ const checkItems = ChecklistItems.find({checklistId: this._id});
+ checkItems.forEach(function(item){
+ item.check();
+ });
+ },
+ uncheckAllItems(){
+ const checkItems = ChecklistItems.find({checklistId: this._id});
+ checkItems.forEach(function(item){
+ item.uncheck();
+ });
+ },
itemIndex(itemId) {
const items = self.findOne({_id : this._id}).items;
return _.pluck(items, '_id').indexOf(itemId);
diff --git a/server/notifications/email.js b/server/notifications/email.js
index 2af6381e..b2b7fab8 100644
--- a/server/notifications/email.js
+++ b/server/notifications/email.js
@@ -39,3 +39,5 @@ Meteor.startup(() => {
}, 30000);
});
});
+
+
diff --git a/server/rulesHelper.js b/server/rulesHelper.js
index 1a00688e..2e9f58f4 100644
--- a/server/rulesHelper.js
+++ b/server/rulesHelper.js
@@ -1,19 +1,12 @@
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 actionType = matchingRules[i].getAction().actionType;
- this.performAction(activity,actionType);
- }
- },
-
- performAction(activity,actionType){
- if(actionType == "moveCardToTop"){
- const card = Cards.findOne({_id:activity.cardId});
- const minOrder = _.min(card.list().cards(card.swimlaneId).map((c) => c.sort));
- card.move(card.swimlaneId, card.listId, minOrder - 1);
+ const action = matchingRules[i].getAction();
+ this.performAction(activity,action);
}
},
findMatchingRules(activity){
@@ -39,6 +32,110 @@ RulesHelper = {
matchingMap[matchingFields[i]] = { $in: [activity[matchingFields[i]],"*"]};
}
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});
+ if(action.actionType == "moveCardToTop"){
+ let listId;
+ let list;
+ if(activity.listTitle == "*"){
+ listId = card.swimlaneId;
+ list = card.list();
+ }else{
+ list = Lists.findOne({title: action.listTitle});
+ listId = list._id;
+ }
+ const minOrder = _.min(list.cards(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;
+ list = card.list();
+ }else{
+ list = Lists.findOne({title: action.listTitle});
+ listId = list._id;
+ }
+ const maxOrder = _.max(list.cards(card.swimlaneId).map((c) => c.sort));
+ card.move(card.swimlaneId, listId, maxOrder + 1);
+ }
+ if(action.actionType == "sendEmail"){
+ const emailTo = action.emailTo;
+ const emailMsg = action.emailMsg;
+ const emailSubject = action.emailSubject;
+ try {
+ Email.send({
+ to: to,
+ from: Accounts.emailTemplates.from,
+ subject: subject,
+ text,
+ });
+ } catch (e) {
+ return;
+ }
+ }
+ if(action.actionType == "archive"){
+ card.archive();
+ }
+ if(action.actionType == "unarchive"){
+ card.restore();
+ }
+ if(action.actionType == "addLabel"){
+ card.addLabel(action.labelId);
+ }
+ if(action.actionType == "removeLabel"){
+ card.removeLabel(action.labelId);
+ }
+ 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]);
+ }
+ }else{
+ const memberId = Users.findOne({username:action.memberName})._id;
+ card.unassignMember(memberId);
+ }
+ }
+ if(action.actionType == "checkAll"){
+ const checkList = Checklists.findOne({"title":action.checklistName,"cardId":card._id});
+ checkList.checkAllItems();
+ }
+ if(action.actionType == "uncheckAll"){
+ const checkList = Checklists.findOne({"title":action.checklistName,"cardId":card._id});
+ checkList.uncheckAllItems();
+ }
+ if(action.actionType == "checkItem"){
+ const checkList = Checklists.findOne({"title":action.checklistName,"cardId":card._id});
+ const checkItem = ChecklistItems.findOne({"title":action.checkItemName,"checkListId":checkList._id})
+ checkItem.check();
+ }
+ if(action.actionType == "uncheckItem"){
+ const checkList = Checklists.findOne({"title":action.checklistName,"cardId":card._id});
+ const checkItem = ChecklistItems.findOne({"title":action.checkItemName,"checkListId":checkList._id})
+ checkItem.uncheck();
+ }
+ if(action.actionType == "addChecklist"){
+ Checklists.insert({"title":action.checklistName,"cardId":card._id,"sort":0});
+ }
+ if(action.actionType == "removeChecklist"){
+ Checklists.remove({"title":action.checklistName,"cardId":card._id,"sort":0});
+ }
+
+ },
} \ No newline at end of file