boardActions.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. BlazeComponent.extendComponent({
  2. onCreated() {
  3. },
  4. events() {
  5. return [{
  6. 'click .js-add-swimlane-action' (event) {
  7. const ruleName = this.data().ruleName.get();
  8. const trigger = this.data().triggerVar.get();
  9. const swimlaneName = this.find('#swimlane-name').value;
  10. const boardId = Session.get('currentBoard');
  11. const desc = Utils.getTriggerActionDesc(event, this);
  12. const triggerId = Triggers.insert(trigger);
  13. const actionId = Actions.insert({
  14. actionType: 'addSwimlane',
  15. swimlaneName,
  16. boardId,
  17. desc,
  18. });
  19. Rules.insert({
  20. title: ruleName,
  21. triggerId,
  22. actionId,
  23. boardId,
  24. });
  25. },
  26. 'click .js-add-spec-move-action' (event) {
  27. const ruleName = this.data().ruleName.get();
  28. const trigger = this.data().triggerVar.get();
  29. const actionSelected = this.find('#move-spec-action').value;
  30. const listTitle = this.find('#listName').value;
  31. const boardId = Session.get('currentBoard');
  32. const desc = Utils.getTriggerActionDesc(event, this);
  33. if (actionSelected === 'top') {
  34. const triggerId = Triggers.insert(trigger);
  35. const actionId = Actions.insert({
  36. actionType: 'moveCardToTop',
  37. listTitle,
  38. boardId,
  39. desc,
  40. });
  41. Rules.insert({
  42. title: ruleName,
  43. triggerId,
  44. actionId,
  45. boardId,
  46. });
  47. }
  48. if (actionSelected === 'bottom') {
  49. const triggerId = Triggers.insert(trigger);
  50. const actionId = Actions.insert({
  51. actionType: 'moveCardToBottom',
  52. listTitle,
  53. boardId,
  54. desc,
  55. });
  56. Rules.insert({
  57. title: ruleName,
  58. triggerId,
  59. actionId,
  60. boardId,
  61. });
  62. }
  63. },
  64. 'click .js-add-gen-move-action' (event) {
  65. const desc = Utils.getTriggerActionDesc(event, this);
  66. const boardId = Session.get('currentBoard');
  67. const ruleName = this.data().ruleName.get();
  68. const trigger = this.data().triggerVar.get();
  69. const actionSelected = this.find('#move-gen-action').value;
  70. if (actionSelected === 'top') {
  71. const triggerId = Triggers.insert(trigger);
  72. const actionId = Actions.insert({
  73. actionType: 'moveCardToTop',
  74. 'listTitle': '*',
  75. boardId,
  76. desc,
  77. });
  78. Rules.insert({
  79. title: ruleName,
  80. triggerId,
  81. actionId,
  82. boardId,
  83. });
  84. }
  85. if (actionSelected === 'bottom') {
  86. const triggerId = Triggers.insert(trigger);
  87. const actionId = Actions.insert({
  88. actionType: 'moveCardToBottom',
  89. 'listTitle': '*',
  90. boardId,
  91. desc,
  92. });
  93. Rules.insert({
  94. title: ruleName,
  95. triggerId,
  96. actionId,
  97. boardId,
  98. });
  99. }
  100. },
  101. 'click .js-add-arch-action' (event) {
  102. const desc = Utils.getTriggerActionDesc(event, this);
  103. const boardId = Session.get('currentBoard');
  104. const ruleName = this.data().ruleName.get();
  105. const trigger = this.data().triggerVar.get();
  106. const actionSelected = this.find('#arch-action').value;
  107. if (actionSelected === 'archive') {
  108. const triggerId = Triggers.insert(trigger);
  109. const actionId = Actions.insert({
  110. actionType: 'archive',
  111. boardId,
  112. desc,
  113. });
  114. Rules.insert({
  115. title: ruleName,
  116. triggerId,
  117. actionId,
  118. boardId,
  119. });
  120. }
  121. if (actionSelected === 'unarchive') {
  122. const triggerId = Triggers.insert(trigger);
  123. const actionId = Actions.insert({
  124. actionType: 'unarchive',
  125. boardId,
  126. desc,
  127. });
  128. Rules.insert({
  129. title: ruleName,
  130. triggerId,
  131. actionId,
  132. boardId,
  133. });
  134. }
  135. },
  136. }];
  137. },
  138. }).register('boardActions');
  139. /* eslint-no-undef */