diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-06-15 17:16:56 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-06-16 14:30:21 +0200 |
commit | 5478fc93dbe3be14c4a38754881e00dc0b6a38f9 (patch) | |
tree | 8b40a29a3cbe07747112e809db3fd12b719ae3bf /client/lib/utils.js | |
parent | a41e07b37ec9243191804ac2966e2d136ce79710 (diff) | |
download | wekan-5478fc93dbe3be14c4a38754881e00dc0b6a38f9.tar.gz wekan-5478fc93dbe3be14c4a38754881e00dc0b6a38f9.tar.bz2 wekan-5478fc93dbe3be14c4a38754881e00dc0b6a38f9.zip |
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.
Diffstat (limited to 'client/lib/utils.js')
-rw-r--r-- | client/lib/utils.js | 13 |
1 files changed, 8 insertions, 5 deletions
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}; } } }; |