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/components/lists/main.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/components/lists/main.js')
-rw-r--r-- | client/components/lists/main.js | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/client/components/lists/main.js b/client/components/lists/main.js index 520d0772..c7f3f5e8 100644 --- a/client/components/lists/main.js +++ b/client/components/lists/main.js @@ -56,22 +56,23 @@ BlazeComponent.extendComponent({ stop: function(evt, ui) { // To attribute the new index number, we need to get the dom element // of the previous and the following card -- if any. - var cardDomElement = ui.item.get(0); - var prevCardDomElement = ui.item.prev('.js-minicard').get(0); - var nextCardDomElement = ui.item.next('.js-minicard').get(0); - var sort = Utils.getSortIndex(prevCardDomElement, nextCardDomElement); + var prevCardDom = ui.item.prev('.js-minicard').get(0); + var nextCardDom = ui.item.next('.js-minicard').get(0); + var nCards = MultiSelection.isActive() ? MultiSelection.count() : 1; + var sortIndex = Utils.calculateIndex(prevCardDom, nextCardDom, nCards); var listId = Blaze.getData(ui.item.parents('.list').get(0))._id; if (MultiSelection.isActive()) { - Cards.find(MultiSelection.getMongoSelector()).forEach(function(c) { + Cards.find(MultiSelection.getMongoSelector()).forEach(function(c, i) { Cards.update(c._id, { $set: { listId: listId, - sort: sort + sort: sortIndex.base + i * sortIndex.increment } }); }); } else { + var cardDomElement = ui.item.get(0); var cardId = Blaze.getData(cardDomElement)._id; Cards.update(cardId, { $set: { @@ -79,7 +80,7 @@ BlazeComponent.extendComponent({ // XXX Using the same sort index for multiple cards is // unacceptable. Keep that only until we figure out if we want to // refactor the whole sorting mecanism or do something more basic. - sort: sort + sort: sortIndex.base } }); } |