diff options
author | 蔡仲明 (Romulus Urakagi Tsai) <urakagi@gmail.com> | 2019-11-21 11:25:56 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-21 11:25:56 +0800 |
commit | 3e0bedd8c7a6dec97352212adb1cbde1ade44190 (patch) | |
tree | 651ff30d25ddb0416444370368d699e597c142d7 /client/components/lists/list.js | |
parent | 9bbeb73db1cd0ce1caaaca8dfb14ea92131bbf9d (diff) | |
parent | 4f5de87cc4c2281bd576548693de7c94e6a988c6 (diff) | |
download | wekan-3e0bedd8c7a6dec97352212adb1cbde1ade44190.tar.gz wekan-3e0bedd8c7a6dec97352212adb1cbde1ade44190.tar.bz2 wekan-3e0bedd8c7a6dec97352212adb1cbde1ade44190.zip |
Merge pull request #1 from wekan/master
Update master
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; |