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/components/lists/body.js | 6 ++++-- client/components/lists/main.js | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'client/components/lists') diff --git a/client/components/lists/body.js b/client/components/lists/body.js index a91f0ca9..27864474 100644 --- a/client/components/lists/body.js +++ b/client/components/lists/body.js @@ -27,10 +27,12 @@ BlazeComponent.extendComponent({ var title = textarea.val(); var position = Blaze.getData(evt.currentTarget).position; var sortIndex; + var firstCard = this.find('.js-minicard:first'); + var lastCard = this.find('.js-minicard:last'); if (position === 'top') { - sortIndex = Utils.getSortIndex(null, this.find('.js-minicard:first')); + sortIndex = Utils.calculateIndex(null, firstCard).base; } else if (position === 'bottom') { - sortIndex = Utils.getSortIndex(this.find('.js-minicard:last'), null); + sortIndex = Utils.calculateIndex(lastCard, null).base; } if ($.trim(title)) { 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 } }); } -- cgit v1.2.3-1-g7c22