boardActions.js 3.5 KB

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