boardTriggers.js 3.7 KB

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