From 5478fc93dbe3be14c4a38754881e00dc0b6a38f9 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Mon, 15 Jun 2015 17:16:56 +0200 Subject: Improve the multi-selection experience New features: - select all filtered cards - assign or unassign a member to selected cards - archive selected cards This commit also fix the card sort indexes calculation when a multi- selection is drag-dropped. --- client/lib/escapeActions.js | 2 +- client/lib/multiSelection.js | 12 +++++++++--- client/lib/utils.js | 13 ++++++++----- 3 files changed, 18 insertions(+), 9 deletions(-) (limited to 'client/lib') diff --git a/client/lib/escapeActions.js b/client/lib/escapeActions.js index 5d8a1f25..c1a8cca5 100644 --- a/client/lib/escapeActions.js +++ b/client/lib/escapeActions.js @@ -153,6 +153,6 @@ Mousetrap.bindGlobal('esc', function() { $(document).on('click', function(evt) { if (evt.which === 1 && $(evt.target).closest('a,button,.is-editable').length === 0) { - EscapeActions.clickExecute(evt, 'detailsPane'); + EscapeActions.clickExecute(evt, 'multiselection'); } }); diff --git a/client/lib/multiSelection.js b/client/lib/multiSelection.js index 2f96e199..e6db42cd 100644 --- a/client/lib/multiSelection.js +++ b/client/lib/multiSelection.js @@ -72,17 +72,21 @@ MultiSelection = { return this._isActive.get(); }, + count: function() { + return Cards.find(this.getMongoSelector()).count(); + }, + isEmpty: function() { - return this._selectedCards.get().length === 0; + return this.count() === 0; }, activate: function() { if (! this.isActive()) { EscapeActions.executeUpTo('detailsPane'); this._isActive.set(true); - Sidebar.setView(this.sidebarView); Tracker.flush(); } + Sidebar.setView(this.sidebarView); }, disable: function() { @@ -152,5 +156,7 @@ Blaze.registerHelper('MultiSelection', MultiSelection); EscapeActions.register('multiselection', function() { MultiSelection.disable(); }, - function() { return MultiSelection.isActive(); } + function() { return MultiSelection.isActive(); }, { + noClickEscapeOn: '.js-minicard,.js-board-sidebar-content' + } ); diff --git a/client/lib/utils.js b/client/lib/utils.js index b9954212..121b3c2b 100644 --- a/client/lib/utils.js +++ b/client/lib/utils.js @@ -37,23 +37,26 @@ Utils = { }, // Determine the new sort index - getSortIndex: function(prevCardDomElement, nextCardDomElement) { + calculateIndex: function(prevCardDomElement, nextCardDomElement, nCards) { + nCards = nCards || 1; + // If we drop the card to an empty column if (! prevCardDomElement && ! nextCardDomElement) { - return 0; + return {base: 0, increment: 1}; // If we drop the card in the first position } else if (! prevCardDomElement) { - return Blaze.getData(nextCardDomElement).sort - 1; + return {base: Blaze.getData(nextCardDomElement).sort - 1, increment: -1}; // If we drop the card in the last position } else if (! nextCardDomElement) { - return Blaze.getData(prevCardDomElement).sort + 1; + return {base: Blaze.getData(prevCardDomElement).sort + 1, increment: 1}; } // In the general case take the average of the previous and next element // sort indexes. else { var prevSortIndex = Blaze.getData(prevCardDomElement).sort; var nextSortIndex = Blaze.getData(nextCardDomElement).sort; - return (prevSortIndex + nextSortIndex) / 2; + var increment = (nextSortIndex - prevSortIndex) / (nCards + 1); + return {base: prevSortIndex + increment, increment: increment}; } } }; -- cgit v1.2.3-1-g7c22