diff --git a/client/components/activities/activities.jade b/client/components/activities/activities.jade index 63d8d9222..6c9fb2e4c 100644 --- a/client/components/activities/activities.jade +++ b/client/components/activities/activities.jade @@ -12,7 +12,7 @@ template(name="boardActivities") +activity(activity=activityData card=card mode=mode) template(name="cardActivities") - each activityData in currentCard.activities + each activityData in activities +activity(activity=activityData card=card mode=mode) template(name="editOrDeleteComment") diff --git a/client/components/activities/activities.js b/client/components/activities/activities.js index f8025d659..de12987c8 100644 --- a/client/components/activities/activities.js +++ b/client/components/activities/activities.js @@ -15,7 +15,7 @@ BlazeComponent.extendComponent({ const capitalizedMode = Utils.capitalize(mode); let thisId, searchId; if (mode === 'linkedcard' || mode === 'linkedboard') { - thisId = Session.get('currentCard'); + thisId = Utils.getCurrentCardId(); searchId = Cards.findOne({ _id: thisId }).linkedId; mode = mode.replace('linked', ''); } else { @@ -54,6 +54,13 @@ BlazeComponent.extendComponent({ }, }).register('activities'); +Template.activities.helpers({ + activities() { + const ret = this.card.activities(); + return ret; + }, +}); + BlazeComponent.extendComponent({ checkItem() { const checkItemId = this.currentData().activity.checklistItemId; diff --git a/client/components/activities/comments.js b/client/components/activities/comments.js index c69ec383e..b9165ce95 100644 --- a/client/components/activities/comments.js +++ b/client/components/activities/comments.js @@ -64,7 +64,7 @@ function resetCommentInput(input) { // Tracker.autorun to register the component dependencies, and re-run when these // dependencies are invalidated. A better component API would remove this hack. Tracker.autorun(() => { - Session.get('currentCard'); + Utils.getCurrentCardId(); Tracker.afterFlush(() => { autosize.update($('.js-new-comment-input')); }); @@ -75,7 +75,7 @@ EscapeActions.register( () => { const draftKey = { fieldName: 'cardComment', - docId: Session.get('currentCard'), + docId: Utils.getCurrentCardId(), }; const commentInput = $('.js-new-comment-input'); const draft = commentInput.val().trim(); diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js index 0195bb545..81846f2ee 100644 --- a/client/components/boards/boardBody.js +++ b/client/components/boards/boardBody.js @@ -23,7 +23,7 @@ BlazeComponent.extendComponent({ }, onlyShowCurrentCard() { - return Utils.isMiniScreen() && Session.get('currentCard'); + return Utils.isMiniScreen() && Utils.getCurrentCardId(true); }, goHome() { @@ -191,21 +191,11 @@ BlazeComponent.extendComponent({ }); this.autorun(() => { - let showDesktopDragHandles = false; - currentUser = Meteor.user(); - if (currentUser) { - showDesktopDragHandles = (currentUser.profile || {}) - .showDesktopDragHandles; - } else if (window.localStorage.getItem('showDesktopDragHandles')) { - showDesktopDragHandles = true; - } else { - showDesktopDragHandles = false; - } - if (Utils.isMiniScreen() || showDesktopDragHandles) { + if (Utils.isMiniScreenOrShowDesktopDragHandles()) { $swimlanesDom.sortable({ handle: '.js-swimlane-header-handle', }); - } else if (!Utils.isMiniScreen() && !showDesktopDragHandles) { + } else { $swimlanesDom.sortable({ handle: '.swimlane-header', }); diff --git a/client/components/boards/boardHeader.js b/client/components/boards/boardHeader.js index c67c60f77..ef1a21fee 100644 --- a/client/components/boards/boardHeader.js +++ b/client/components/boards/boardHeader.js @@ -136,7 +136,7 @@ BlazeComponent.extendComponent({ Sidebar.setView('search'); }, 'click .js-multiselection-activate'() { - const currentCard = Session.get('currentCard'); + const currentCard = Utils.getCurrentCardId(); MultiSelection.activate(); if (currentCard) { MultiSelection.add(currentCard); diff --git a/client/components/cards/cardCustomFields.js b/client/components/cards/cardCustomFields.js index e1b0c7d28..eebdb3692 100644 --- a/client/components/cards/cardCustomFields.js +++ b/client/components/cards/cardCustomFields.js @@ -3,7 +3,7 @@ import Cards from '/models/cards'; Template.cardCustomFieldsPopup.helpers({ hasCustomField() { - const card = Cards.findOne(Session.get('currentCard')); + const card = Utils.getCurrentCard(); const customFieldId = this._id; return card.customFieldIndex(customFieldId) > -1; }, @@ -11,7 +11,7 @@ Template.cardCustomFieldsPopup.helpers({ Template.cardCustomFieldsPopup.events({ 'click .js-select-field'(event) { - const card = Cards.findOne(Session.get('currentCard')); + const card = Utils.getCurrentCard(); const customFieldId = this._id; card.toggleCustomField(customFieldId); event.preventDefault(); @@ -31,7 +31,7 @@ const CardCustomField = BlazeComponent.extendComponent({ onCreated() { const self = this; - self.card = Cards.findOne(Session.get('currentCard')); + self.card = Utils.getCurrentCard(); self.customFieldId = this.data()._id; }, @@ -194,7 +194,7 @@ CardCustomField.register('cardCustomField'); onCreated() { super.onCreated(); const self = this; - self.card = Cards.findOne(Session.get('currentCard')); + self.card = Utils.getCurrentCard(); self.customFieldId = this.data()._id; this.data().value && this.date.set(moment(this.data().value)); } diff --git a/client/components/cards/cardDescription.js b/client/components/cards/cardDescription.js index d83735861..c958c335e 100644 --- a/client/components/cards/cardDescription.js +++ b/client/components/cards/cardDescription.js @@ -25,7 +25,10 @@ BlazeComponent.extendComponent({ // Pressing Ctrl+Enter should submit the form 'keydown form textarea'(evt) { if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) { - this.find('button[type=submit]').click(); + const submitButton = this.find('button[type=submit]'); + if (submitButton) { + submitButton.click(); + } } }, }, diff --git a/client/components/cards/cardDetails.jade b/client/components/cards/cardDetails.jade index c400d4510..0815191c0 100644 --- a/client/components/cards/cardDetails.jade +++ b/client/components/cards/cardDetails.jade @@ -1,5 +1,8 @@ +template(name="cardDetailsPopup") + +cardDetails(popupCard) + template(name="cardDetails") - section.card-details.js-card-details(class='{{#if cardMaximized}}card-details-maximized{{/if}}'): .card-details-canvas + section.card-details.js-card-details(class='{{#if cardMaximized}}card-details-maximized{{/if}}' class='{{#if isPopup}}card-details-popup{{/if}}'): .card-details-canvas .card-details-header(class='{{#if colorClass}}card-details-{{colorClass}}{{/if}}') +inlinedForm(classNames="js-card-details-title") +editCardTitleForm @@ -18,10 +21,14 @@ template(name="cardDetails") title="{{_ 'copy-card-link-to-clipboard'}}" ) if isMiniScreen - a.fa.fa-times-thin.close-card-details-mobile-web.js-close-card-details(title="{{_ 'close-card'}}") + unless isPopup + a.fa.fa-times-thin.close-card-details.js-close-card-details(title="{{_ 'close-card'}}") if currentUser.isBoardMember a.fa.fa-navicon.card-details-menu-mobile-web.js-open-card-details-menu(title="{{_ 'cardDetailsActionsPopup-title'}}") - a.fa.fa-link.card-copy-mobile-button + a.fa.fa-link.card-copy-mobile-button( + class="fa-link" + title="{{_ 'copy-card-link-to-clipboard'}}" + ) h2.card-details-title.js-card-title( class="{{#if canModifyCard}}js-open-inlined-form is-editable{{/if}}") +viewer diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index e2493f5f4..0e613e2be 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -34,11 +34,14 @@ BlazeComponent.extendComponent({ onCreated() { this.currentBoard = Boards.findOne(Session.get('currentBoard')); this.isLoaded = new ReactiveVar(false); - const boardBody = this.parentComponent().parentComponent(); - //in Miniview parent is Board, not BoardBody. - if (boardBody !== null) { - boardBody.showOverlay.set(true); - boardBody.mouseHasEnterCardDetails = false; + + if (this.parentComponent() && this.parentComponent().parentComponent()) { + const boardBody = this.parentComponent().parentComponent(); + //in Miniview parent is Board, not BoardBody. + if (boardBody !== null) { + boardBody.showOverlay.set(true); + boardBody.mouseHasEnterCardDetails = false; + } } this.calculateNextPeak(); @@ -215,7 +218,7 @@ BlazeComponent.extendComponent({ distance: 7, start(evt, ui) { ui.placeholder.height(ui.helper.height()); - EscapeActions.executeUpTo('popup-close'); + EscapeActions.clickExecute(evt.target, 'inlinedForm'); }, stop(evt, ui) { let prevChecklist = ui.item.prev('.js-checklist').get(0); @@ -297,6 +300,7 @@ BlazeComponent.extendComponent({ }, onDestroyed() { + if (this.parentComponent() === null) return; const parentComponent = this.parentComponent().parentComponent(); //on mobile view parent is Board, not board body. if (parentComponent === null) return; @@ -408,6 +412,7 @@ BlazeComponent.extendComponent({ 'click .js-show-positive-votes': Popup.open('positiveVoteMembers'), 'click .js-show-negative-votes': Popup.open('negativeVoteMembers'), 'mouseenter .js-card-details'() { + if (this.parentComponent() === null) return; const parentComponent = this.parentComponent().parentComponent(); //on mobile view parent is Board, not BoardBody. if (parentComponent === null) return; @@ -532,6 +537,22 @@ BlazeComponent.extendComponent({ }, }).register('cardDetails'); +Template.cardDetails.helpers({ + isPopup() { + let ret = !!Utils.getPopupCardId(); + return ret; + } +}); +Template.cardDetailsPopup.onDestroyed(() => { + Session.delete('popupCard'); +}); +Template.cardDetailsPopup.helpers({ + popupCard() { + const ret = Utils.getPopupCard(); + return ret; + }, +}); + BlazeComponent.extendComponent({ template() { return 'exportCard'; @@ -582,16 +603,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()); } } @@ -786,7 +806,7 @@ Template.moveCardPopup.events({ 'click .js-done'() { // XXX We should *not* get the currentCard from the global state, but // instead from a “component” state. - const card = Cards.findOne(Session.get('currentCard')); + const card = Utils.getCurrentCard(); const bSelect = $('.js-select-boards')[0]; let boardId; // if we are a worker, we won't have a board select so we just use the @@ -844,7 +864,7 @@ BlazeComponent.extendComponent({ Template.copyCardPopup.events({ 'click .js-done'() { - const card = Cards.findOne(Session.get('currentCard')); + const card = Utils.getCurrentCard(); const lSelect = $('.js-select-lists')[0]; const listId = lSelect.options[lSelect.selectedIndex].value; const slSelect = $('.js-select-swimlanes')[0]; @@ -873,7 +893,7 @@ Template.copyCardPopup.events({ Template.convertChecklistItemToCardPopup.events({ 'click .js-done'() { - const card = Cards.findOne(Session.get('currentCard')); + const card = Utils.getCurrentCard(); const lSelect = $('.js-select-lists')[0]; const listId = lSelect.options[lSelect.selectedIndex].value; const slSelect = $('.js-select-swimlanes')[0]; @@ -901,7 +921,7 @@ Template.convertChecklistItemToCardPopup.events({ Template.copyChecklistToManyCardsPopup.events({ 'click .js-done'() { - const card = Cards.findOne(Session.get('currentCard')); + const card = Utils.getCurrentCard(); const oldId = card._id; card._id = null; const lSelect = $('.js-select-lists')[0]; @@ -1020,7 +1040,7 @@ BlazeComponent.extendComponent({ }, cards() { - const currentId = Session.get('currentCard'); + const currentId = Utils.getCurrentCardId(); if (this.parentBoard.get()) { return Cards.find({ boardId: this.parentBoard.get(), @@ -1686,7 +1706,7 @@ Template.cardAssigneesPopup.onCreated(function () { Template.cardAssigneesPopup.events({ 'click .js-select-assignee'(event) { - const card = Cards.findOne(Session.get('currentCard')); + const card = Utils.getCurrentCard(); const assigneeId = this.userId; card.toggleAssignee(assigneeId); event.preventDefault(); diff --git a/client/components/cards/cardDetails.styl b/client/components/cards/cardDetails.styl index 9eb64da4e..68688a238 100644 --- a/client/components/cards/cardDetails.styl +++ b/client/components/cards/cardDetails.styl @@ -315,6 +315,21 @@ input[type="submit"].attachment-add-link-submit .minimize-card-details margin-right: 40px + .card-details-popup + padding: 0px 10px + + .pop-over > .content-wrapper > .popup-container-depth-0 + width: 100% + + & > .content + width: calc(100% - 10px) + + & > .content > .card-details-popup + overflow-y: auto + + & hr + margin: 15px 0px + card-details-color(background, color...) background: background !important if color diff --git a/client/components/cards/checklists.jade b/client/components/cards/checklists.jade index 6c7b517c7..06f419282 100644 --- a/client/components/cards/checklists.jade +++ b/client/components/cards/checklists.jade @@ -18,14 +18,14 @@ template(name="checklists") .card-checklist-items - each checklist in currentCard.checklists + each checklist in checklists +checklistDetail(checklist = checklist) if canModifyCard +inlinedForm(autoclose=false classNames="js-add-checklist" cardId = cardId) +addChecklistItemForm else - a.js-open-inlined-form(title="{{_ 'add-checklist'}}") + a.add-checklist.js-open-inlined-form(title="{{_ 'add-checklist'}}") i.fa.fa-plus template(name="checklistDetail") diff --git a/client/components/cards/checklists.js b/client/components/cards/checklists.js index 0141f8ed5..f2dc48dfd 100644 --- a/client/components/cards/checklists.js +++ b/client/components/cards/checklists.js @@ -16,7 +16,7 @@ function initSorting(items) { scroll: false, start(evt, ui) { ui.placeholder.height(ui.helper.height()); - EscapeActions.executeUpTo('popup-close'); + EscapeActions.clickExecute(evt.target, 'inlinedForm'); }, stop(evt, ui) { const parent = ui.item.parents('.js-checklist-items'); @@ -94,16 +94,14 @@ BlazeComponent.extendComponent({ title, sort: card.checklists().count(), }); + this.closeAllInlinedForms(); setTimeout(() => { this.$('.add-checklist-item') .last() .click(); }, 100); } - textarea.value = ''; - textarea.focus(); }, - addChecklistItem(event) { event.preventDefault(); const textarea = this.find('textarea.js-add-checklist-item'); @@ -190,6 +188,10 @@ BlazeComponent.extendComponent({ } }, + closeAllInlinedForms() { + this.$('.js-close-inlined-form').click(); + }, + events() { const events = { 'click .toggle-delete-checklist-dialog'(event) { @@ -214,6 +216,8 @@ BlazeComponent.extendComponent({ 'click .js-delete-checklist-item': this.deleteItem, 'click .confirm-checklist-delete': this.deleteChecklist, 'focus .js-add-checklist-item': this.focusChecklistItem, + 'click .add-checklist-item.js-open-inlined-form': this.closeAllInlinedForms, + 'click .add-checklist.js-open-inlined-form': this.closeAllInlinedForms, keydown: this.pressKey, }, ]; @@ -262,6 +266,11 @@ BlazeComponent.extendComponent({ }).register('boardsSwimlanesAndLists'); Template.checklists.helpers({ + checklists() { + const card = Cards.findOne(this.cardId); + const ret = card.checklists(); + return ret; + }, hideCheckedItems() { const currentUser = Meteor.user(); if (currentUser) return currentUser.hasHideCheckedItems(); diff --git a/client/components/cards/labels.js b/client/components/cards/labels.js index 1e156f542..cf86fa105 100644 --- a/client/components/cards/labels.js +++ b/client/components/cards/labels.js @@ -41,7 +41,7 @@ Template.createLabelPopup.helpers({ Template.cardLabelsPopup.events({ 'click .js-select-label'(event) { - const card = Cards.findOne(Session.get('currentCard')); + const card = Utils.getCurrentCard(); const labelId = this._id; card.toggleLabel(labelId); event.preventDefault(); diff --git a/client/components/cards/minicard.jade b/client/components/cards/minicard.jade index e804b3e4c..45e48e996 100644 --- a/client/components/cards/minicard.jade +++ b/client/components/cards/minicard.jade @@ -2,14 +2,10 @@ template(name="minicard") .minicard( class="{{#if isLinkedCard}}linked-card{{/if}}" class="{{#if isLinkedBoard}}linked-board{{/if}}" - class="minicard-{{colorClass}}") - if isMiniScreen + class="{{#if colorClass}}minicard-{{colorClass}}{{/if}}") + if isMiniScreenOrShowDesktopDragHandles .handle .fa.fa-arrows - unless isMiniScreen - if showDesktopDragHandles - .handle - .fa.fa-arrows if cover .minicard-cover(style="background-image: url('{{cover.url}}');") if labels diff --git a/client/components/cards/minicard.js b/client/components/cards/minicard.js index 9bf687ef9..d0c4929c4 100644 --- a/client/components/cards/minicard.js +++ b/client/components/cards/minicard.js @@ -75,16 +75,6 @@ BlazeComponent.extendComponent({ }).register('minicard'); Template.minicard.helpers({ - showDesktopDragHandles() { - currentUser = Meteor.user(); - if (currentUser) { - return (currentUser.profile || {}).showDesktopDragHandles; - } else if (window.localStorage.getItem('showDesktopDragHandles')) { - return true; - } else { - return false; - } - }, hiddenMinicardLabelText() { currentUser = Meteor.user(); if (currentUser) { diff --git a/client/components/lists/list.js b/client/components/lists/list.js index 1cfbaff9a..b5f829f25 100644 --- a/client/components/lists/list.js +++ b/client/components/lists/list.js @@ -117,22 +117,11 @@ BlazeComponent.extendComponent({ }); this.autorun(() => { - let showDesktopDragHandles = false; - currentUser = Meteor.user(); - if (currentUser) { - showDesktopDragHandles = (currentUser.profile || {}) - .showDesktopDragHandles; - } else if (window.localStorage.getItem('showDesktopDragHandles')) { - showDesktopDragHandles = true; - } else { - showDesktopDragHandles = false; - } - - if (Utils.isMiniScreen() || showDesktopDragHandles) { + if (Utils.isMiniScreenOrShowDesktopDragHandles()) { $cards.sortable({ handle: '.handle', }); - } else if (!Utils.isMiniScreen() && !showDesktopDragHandles) { + } else { $cards.sortable({ handle: '.minicard', }); @@ -178,19 +167,6 @@ BlazeComponent.extendComponent({ }, }).register('list'); -Template.list.helpers({ - showDesktopDragHandles() { - currentUser = Meteor.user(); - if (currentUser) { - return (currentUser.profile || {}).showDesktopDragHandles; - } else if (window.localStorage.getItem('showDesktopDragHandles')) { - return true; - } else { - return false; - } - }, -}); - Template.miniList.events({ 'click .js-select-list'() { const listId = this._id; diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index fcd28b644..aa33e65c7 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -148,6 +148,10 @@ 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()) { + evt.preventDefault(); + Session.set('popupCard', this.currentData()._id); + this.cardDetailsPopup(evt); } else if (Session.equals('currentCard', this.currentData()._id)) { evt.stopImmediatePropagation(); evt.preventDefault(); @@ -216,6 +220,12 @@ BlazeComponent.extendComponent({ ); }, + cardDetailsPopup(event) { + if (!Popup.isOpen()) { + Popup.open("cardDetails")(event); + } + }, + events() { return [ { diff --git a/client/components/lists/listHeader.jade b/client/components/lists/listHeader.jade index c01e9d616..866665308 100644 --- a/client/components/lists/listHeader.jade +++ b/client/components/lists/listHeader.jade @@ -44,7 +44,7 @@ template(name="listHeader") a.js-add-card.fa.fa-plus.list-header-plus-icon(title="{{_ 'add-card-to-top-of-list'}}") a.fa.fa-navicon.js-open-list-menu(title="{{_ 'listActionPopup-title'}}") if currentUser.isBoardAdmin - if showDesktopDragHandles + if isShowDesktopDragHandles a.list-header-handle.handle.fa.fa-arrows.js-list-handle template(name="editListTitleForm") diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js index 91d6064cd..e9a8b2676 100644 --- a/client/components/lists/listHeader.js +++ b/client/components/lists/listHeader.js @@ -122,18 +122,7 @@ BlazeComponent.extendComponent({ Template.listHeader.helpers({ isBoardAdmin() { return Meteor.user().isBoardAdmin(); - }, - - showDesktopDragHandles() { - currentUser = Meteor.user(); - if (currentUser) { - return (currentUser.profile || {}).showDesktopDragHandles; - } else if (window.localStorage.getItem('showDesktopDragHandles')) { - return true; - } else { - return false; - } - }, + } }); Template.listActionPopup.helpers({ diff --git a/client/components/main/editor.js b/client/components/main/editor.js index 9c8cd0483..34ada0e24 100644 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -150,7 +150,7 @@ Template.editor.onRendered(() => { const $summernote = getSummernote(this); if (files && files.length > 0) { const image = files[0]; - const currentCard = Cards.findOne(Session.get('currentCard')); + const currentCard = Utils.getCurrentCard(); const MAX_IMAGE_PIXEL = Utils.MAX_IMAGE_PIXEL; const COMPRESS_RATIO = Utils.IMAGE_COMPRESS_RATIO; const insertImage = src => { diff --git a/client/components/main/popup.styl b/client/components/main/popup.styl index 91f5fa039..24a864722 100644 --- a/client/components/main/popup.styl +++ b/client/components/main/popup.styl @@ -14,8 +14,7 @@ $popupWidth = 300px margin-top: 5px hr - margin: 4px -10px - width: $popupWidth + margin: 4px 0px p, textarea, @@ -23,7 +22,6 @@ $popupWidth = 300px input[type="email"], input[type="password"], input[type="file"] - margin: 4px 0 12px width: 100% select @@ -313,22 +311,13 @@ $popupWidth = 300px input[type="email"], input[type="password"], input[type="file"] - margin: 4px 0 12px width: 100% box-sizing: border-box .pop-over-list li > a width: calc(100% - 20px) - padding: 10px 10px margin: 0px 0px - border-bottom: 1px solid #eee - - hr - width: 100% - height: 20px - margin: 0px 0px - color: #eee for depth in (1..6) .popup-container-depth-{depth} diff --git a/client/components/swimlanes/swimlaneHeader.jade b/client/components/swimlanes/swimlaneHeader.jade index 5319402c2..072b7ccee 100644 --- a/client/components/swimlanes/swimlaneHeader.jade +++ b/client/components/swimlanes/swimlaneHeader.jade @@ -26,7 +26,7 @@ template(name="swimlaneFixedHeader") a.fa.fa-plus.js-open-add-swimlane-menu.swimlane-header-plus-icon(title="{{_ 'add-swimlane'}}") a.fa.fa-navicon.js-open-swimlane-menu(title="{{_ 'swimlaneActionPopup-title'}}") unless isMiniScreen - if showDesktopDragHandles + if isShowDesktopDragHandles a.swimlane-header-handle.handle.fa.fa-arrows.js-swimlane-header-handle if isMiniScreen a.swimlane-header-miniscreen-handle.handle.fa.fa-arrows.js-swimlane-header-handle diff --git a/client/components/swimlanes/swimlaneHeader.js b/client/components/swimlanes/swimlaneHeader.js index 9d01ee34c..b941d46ed 100644 --- a/client/components/swimlanes/swimlaneHeader.js +++ b/client/components/swimlanes/swimlaneHeader.js @@ -28,19 +28,6 @@ BlazeComponent.extendComponent({ }, }).register('swimlaneHeader'); -Template.swimlaneHeader.helpers({ - showDesktopDragHandles() { - currentUser = Meteor.user(); - if (currentUser) { - return (currentUser.profile || {}).showDesktopDragHandles; - } else if (window.localStorage.getItem('showDesktopDragHandles')) { - return true; - } else { - return false; - } - }, -}); - Template.swimlaneFixedHeader.helpers({ isBoardAdmin() { return Meteor.user().isBoardAdmin(); diff --git a/client/components/swimlanes/swimlanes.js b/client/components/swimlanes/swimlanes.js index b6fe744b5..c099ed16e 100644 --- a/client/components/swimlanes/swimlanes.js +++ b/client/components/swimlanes/swimlanes.js @@ -9,7 +9,7 @@ function currentListIsInThisSwimlane(swimlaneId) { } function currentCardIsInThisList(listId, swimlaneId) { - const currentCard = Cards.findOne(Session.get('currentCard')); + const currentCard = Utils.getCurrentCard(); const currentUser = Meteor.user(); if ( currentUser && @@ -95,22 +95,11 @@ function initSortable(boardComponent, $listsDom) { //} boardComponent.autorun(() => { - let showDesktopDragHandles = false; - currentUser = Meteor.user(); - if (currentUser) { - showDesktopDragHandles = (currentUser.profile || {}) - .showDesktopDragHandles; - } else if (window.localStorage.getItem('showDesktopDragHandles')) { - showDesktopDragHandles = true; - } else { - showDesktopDragHandles = false; - } - - if (Utils.isMiniScreen() || showDesktopDragHandles) { + if (Utils.isMiniScreenOrShowDesktopDragHandles()) { $listsDom.sortable({ handle: '.js-list-handle', }); - } else if (!Utils.isMiniScreen() && !showDesktopDragHandles) { + } else { $listsDom.sortable({ handle: '.js-list-header', }); @@ -136,7 +125,7 @@ BlazeComponent.extendComponent({ const boardComponent = this.parentComponent(); const $listsDom = this.$('.js-lists'); - if (!Session.get('currentCard')) { + if (!Utils.getCurrentCardId()) { boardComponent.scrollLeft(); } @@ -172,19 +161,8 @@ BlazeComponent.extendComponent({ // the user will legitimately expect to be able to select some text with // his mouse. - let showDesktopDragHandles = false; - currentUser = Meteor.user(); - if (currentUser) { - showDesktopDragHandles = (currentUser.profile || {}) - .showDesktopDragHandles; - } else if (window.localStorage.getItem('showDesktopDragHandles')) { - showDesktopDragHandles = true; - } else { - showDesktopDragHandles = false; - } - const noDragInside = ['a', 'input', 'textarea', 'p'].concat( - Utils.isMiniScreen() || showDesktopDragHandles + Utils.isMiniScreenOrShowDesktopDragHandles() ? ['.js-list-handle', '.js-swimlane-header-handle'] : ['.js-list-header'], ); @@ -264,16 +242,6 @@ BlazeComponent.extendComponent({ }).register('addListForm'); Template.swimlane.helpers({ - showDesktopDragHandles() { - currentUser = Meteor.user(); - if (currentUser) { - return (currentUser.profile || {}).showDesktopDragHandles; - } else if (window.localStorage.getItem('showDesktopDragHandles')) { - return true; - } else { - return false; - } - }, canSeeAddList() { return Meteor.user().isBoardAdmin(); /* @@ -316,7 +284,7 @@ BlazeComponent.extendComponent({ const boardComponent = this.parentComponent(); const $listsDom = this.$('.js-lists'); - if (!Session.get('currentCard')) { + if (!Utils.getCurrentCardId()) { boardComponent.scrollLeft(); } diff --git a/client/components/users/userAvatar.js b/client/components/users/userAvatar.js index 3fe008ca3..00e63fa7f 100644 --- a/client/components/users/userAvatar.js +++ b/client/components/users/userAvatar.js @@ -274,7 +274,7 @@ Template.cardMembersPopup.helpers({ Template.cardMembersPopup.events({ 'click .js-select-member'(event) { - const card = Cards.findOne(Session.get('currentCard')); + const card = Utils.getCurrentCard(); const memberId = this.userId; card.toggleMember(memberId); event.preventDefault(); diff --git a/client/components/users/userHeader.jade b/client/components/users/userHeader.jade index 98e8c36b9..d5fe14739 100644 --- a/client/components/users/userHeader.jade +++ b/client/components/users/userHeader.jade @@ -134,7 +134,7 @@ template(name="changeSettingsPopup") a.js-toggle-desktop-drag-handles i.fa.fa-arrows | {{_ 'show-desktop-drag-handles'}} - if showDesktopDragHandles + if isShowDesktopDragHandles i.fa.fa-check unless currentUser.isWorker li diff --git a/client/components/users/userHeader.js b/client/components/users/userHeader.js index 7088e4309..1270eff39 100644 --- a/client/components/users/userHeader.js +++ b/client/components/users/userHeader.js @@ -259,16 +259,6 @@ Template.changeLanguagePopup.events({ }); Template.changeSettingsPopup.helpers({ - showDesktopDragHandles() { - currentUser = Meteor.user(); - if (currentUser) { - return (currentUser.profile || {}).showDesktopDragHandles; - } else if (window.localStorage.getItem('showDesktopDragHandles')) { - return true; - } else { - return false; - } - }, hiddenSystemMessages() { currentUser = Meteor.user(); if (currentUser) { 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/datepicker.js b/client/lib/datepicker.js index ef5b91768..f57bcdaa3 100644 --- a/client/lib/datepicker.js +++ b/client/lib/datepicker.js @@ -120,7 +120,7 @@ export class DatePicker extends BlazeComponent { } if (newCompleteDate.isValid()) { this._storeDate(newCompleteDate.toDate()); - Popup.close(); + Popup.back(); } else if (!this.error) { this.error.set('invalid'); } @@ -128,7 +128,7 @@ export class DatePicker extends BlazeComponent { 'click .js-delete-date'(evt) { evt.preventDefault(); this._deleteDate(); - Popup.close(); + Popup.back(); }, }, ]; diff --git a/client/lib/inlinedform.js b/client/lib/inlinedform.js index f2ebe31e0..f0d2cc130 100644 --- a/client/lib/inlinedform.js +++ b/client/lib/inlinedform.js @@ -29,10 +29,15 @@ InlinedForm = BlazeComponent.extendComponent({ }, open(evt) { - evt && evt.preventDefault(); + if (evt) { + evt.preventDefault(); + // Close currently opened form, if any + EscapeActions.clickExecute(evt.target, 'inlinedForm'); + } else { + // Close currently opened form, if any + EscapeActions.executeUpTo('inlinedForm'); + } - // Close currently opened form, if any - EscapeActions.executeUpTo('inlinedForm'); this.isOpen.set(true); currentlyOpenedForm.set(this); }, @@ -44,7 +49,7 @@ InlinedForm = BlazeComponent.extendComponent({ getValue() { const input = this.find('textarea,input[type=text]'); - return this.isOpen.get() && input && input.value; + return this.isOpen.get() && input && input.value.replaceAll(/\s +$/gm, ''); }, events() { diff --git a/client/lib/keyboard.js b/client/lib/keyboard.js index 9f35009d3..4384fe135 100644 --- a/client/lib/keyboard.js +++ b/client/lib/keyboard.js @@ -54,7 +54,7 @@ Mousetrap.bind('/', () => { }); Mousetrap.bind(['down', 'up'], (evt, key) => { - if (!Session.get('currentCard')) { + if (!Utils.getCurrentCardId()) { return; } diff --git a/client/lib/popup.js b/client/lib/popup.js index cae226594..fa9e125bb 100644 --- a/client/lib/popup.js +++ b/client/lib/popup.js @@ -201,7 +201,7 @@ escapeActions.forEach(actionName => { () => Popup[actionName](), () => Popup.isOpen(), { - noClickEscapeOn: '.js-pop-over,.js-open-card-title-popup', + noClickEscapeOn: '.js-pop-over,.js-open-card-title-popup,.js-open-inlined-form', enabledOnClick: actionName === 'close', }, ); diff --git a/client/lib/utils.js b/client/lib/utils.js index f8f684325..3e2cad868 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -1,4 +1,25 @@ Utils = { + getCurrentCardId(ignorePopupCard) { + let ret = Session.get('currentCard'); + if (!ret && !ignorePopupCard) { + ret = Utils.getPopupCardId(); + } + return ret; + }, + getPopupCardId() { + const ret = Session.get('popupCard'); + return ret; + }, + getCurrentCard(ignorePopupCard) { + const cardId = Utils.getCurrentCardId(ignorePopupCard); + 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. @@ -248,6 +269,8 @@ Utils = { const currentUser = Meteor.user(); if (currentUser) { return (currentUser.profile || {}).showDesktopDragHandles; + } else if (window.localStorage.getItem('showDesktopDragHandles')) { + return true; } else { return false; } diff --git a/config/router.js b/config/router.js index 372f17c7e..dec27ba21 100644 --- a/config/router.js +++ b/config/router.js @@ -12,6 +12,7 @@ FlowRouter.route('/', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); + Session.set('popupCard', null); Filter.reset(); Session.set('sortBy', ''); @@ -34,6 +35,7 @@ FlowRouter.route('/public', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); + Session.set('popupCard', null); Filter.reset(); Session.set('sortBy', ''); @@ -56,6 +58,7 @@ FlowRouter.route('/b/:id/:slug', { const previousBoard = Session.get('currentBoard'); Session.set('currentBoard', currentBoard); Session.set('currentCard', null); + Session.set('popupCard', 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.) @@ -84,6 +87,7 @@ FlowRouter.route('/b/:boardId/:slug/:cardId', { Session.set('currentBoard', params.boardId); Session.set('currentCard', params.cardId); + Session.set('popupCard', null); Utils.manageCustomUI(); Utils.manageMatomo(); @@ -212,6 +216,7 @@ FlowRouter.route('/import/:source', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); + Session.set('popupCard', null); Session.set('importSource', params.source); Filter.reset(); @@ -232,6 +237,7 @@ FlowRouter.route('/setting', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); + Session.set('popupCard', null); Filter.reset(); Session.set('sortBy', ''); @@ -255,6 +261,7 @@ FlowRouter.route('/information', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); + Session.set('popupCard', null); Filter.reset(); Session.set('sortBy', ''); @@ -277,6 +284,7 @@ FlowRouter.route('/people', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); + Session.set('popupCard', null); Filter.reset(); Session.set('sortBy', ''); @@ -299,6 +307,7 @@ FlowRouter.route('/admin-reports', { Session.set('currentBoard', null); Session.set('currentList', null); Session.set('currentCard', null); + Session.set('popupCard', null); Filter.reset(); Session.set('sortBy', ''); diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index e537db041..72abc2a37 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -1086,5 +1086,6 @@ "request": "Request", "requests": "Requests", "help-request": "Help Request", - "editCardSortOrderPopup-title": "Change Sorting" + "editCardSortOrderPopup-title": "Change Sorting", + "cardDetailsPopup-title": "Card Details" }