summaryrefslogtreecommitdiffstats
path: root/client/components/rules/triggers/checklistTriggers.js
blob: 9880e3bbfba7acf7caaf5f98565af8a15736470e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
BlazeComponent.extendComponent({
  onCreated() {
    this.subscribe('allRules');
  },
  events() {
    return [
    {'click .js-add-gen-check-trigger'(event) {

      let datas = this.data();
      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);
        });
      }
      if(actionSelected == "removed"){
        Triggers.insert({activityType: "removeChecklist","boardId":boardId,"checklistName":"*"},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
    },
    'click .js-add-spec-check-trigger'(event) {
      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"){
        Triggers.insert({activityType: "addChecklist","boardId":boardId,"checklistName":checklistId},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
      if(actionSelected == "removed"){
        Triggers.insert({activityType: "removeChecklist","boardId":boardId,"checklistName":checklistId},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
    },
    'click .js-add-gen-comp-trigger'(event) {

      let datas = this.data();
      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);
        });
      }
      if(actionSelected == "uncompleted"){
        Triggers.insert({activityType: "uncompleteChecklist","boardId":boardId,"checklistName":"*"},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
    },
    'click .js-add-spec-comp-trigger'(event) {
      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"){
        Triggers.insert({activityType: "joinMember","boardId":boardId,"checklistName":checklistId},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
      if(actionSelected == "removed"){
        Triggers.insert({activityType: "unjoinMember","boardId":boardId,"checklistName":checklistId},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
    },
    'click .js-add-gen-check-item-trigger'(event) {

      let datas = this.data();
      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);
        });
      }
      if(actionSelected == "unchecked"){
        Triggers.insert({activityType: "uncheckedItem","boardId":boardId,"checklistItemName":"*"},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
    },
    'click .js-add-spec-check-item-trigger'(event) {
      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 == "added"){
        Triggers.insert({activityType: "joinMember","boardId":boardId,"checklistItemName":checklistItemId},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
      if(actionSelected == "removed"){
        Triggers.insert({activityType: "unjoinMember","boardId":boardId,"checklistItemName":checklistItemId},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
    },
    }];
  },

}).register('checklistTriggers');