diff --git a/client/components/cards/cardDetails.jade b/client/components/cards/cardDetails.jade index 607e9eeb6..85b047780 100644 --- a/client/components/cards/cardDetails.jade +++ b/client/components/cards/cardDetails.jade @@ -1,5 +1,5 @@ template(name="cardDetailsPopup") - +cardDetails + +cardDetails(popupCard) template(name="cardDetails") section.card-details.js-card-details(class='{{#if cardMaximized}}card-details-maximized{{/if}}' class='{{#if isMiniScreen}}card-details-popup{{/if}}'): .card-details-canvas diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index 349238290..f47806335 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -537,6 +537,13 @@ BlazeComponent.extendComponent({ }, }).register('cardDetails'); +Template.cardDetailsPopup.helpers({ + popupCard() { + const ret = Utils.getPopupCard(); + return ret; + }, +}); + BlazeComponent.extendComponent({ template() { return 'exportCard'; @@ -587,16 +594,15 @@ Template.editCardSortOrderForm.onRendered(function () { // XXX Recovering the currentCard identifier form a session variable is // fragile because this variable may change for instance if the route // change. We should use some component props instead. - docId: Session.get('currentCard'), + docId: Utils.getCurrentCardId(), }; } close(isReset = false) { if (this.isOpen.get() && !isReset) { const draft = this.getValue().trim(); - if ( - draft !== Cards.findOne(Session.get('currentCard')).getDescription() - ) { + let card = Utils.getCurrentCard(); + if (card && draft !== card.getDescription()) { UnsavedEdits.set(this._getUnsavedEditKey(), this.getValue()); } } diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index 167947dfe..9afa5d47f 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -148,6 +148,8 @@ BlazeComponent.extendComponent({ // If the card is already selected, we want to de-select it. // XXX We should probably modify the minicard href attribute instead of // overwriting the event in case the card is already selected. + } else if (Utils.isMiniScreen()) { + Session.set('popupCard', this.currentData()._id); } else if (Session.equals('currentCard', this.currentData()._id)) { evt.stopImmediatePropagation(); evt.preventDefault(); diff --git a/client/config/blazeHelpers.js b/client/config/blazeHelpers.js index a4c610612..741b2fc58 100644 --- a/client/config/blazeHelpers.js +++ b/client/config/blazeHelpers.js @@ -8,12 +8,8 @@ Blaze.registerHelper('currentBoard', () => { }); Blaze.registerHelper('currentCard', () => { - const cardId = Session.get('currentCard'); - if (cardId) { - return Cards.findOne(cardId); - } else { - return null; - } + const ret = Utils.getCurrentCard(); + return ret; }); Blaze.registerHelper('currentList', () => { diff --git a/client/lib/utils.js b/client/lib/utils.js index 3c1e79f93..92e08b3f9 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -1,4 +1,25 @@ Utils = { + getCurrentCardId() { + let ret = Session.get('currentCard'); + if (!ret) { + ret = Utils.getPopupCardId(); + } + return ret; + }, + getPopupCardId() { + const ret = Session.get('popupCard'); + return ret; + }, + getCurrentCard() { + const cardId = Utils.getCurrentCardId(); + const ret = Cards.findOne(cardId); + return ret; + }, + getPopupCard() { + const cardId = Utils.getPopupCardId(); + const ret = Cards.findOne(cardId); + return ret; + }, reload () { // we move all window.location.reload calls into this function // so we can disable it when running tests.