From 72ddd664951591291f2e39c1b824477761a861b2 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Sat, 6 Nov 2021 11:26:39 +0100 Subject: [PATCH 1/4] Global Search Card Detail Popup shows now the description too --- server/publications/cards.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/publications/cards.js b/server/publications/cards.js index caa9190a5..19906f4f1 100644 --- a/server/publications/cards.js +++ b/server/publications/cards.js @@ -489,6 +489,7 @@ function buildProjection(query) { labelIds: 1, customFields: 1, userId: 1, + description: 1, }, sort: { boardId: 1, From 4733afe4eb825e993c2cac48cba1830b3b889039 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Mon, 8 Nov 2021 11:47:41 +0100 Subject: [PATCH 2/4] Global Search Card Popup has now every data if the search was opened from another board - the global search only returns the card details data needed to display the search results, but for opening the popup card details a lot more information is needed. It already worked if the data was already in the minimongo, but if not, nearly nothing was displayed --- client/components/cards/cardDetails.js | 1 + client/components/cards/resultCard.js | 12 ++++++++++-- client/config/blazeHelpers.js | 8 ++------ client/lib/utils.js | 20 ++++++++++++++++++++ config/router.js | 9 +++++++++ server/publications/cards.js | 17 ++++++++++++++++- 6 files changed, 58 insertions(+), 9 deletions(-) diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index f3693cb5d..7fd2dac8d 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -547,6 +547,7 @@ Template.cardDetails.helpers({ }); Template.cardDetailsPopup.onDestroyed(() => { Session.delete('popupCard'); + Session.delete('popupCardBoardId'); }); Template.cardDetailsPopup.helpers({ popupCard() { diff --git a/client/components/cards/resultCard.js b/client/components/cards/resultCard.js index 89632b97a..bfe54b01e 100644 --- a/client/components/cards/resultCard.js +++ b/client/components/cards/resultCard.js @@ -7,8 +7,16 @@ Template.resultCard.helpers({ BlazeComponent.extendComponent({ clickOnMiniCard(evt) { evt.preventDefault(); - Session.set('popupCard', this.currentData()._id); - this.cardDetailsPopup(evt); + const this_ = this; + const cardId = this.currentData()._id; + const boardId = this.currentData().boardId; + Meteor.subscribe('popupCardData', cardId, { + onReady() { + Session.set('popupCard', cardId); + Session.set('popupCardBoardId', boardId); + this_.cardDetailsPopup(evt); + }, + }); }, cardDetailsPopup(event) { diff --git a/client/config/blazeHelpers.js b/client/config/blazeHelpers.js index 741b2fc58..22194f3bd 100644 --- a/client/config/blazeHelpers.js +++ b/client/config/blazeHelpers.js @@ -1,10 +1,6 @@ Blaze.registerHelper('currentBoard', () => { - const boardId = Session.get('currentBoard'); - if (boardId) { - return Boards.findOne(boardId); - } else { - return null; - } + const ret = Utils.getCurrentBoard(); + return ret; }); Blaze.registerHelper('currentCard', () => { diff --git a/client/lib/utils.js b/client/lib/utils.js index 3e2cad868..cba1243f7 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -1,4 +1,16 @@ Utils = { + /** returns the current board id + *
  • returns the current board id or the board id of the popup card if set + */ + getCurrentBoardId() { + let popupCardBoardId = Session.get('popupCardBoardId'); + let currentBoard = Session.get('currentBoard'); + let ret = currentBoard; + if (popupCardBoardId) { + ret = popupCardBoardId; + } + return ret; + }, getCurrentCardId(ignorePopupCard) { let ret = Session.get('currentCard'); if (!ret && !ignorePopupCard) { @@ -10,6 +22,14 @@ Utils = { const ret = Session.get('popupCard'); return ret; }, + /** returns the current board + *
  • returns the current board or the board of the popup card if set + */ + getCurrentBoard() { + const boardId = Utils.getCurrentBoardId(); + const ret = Boards.findOne(boardId); + return ret; + }, getCurrentCard(ignorePopupCard) { const cardId = Utils.getCurrentCardId(ignorePopupCard); const ret = Cards.findOne(cardId); diff --git a/config/router.js b/config/router.js index dec27ba21..2ba95fdcd 100644 --- a/config/router.js +++ b/config/router.js @@ -13,6 +13,7 @@ FlowRouter.route('/', { Session.set('currentList', null); Session.set('currentCard', null); Session.set('popupCard', null); + Session.set('popupCardBoardId', null); Filter.reset(); Session.set('sortBy', ''); @@ -36,6 +37,7 @@ FlowRouter.route('/public', { Session.set('currentList', null); Session.set('currentCard', null); Session.set('popupCard', null); + Session.set('popupCardBoardId', null); Filter.reset(); Session.set('sortBy', ''); @@ -59,6 +61,7 @@ FlowRouter.route('/b/:id/:slug', { Session.set('currentBoard', currentBoard); Session.set('currentCard', null); Session.set('popupCard', null); + Session.set('popupCardBoardId', null); // If we close a card, we'll execute again this route action but we don't // want to excape every current actions (filters, etc.) @@ -88,6 +91,7 @@ FlowRouter.route('/b/:boardId/:slug/:cardId', { Session.set('currentBoard', params.boardId); Session.set('currentCard', params.cardId); Session.set('popupCard', null); + Session.set('popupCardBoardId', null); Utils.manageCustomUI(); Utils.manageMatomo(); @@ -217,6 +221,7 @@ FlowRouter.route('/import/:source', { Session.set('currentList', null); Session.set('currentCard', null); Session.set('popupCard', null); + Session.set('popupCardBoardId', null); Session.set('importSource', params.source); Filter.reset(); @@ -238,6 +243,7 @@ FlowRouter.route('/setting', { Session.set('currentList', null); Session.set('currentCard', null); Session.set('popupCard', null); + Session.set('popupCardBoardId', null); Filter.reset(); Session.set('sortBy', ''); @@ -262,6 +268,7 @@ FlowRouter.route('/information', { Session.set('currentList', null); Session.set('currentCard', null); Session.set('popupCard', null); + Session.set('popupCardBoardId', null); Filter.reset(); Session.set('sortBy', ''); @@ -285,6 +292,7 @@ FlowRouter.route('/people', { Session.set('currentList', null); Session.set('currentCard', null); Session.set('popupCard', null); + Session.set('popupCardBoardId', null); Filter.reset(); Session.set('sortBy', ''); @@ -308,6 +316,7 @@ FlowRouter.route('/admin-reports', { Session.set('currentList', null); Session.set('currentCard', null); Session.set('popupCard', null); + Session.set('popupCardBoardId', null); Filter.reset(); Session.set('sortBy', ''); diff --git a/server/publications/cards.js b/server/publications/cards.js index 19906f4f1..8322de09d 100644 --- a/server/publications/cards.js +++ b/server/publications/cards.js @@ -52,7 +52,22 @@ const escapeForRegex = require('escape-string-regexp'); Meteor.publish('card', cardId => { check(cardId, String); - return Cards.find({ _id: cardId }); + const ret = Cards.find({ _id: cardId }); + return ret; +}); + +/** publish all data which is necessary to display card details as popup + * @returns array of cursors + */ +Meteor.publishRelations('popupCardData', function(cardId) { + check(cardId, String); + this.cursor( + Cards.find({_id: cardId}), + function(cardId, card) { + this.cursor(Boards.find({_id: card.boardId})); + }, + ); + return this.ready() }); Meteor.publish('myCards', function(sessionId) { From f4a3363f6f75bb1a70f5fae41b551916d9866325 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Mon, 8 Nov 2021 11:55:14 +0100 Subject: [PATCH 3/4] replace Session key popupCard with popupCardId (better meaning of what the variable contains) --- client/components/cards/cardDetails.js | 2 +- client/components/cards/resultCard.js | 2 +- client/components/lists/listBody.js | 2 +- client/components/sidebar/sidebarSearches.js | 2 +- client/lib/utils.js | 2 +- config/router.js | 18 +++++++++--------- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index 7fd2dac8d..ab6deb4a4 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -546,7 +546,7 @@ Template.cardDetails.helpers({ } }); Template.cardDetailsPopup.onDestroyed(() => { - Session.delete('popupCard'); + Session.delete('popupCardId'); Session.delete('popupCardBoardId'); }); Template.cardDetailsPopup.helpers({ diff --git a/client/components/cards/resultCard.js b/client/components/cards/resultCard.js index bfe54b01e..8e04f1654 100644 --- a/client/components/cards/resultCard.js +++ b/client/components/cards/resultCard.js @@ -12,7 +12,7 @@ BlazeComponent.extendComponent({ const boardId = this.currentData().boardId; Meteor.subscribe('popupCardData', cardId, { onReady() { - Session.set('popupCard', cardId); + Session.set('popupCardId', cardId); Session.set('popupCardBoardId', boardId); this_.cardDetailsPopup(evt); }, diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index 3ec189a21..bb03d72cd 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -150,7 +150,7 @@ BlazeComponent.extendComponent({ // overwriting the event in case the card is already selected. } else if (Utils.isMiniScreen()) { evt.preventDefault(); - Session.set('popupCard', this.currentData()._id); + Session.set('popupCardId', this.currentData()._id); this.cardDetailsPopup(evt); } else if (Session.equals('currentCard', this.currentData()._id)) { evt.stopImmediatePropagation(); diff --git a/client/components/sidebar/sidebarSearches.js b/client/components/sidebar/sidebarSearches.js index 643fcb59c..f5e8a5c82 100644 --- a/client/components/sidebar/sidebarSearches.js +++ b/client/components/sidebar/sidebarSearches.js @@ -16,7 +16,7 @@ BlazeComponent.extendComponent({ clickOnMiniCard(evt) { if (Utils.isMiniScreen()) { evt.preventDefault(); - Session.set('popupCard', this.currentData()._id); + Session.set('popupCardId', this.currentData()._id); this.cardDetailsPopup(evt); } }, diff --git a/client/lib/utils.js b/client/lib/utils.js index cba1243f7..6395fe741 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -19,7 +19,7 @@ Utils = { return ret; }, getPopupCardId() { - const ret = Session.get('popupCard'); + const ret = Session.get('popupCardId'); return ret; }, /** returns the current board diff --git a/config/router.js b/config/router.js index 2ba95fdcd..a35883ee3 100644 --- a/config/router.js +++ b/config/router.js @@ -12,7 +12,7 @@ FlowRouter.route('/', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); - Session.set('popupCard', null); + Session.set('popupCardId', null); Session.set('popupCardBoardId', null); Filter.reset(); @@ -36,7 +36,7 @@ FlowRouter.route('/public', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); - Session.set('popupCard', null); + Session.set('popupCardId', null); Session.set('popupCardBoardId', null); Filter.reset(); @@ -60,7 +60,7 @@ FlowRouter.route('/b/:id/:slug', { const previousBoard = Session.get('currentBoard'); Session.set('currentBoard', currentBoard); Session.set('currentCard', null); - Session.set('popupCard', null); + Session.set('popupCardId', null); Session.set('popupCardBoardId', null); // If we close a card, we'll execute again this route action but we don't @@ -90,7 +90,7 @@ FlowRouter.route('/b/:boardId/:slug/:cardId', { Session.set('currentBoard', params.boardId); Session.set('currentCard', params.cardId); - Session.set('popupCard', null); + Session.set('popupCardId', null); Session.set('popupCardBoardId', null); Utils.manageCustomUI(); @@ -220,7 +220,7 @@ FlowRouter.route('/import/:source', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); - Session.set('popupCard', null); + Session.set('popupCardId', null); Session.set('popupCardBoardId', null); Session.set('importSource', params.source); @@ -242,7 +242,7 @@ FlowRouter.route('/setting', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); - Session.set('popupCard', null); + Session.set('popupCardId', null); Session.set('popupCardBoardId', null); Filter.reset(); @@ -267,7 +267,7 @@ FlowRouter.route('/information', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); - Session.set('popupCard', null); + Session.set('popupCardId', null); Session.set('popupCardBoardId', null); Filter.reset(); @@ -291,7 +291,7 @@ FlowRouter.route('/people', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); - Session.set('popupCard', null); + Session.set('popupCardId', null); Session.set('popupCardBoardId', null); Filter.reset(); @@ -315,7 +315,7 @@ FlowRouter.route('/admin-reports', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); - Session.set('popupCard', null); + Session.set('popupCardId', null); Session.set('popupCardBoardId', null); Filter.reset(); From 8ec4e1a7d0c1986b03aa430460a3e7aef8d0c49b Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Mon, 8 Nov 2021 12:05:29 +0100 Subject: [PATCH 4/4] Card Details Popup is now modifiable if the user has the permissions --- models/users.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/models/users.js b/models/users.js index 69c6d5e0e..2cefac993 100644 --- a/models/users.js +++ b/models/users.js @@ -458,46 +458,51 @@ Users.safeFields = { if (Meteor.isClient) { Users.helpers({ isBoardMember() { - const board = Boards.findOne(Session.get('currentBoard')); + const board = Utils.getCurrentBoard(); return board && board.hasMember(this._id); }, isNotNoComments() { - const board = Boards.findOne(Session.get('currentBoard')); + const board = Utils.getCurrentBoard(); return ( board && board.hasMember(this._id) && !board.hasNoComments(this._id) ); }, isNoComments() { - const board = Boards.findOne(Session.get('currentBoard')); + const board = Utils.getCurrentBoard(); return board && board.hasNoComments(this._id); }, isNotCommentOnly() { - const board = Boards.findOne(Session.get('currentBoard')); + const board = Utils.getCurrentBoard(); return ( board && board.hasMember(this._id) && !board.hasCommentOnly(this._id) ); }, isCommentOnly() { - const board = Boards.findOne(Session.get('currentBoard')); + const board = Utils.getCurrentBoard(); return board && board.hasCommentOnly(this._id); }, isNotWorker() { - const board = Boards.findOne(Session.get('currentBoard')); + const board = Utils.getCurrentBoard(); return board && board.hasMember(this._id) && !board.hasWorker(this._id); }, isWorker() { - const board = Boards.findOne(Session.get('currentBoard')); + const board = Utils.getCurrentBoard(); return board && board.hasWorker(this._id); }, - isBoardAdmin(boardId = Session.get('currentBoard')) { - const board = Boards.findOne(boardId); + isBoardAdmin(boardId) { + let board; + if (boardId) { + board = Boards.findOne(boardId); + } else { + board = Utils.getCurrentBoard(); + } return board && board.hasAdmin(this._id); }, });