boardTriggers.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. BlazeComponent.extendComponent({
  2. onCreated() {
  3. this.provaVar = new ReactiveVar('');
  4. this.currentPopupTriggerId = 'def';
  5. this.cardTitleFilters = {};
  6. },
  7. setNameFilter(name) {
  8. this.cardTitleFilters[this.currentPopupTriggerId] = name;
  9. },
  10. events() {
  11. return [
  12. {
  13. 'click .js-open-card-title-popup'(event) {
  14. const funct = Popup.open('boardCardTitle');
  15. const divId = $(event.currentTarget.parentNode.parentNode).attr('id');
  16. //console.log('current popup');
  17. //console.log(this.currentPopupTriggerId);
  18. this.currentPopupTriggerId = divId;
  19. funct.call(this, event);
  20. },
  21. 'click .js-add-create-trigger'(event) {
  22. const desc = Utils.getTriggerActionDesc(event, this);
  23. const datas = this.data();
  24. const listName = this.find('#create-list-name').value;
  25. const swimlaneName = this.find('#create-swimlane-name').value;
  26. const boardId = Session.get('currentBoard');
  27. const divId = $(event.currentTarget.parentNode).attr('id');
  28. const cardTitle = this.cardTitleFilters[divId];
  29. // move to generic funciont
  30. datas.triggerVar.set({
  31. activityType: 'createCard',
  32. boardId,
  33. cardTitle,
  34. swimlaneName,
  35. listName,
  36. desc,
  37. });
  38. },
  39. 'click .js-add-moved-trigger'(event) {
  40. const datas = this.data();
  41. const desc = Utils.getTriggerActionDesc(event, this);
  42. const swimlaneName = this.find('#create-swimlane-name-2').value;
  43. const actionSelected = this.find('#move-action').value;
  44. const listName = this.find('#move-list-name').value;
  45. const boardId = Session.get('currentBoard');
  46. const divId = $(event.currentTarget.parentNode).attr('id');
  47. const cardTitle = this.cardTitleFilters[divId];
  48. if (actionSelected === 'moved-to') {
  49. datas.triggerVar.set({
  50. activityType: 'moveCard',
  51. boardId,
  52. listName,
  53. cardTitle,
  54. swimlaneName,
  55. oldListName: '*',
  56. desc,
  57. });
  58. }
  59. if (actionSelected === 'moved-from') {
  60. datas.triggerVar.set({
  61. activityType: 'moveCard',
  62. boardId,
  63. cardTitle,
  64. swimlaneName,
  65. listName: '*',
  66. oldListName: listName,
  67. desc,
  68. });
  69. }
  70. },
  71. 'click .js-add-gen-moved-trigger'(event) {
  72. const datas = this.data();
  73. const desc = Utils.getTriggerActionDesc(event, this);
  74. const boardId = Session.get('currentBoard');
  75. datas.triggerVar.set({
  76. activityType: 'moveCard',
  77. boardId,
  78. swimlaneName: '*',
  79. listName: '*',
  80. oldListName: '*',
  81. desc,
  82. });
  83. },
  84. 'click .js-add-arc-trigger'(event) {
  85. const datas = this.data();
  86. const desc = Utils.getTriggerActionDesc(event, this);
  87. const actionSelected = this.find('#arch-action').value;
  88. const boardId = Session.get('currentBoard');
  89. if (actionSelected === 'archived') {
  90. datas.triggerVar.set({
  91. activityType: 'archivedCard',
  92. boardId,
  93. desc,
  94. });
  95. }
  96. if (actionSelected === 'unarchived') {
  97. datas.triggerVar.set({
  98. activityType: 'restoredCard',
  99. boardId,
  100. desc,
  101. });
  102. }
  103. },
  104. },
  105. ];
  106. },
  107. }).register('boardTriggers');
  108. Template.boardCardTitlePopup.events({
  109. submit(event, templateInstance) {
  110. const title = templateInstance
  111. .$('.js-card-filter-name')
  112. .val()
  113. .trim();
  114. Popup.getOpenerComponent().setNameFilter(title);
  115. event.preventDefault();
  116. Popup.close();
  117. },
  118. });