Merge pull request #4142 from mfilser/global_search_load_card_details

Global search load card details
This commit is contained in:
Lauri Ojansivu 2021-11-15 12:54:46 +02:00 committed by GitHub
commit 25024fbe6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 86 additions and 31 deletions

View file

@ -546,7 +546,8 @@ Template.cardDetails.helpers({
}
});
Template.cardDetailsPopup.onDestroyed(() => {
Session.delete('popupCard');
Session.delete('popupCardId');
Session.delete('popupCardBoardId');
});
Template.cardDetailsPopup.helpers({
popupCard() {

View file

@ -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('popupCardId', cardId);
Session.set('popupCardBoardId', boardId);
this_.cardDetailsPopup(evt);
},
});
},
cardDetailsPopup(event) {

View file

@ -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();

View file

@ -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);
}
},

View file

@ -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', () => {

View file

@ -1,4 +1,16 @@
Utils = {
/** returns the current board id
* <li> 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) {
@ -7,7 +19,15 @@ Utils = {
return ret;
},
getPopupCardId() {
const ret = Session.get('popupCard');
const ret = Session.get('popupCardId');
return ret;
},
/** returns the current board
* <li> 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) {

View file

@ -12,7 +12,8 @@ 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();
Session.set('sortBy', '');
@ -35,7 +36,8 @@ 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();
Session.set('sortBy', '');
@ -58,7 +60,8 @@ 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
// want to excape every current actions (filters, etc.)
@ -87,7 +90,8 @@ 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();
Utils.manageMatomo();
@ -216,7 +220,8 @@ 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);
Filter.reset();
@ -237,7 +242,8 @@ 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();
Session.set('sortBy', '');
@ -261,7 +267,8 @@ 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();
Session.set('sortBy', '');
@ -284,7 +291,8 @@ 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();
Session.set('sortBy', '');
@ -307,7 +315,8 @@ 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();
Session.set('sortBy', '');

View file

@ -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);
},
});

View file

@ -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) {
@ -489,6 +504,7 @@ function buildProjection(query) {
labelIds: 1,
customFields: 1,
userId: 1,
description: 1,
},
sort: {
boardId: 1,