diff options
Diffstat (limited to 'client/components/boards/boardBody.js')
-rw-r--r-- | client/components/boards/boardBody.js | 65 |
1 files changed, 52 insertions, 13 deletions
diff --git a/client/components/boards/boardBody.js b/client/components/boards/boardBody.js index 47042ae7..e70a9f67 100644 --- a/client/components/boards/boardBody.js +++ b/client/components/boards/boardBody.js @@ -1,3 +1,5 @@ +import { Cookies } from 'meteor/ostrio:cookies'; +const cookies = new Cookies(); const subManager = new SubsManager(); const { calculateIndex, enableClickOnTouch } = Utils; const swimlaneWhileSortingHeight = 150; @@ -89,7 +91,6 @@ BlazeComponent.extendComponent({ helper.append(list.clone()); return helper; }, - handle: '.js-swimlane-header-handle', items: '.swimlane:not(.placeholder)', placeholder: 'swimlane placeholder', distance: 7, @@ -193,6 +194,32 @@ BlazeComponent.extendComponent({ // ugly touch event hotfix enableClickOnTouch('.js-swimlane:not(.placeholder)'); + 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) { + $swimlanesDom.sortable({ + handle: '.js-swimlane-header-handle', + }); + } else if (!Utils.isMiniScreen() && !showDesktopDragHandles) { + $swimlanesDom.sortable({ + handle: '.swimlane-header', + }); + } + + // Disable drag-dropping if the current user is not a board member or is miniscreen + $swimlanesDom.sortable('option', 'disabled', !userIsMember()); + $swimlanesDom.sortable('option', 'disabled', Utils.isMiniScreen()); + }); + function userIsMember() { return ( Meteor.user() && @@ -210,21 +237,30 @@ BlazeComponent.extendComponent({ }, isViewSwimlanes() { - const currentUser = Meteor.user(); - if (!currentUser) return false; - return (currentUser.profile || {}).boardView === 'board-view-swimlanes'; + currentUser = Meteor.user(); + if (currentUser) { + return (currentUser.profile || {}).boardView === 'board-view-swimlanes'; + } else { + return cookies.get('boardView') === 'board-view-swimlanes'; + } }, isViewLists() { - const currentUser = Meteor.user(); - if (!currentUser) return true; - return (currentUser.profile || {}).boardView === 'board-view-lists'; + currentUser = Meteor.user(); + if (currentUser) { + return (currentUser.profile || {}).boardView === 'board-view-lists'; + } else { + return cookies.get('boardView') === 'board-view-lists'; + } }, isViewCalendar() { - const currentUser = Meteor.user(); - if (!currentUser) return false; - return (currentUser.profile || {}).boardView === 'board-view-cal'; + currentUser = Meteor.user(); + if (currentUser) { + return (currentUser.profile || {}).boardView === 'board-view-cal'; + } else { + return cookies.get('boardView') === 'board-view-cal'; + } }, openNewListForm() { @@ -381,8 +417,11 @@ BlazeComponent.extendComponent({ }; }, isViewCalendar() { - const currentUser = Meteor.user(); - if (!currentUser) return false; - return (currentUser.profile || {}).boardView === 'board-view-cal'; + currentUser = Meteor.user(); + if (currentUser) { + return (currentUser.profile || {}).boardView === 'board-view-cal'; + } else { + return cookies.get('boardView') === 'board-view-cal'; + } }, }).register('calendarView'); |