checklistTriggers.js 4.7 KB

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