checklistTriggers.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. BlazeComponent.extendComponent({
  2. onCreated() {
  3. this.subscribe('allRules');
  4. },
  5. events() {
  6. return [
  7. {
  8. 'click .js-add-gen-check-trigger'(event) {
  9. const desc = Utils.getTriggerActionDesc(event, this);
  10. const datas = this.data();
  11. const actionSelected = this.find('#gen-check-action').value;
  12. const boardId = Session.get('currentBoard');
  13. if (actionSelected === 'created') {
  14. datas.triggerVar.set({
  15. activityType: 'addChecklist',
  16. boardId,
  17. checklistName: '*',
  18. desc,
  19. });
  20. }
  21. if (actionSelected === 'removed') {
  22. datas.triggerVar.set({
  23. activityType: 'removeChecklist',
  24. boardId,
  25. checklistName: '*',
  26. desc,
  27. });
  28. }
  29. },
  30. 'click .js-add-spec-check-trigger'(event) {
  31. const desc = Utils.getTriggerActionDesc(event, this);
  32. const datas = this.data();
  33. const actionSelected = this.find('#spec-check-action').value;
  34. const checklistId = this.find('#check-name').value;
  35. const boardId = Session.get('currentBoard');
  36. if (actionSelected === 'created') {
  37. datas.triggerVar.set({
  38. activityType: 'addChecklist',
  39. boardId,
  40. checklistName: checklistId,
  41. desc,
  42. });
  43. }
  44. if (actionSelected === 'removed') {
  45. datas.triggerVar.set({
  46. activityType: 'removeChecklist',
  47. boardId,
  48. checklistName: checklistId,
  49. desc,
  50. });
  51. }
  52. },
  53. 'click .js-add-gen-comp-trigger'(event) {
  54. const desc = Utils.getTriggerActionDesc(event, this);
  55. const datas = this.data();
  56. const actionSelected = this.find('#gen-comp-check-action').value;
  57. const boardId = Session.get('currentBoard');
  58. if (actionSelected === 'completed') {
  59. datas.triggerVar.set({
  60. activityType: 'completeChecklist',
  61. boardId,
  62. checklistName: '*',
  63. desc,
  64. });
  65. }
  66. if (actionSelected === 'uncompleted') {
  67. datas.triggerVar.set({
  68. activityType: 'uncompleteChecklist',
  69. boardId,
  70. checklistName: '*',
  71. desc,
  72. });
  73. }
  74. },
  75. 'click .js-add-spec-comp-trigger'(event) {
  76. const desc = Utils.getTriggerActionDesc(event, this);
  77. const datas = this.data();
  78. const actionSelected = this.find('#spec-comp-check-action').value;
  79. const checklistId = this.find('#spec-comp-check-name').value;
  80. const boardId = Session.get('currentBoard');
  81. if (actionSelected === 'completed') {
  82. datas.triggerVar.set({
  83. activityType: 'completeChecklist',
  84. boardId,
  85. checklistName: checklistId,
  86. desc,
  87. });
  88. }
  89. if (actionSelected === 'uncompleted') {
  90. datas.triggerVar.set({
  91. activityType: 'uncompleteChecklist',
  92. boardId,
  93. checklistName: checklistId,
  94. desc,
  95. });
  96. }
  97. },
  98. 'click .js-add-gen-check-item-trigger'(event) {
  99. const desc = Utils.getTriggerActionDesc(event, this);
  100. const datas = this.data();
  101. const actionSelected = this.find('#check-item-gen-action').value;
  102. const boardId = Session.get('currentBoard');
  103. if (actionSelected === 'checked') {
  104. datas.triggerVar.set({
  105. activityType: 'checkedItem',
  106. boardId,
  107. checklistItemName: '*',
  108. desc,
  109. });
  110. }
  111. if (actionSelected === 'unchecked') {
  112. datas.triggerVar.set({
  113. activityType: 'uncheckedItem',
  114. boardId,
  115. checklistItemName: '*',
  116. desc,
  117. });
  118. }
  119. },
  120. 'click .js-add-spec-check-item-trigger'(event) {
  121. const desc = Utils.getTriggerActionDesc(event, this);
  122. const datas = this.data();
  123. const actionSelected = this.find('#check-item-spec-action').value;
  124. const checklistItemId = this.find('#check-item-name').value;
  125. const boardId = Session.get('currentBoard');
  126. if (actionSelected === 'checked') {
  127. datas.triggerVar.set({
  128. activityType: 'checkedItem',
  129. boardId,
  130. checklistItemName: checklistItemId,
  131. desc,
  132. });
  133. }
  134. if (actionSelected === 'unchecked') {
  135. datas.triggerVar.set({
  136. activityType: 'uncheckedItem',
  137. boardId,
  138. checklistItemName: checklistItemId,
  139. desc,
  140. });
  141. }
  142. },
  143. },
  144. ];
  145. },
  146. }).register('checklistTriggers');