summaryrefslogtreecommitdiffstats
path: root/client/components/rules/triggers/boardTriggers.js
blob: 562d84a91a184bd1a219f8d1ff9879544c402614 (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
109
110
111
112
113
114
115
116
BlazeComponent.extendComponent({
  onCreated() {

  },

  events() {
    return [{
      'click .js-add-gen-trigger' (event) {
        const desc = Utils.getTriggerActionDesc(event, this);
        const datas = this.data();
        const actionSelected = this.find('#gen-action').value;
        const boardId = Session.get('currentBoard');
        if (actionSelected === 'created') {
          datas.triggerVar.set({
            activityType: 'createCard',
            boardId,
            'listName': '*',
            desc,
          });
        }
        if (actionSelected === 'removed') {
          datas.triggerVar.set({
            activityType: 'removeCard',
            boardId,
            desc,
          });
        }

      },
      'click .js-add-create-trigger' (event) {
        const desc = Utils.getTriggerActionDesc(event, this);
        const 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,
            listName,
            desc,
          });
        }
        if (actionSelected === 'removed') {
          datas.triggerVar.set({
            activityType: 'removeCard',
            boardId,
            listName,
            desc,
          });
        }
      },
      'click .js-add-moved-trigger' (event) {
        const 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,
            listName,
            'oldListName': '*',
            desc,
          });
        }
        if (actionSelected === 'moved-from') {
          datas.triggerVar.set({
            activityType: 'moveCard',
            boardId,
            'listName': '*',
            'oldListName': listName,
            desc,
          });
        }
      },
      'click .js-add-gen-moved-trigger' (event){
        const datas = this.data();
        const desc = Utils.getTriggerActionDesc(event, this);
        const boardId = Session.get('currentBoard');

          datas.triggerVar.set({
            activityType: 'moveCard',
            boardId,
            'listName':'*',
            'oldListName': '*',
            desc,
          });
      },
      'click .js-add-arc-trigger' (event) {
        const 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,
            desc,
          });
        }
        if (actionSelected === 'unarchived') {
          datas.triggerVar.set({
            activityType: 'restoredCard',
            boardId,
            desc,
          });
        }
      },

    }];
  },

}).register('boardTriggers');