boardTriggers.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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').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. if (actionSelected === 'moved-to') {
  46. datas.triggerVar.set({
  47. activityType: 'moveCard',
  48. boardId,
  49. listName,
  50. swimlaneName,
  51. 'oldListName': '*',
  52. desc,
  53. });
  54. }
  55. if (actionSelected === 'moved-from') {
  56. datas.triggerVar.set({
  57. activityType: 'moveCard',
  58. boardId,
  59. swimlaneName,
  60. 'listName': '*',
  61. 'oldListName': listName,
  62. desc,
  63. });
  64. }
  65. },
  66. 'click .js-add-gen-moved-trigger' (event){
  67. const datas = this.data();
  68. const desc = Utils.getTriggerActionDesc(event, this);
  69. const boardId = Session.get('currentBoard');
  70. datas.triggerVar.set({
  71. 'activityType': 'moveCard',
  72. boardId,
  73. 'swimlaneName': '*',
  74. 'listName':'*',
  75. 'oldListName': '*',
  76. desc,
  77. });
  78. },
  79. 'click .js-add-arc-trigger' (event) {
  80. const datas = this.data();
  81. const desc = Utils.getTriggerActionDesc(event, this);
  82. const actionSelected = this.find('#arch-action').value;
  83. const boardId = Session.get('currentBoard');
  84. if (actionSelected === 'archived') {
  85. datas.triggerVar.set({
  86. activityType: 'archivedCard',
  87. boardId,
  88. desc,
  89. });
  90. }
  91. if (actionSelected === 'unarchived') {
  92. datas.triggerVar.set({
  93. activityType: 'restoredCard',
  94. boardId,
  95. desc,
  96. });
  97. }
  98. },
  99. }];
  100. },
  101. }).register('boardTriggers');
  102. Template.boardCardTitlePopup.events({
  103. submit(evt, tpl) {
  104. const title = tpl.$('.js-card-filter-name').val().trim();
  105. Popup.getOpenerComponent().setNameFilter(title);
  106. evt.preventDefault();
  107. Popup.close();
  108. },
  109. });