summaryrefslogtreecommitdiffstats
path: root/client/components/rules/triggers/boardTriggers.js
blob: 49c00c16bb4428270850c3457460af39634863fc (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
BlazeComponent.extendComponent({
  onCreated() {

  },

  events() {
    return [
    {'click .js-add-gen-trigger'(event) {

      let datas = this.data();
      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);
        });
      }
      if(actionSelected == "removed"){
        Triggers.insert({activityType: "removeCard","boardId":boardId},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
    },
    'click .js-add-create-trigger'(event) {

      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"){
        Triggers.insert({activityType: "createCard","boardId":boardId,"listName":listName},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
      if(actionSelected == "removed"){
        Triggers.insert({activityType: "removeCard","boardId":boardId,"listName":listName},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
    },
    'click .js-add-moved-trigger'(event) {
      let datas = this.data();
      const actionSelected = this.find('#move-action').value;
      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);
        });
      }
      if(actionSelected == "moved-from"){
        Triggers.insert({activityType: "moveCard","boardId":boardId,"listName":"*","oldListName":listName},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
    },
    'click .js-add-arc-trigger'(event) {
      let datas = this.data();
      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);
        });
      }
      if(actionSelected == "unarchived"){
        Triggers.insert({activityType: "restoredCard","boardId":boardId},function(error,id){
          datas.triggerIdVar.set(id);
        });
      }
    }

    }];
  },

}).register('boardTriggers');