summaryrefslogtreecommitdiffstats
path: root/client/components/rules/actions/boardActions.js
blob: d1593a5b2ba4e2cf04f8a3d0fb44268120b3d5a5 (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
BlazeComponent.extendComponent({
  onCreated() {

  },



  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');

      if(actionSelected == "top"){
       const triggerId = Triggers.insert(trigger);
       const actionId = Actions.insert({actionType: "moveCardToTop","listTitle":listTitle,"boardId":boardId});
       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});
       Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});  
     }
   },
   'click .js-add-gen-move-action'(event) {
    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});
     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});
     Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});  
   }
 },
 'click .js-add-arch-action'(event) {
  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});
   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});
   Rules.insert({title: ruleName, triggerId: triggerId, actionId: actionId,"boardId":boardId});  
 }
},
}];
},

}).register('boardActions');