diff options
Diffstat (limited to 'client/components/lists/list.js')
-rw-r--r-- | client/components/lists/list.js | 66 |
1 files changed, 50 insertions, 16 deletions
diff --git a/client/components/lists/list.js b/client/components/lists/list.js index c2b39be9..e58ea430 100644 --- a/client/components/lists/list.js +++ b/client/components/lists/list.js @@ -22,21 +22,15 @@ BlazeComponent.extendComponent({ function userIsMember() { return ( - Meteor.user() && - Meteor.user().isBoardMember() && - !Meteor.user().isCommentOnly() + Meteor.user() + && Meteor.user().isBoardMember() + && !Meteor.user().isCommentOnly() ); } const itemsSelector = '.js-minicard:not(.placeholder, .js-card-composer)'; const $cards = this.$('.js-minicards'); - if (window.matchMedia('(max-width: 1199px)').matches) { - $('.js-minicards').sortable({ - handle: '.handle', - }); - } - $cards.sortable({ connectWith: '.js-minicards:not(.js-list-full)', tolerance: 'pointer', @@ -79,16 +73,15 @@ BlazeComponent.extendComponent({ const listId = Blaze.getData(ui.item.parents('.list').get(0))._id; const currentBoard = Boards.findOne(Session.get('currentBoard')); let swimlaneId = ''; - const boardView = (Meteor.user().profile || {}).boardView; if ( - boardView === 'board-view-swimlanes' || - currentBoard.isTemplatesBoard() + Utils.boardView() === 'board-view-swimlanes' + || currentBoard.isTemplatesBoard() ) swimlaneId = Blaze.getData(ui.item.parents('.swimlane').get(0))._id; else if ( - boardView === 'board-view-lists' || - boardView === 'board-view-cal' || - !boardView + Utils.boardView() === 'board-view-lists' + || Utils.boardView() === 'board-view-cal' + || !Utils.boardView ) swimlaneId = currentBoard.getDefaultSwimline()._id; @@ -122,8 +115,32 @@ BlazeComponent.extendComponent({ // ugly touch event hotfix enableClickOnTouch(itemsSelector); - // Disable drag-dropping if the current user is not a board member or is comment only + import { Cookies } from 'meteor/ostrio:cookies'; + const cookies = new Cookies(); + this.autorun(() => { + let showDesktopDragHandles = false; + currentUser = Meteor.user(); + if (currentUser) { + showDesktopDragHandles = (currentUser.profile || {}) + .showDesktopDragHandles; + } else if (cookies.has('showDesktopDragHandles')) { + showDesktopDragHandles = true; + } else { + showDesktopDragHandles = false; + } + + if (!Utils.isMiniScreen() && showDesktopDragHandles) { + $cards.sortable({ + handle: '.handle', + }); + } else { + $cards.sortable({ + handle: '.minicard', + }); + } + + // Disable drag-dropping if the current user is not a board member or is comment only $cards.sortable('option', 'disabled', !userIsMember()); }); @@ -155,6 +172,23 @@ BlazeComponent.extendComponent({ }, }).register('list'); +Template.list.helpers({ + showDesktopDragHandles() { + currentUser = Meteor.user(); + if (currentUser) { + return (currentUser.profile || {}).showDesktopDragHandles; + } else { + import { Cookies } from 'meteor/ostrio:cookies'; + const cookies = new Cookies(); + if (cookies.has('showDesktopDragHandles')) { + return true; + } else { + return false; + } + } + }, +}); + Template.miniList.events({ 'click .js-select-list'() { const listId = this._id; |