diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index 17b651734..fa7fe96aa 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -977,10 +977,11 @@ BlazeComponent.extendComponent({ cards() { const currentId = Utils.getCurrentCardId(); if (this.parentBoard.get()) { - return Cards.find({ + const ret = ReactiveCache.getCards({ boardId: this.parentBoard.get(), _id: { $ne: currentId }, }); + return ret; } else { return []; } @@ -1023,7 +1024,7 @@ BlazeComponent.extendComponent({ 'click .js-delete': Popup.afterConfirm('cardDelete', function () { Popup.close(); // verify that there are no linked cards - if (Cards.find({ linkedId: this._id }).count() === 0) { + if (ReactiveCache.getCards({ linkedId: this._id }).length === 0) { Cards.remove(this._id); } else { // TODO: Maybe later we can list where the linked cards are. diff --git a/client/components/lists/list.js b/client/components/lists/list.js index c3cacdb90..902df3427 100644 --- a/client/components/lists/list.js +++ b/client/components/lists/list.js @@ -90,7 +90,7 @@ BlazeComponent.extendComponent({ $cards.sortable('cancel'); if (MultiSelection.isActive()) { - Cards.find(MultiSelection.getMongoSelector(), { sort: ['sort'] }).forEach((card, i) => { + ReactiveCache.getCards(MultiSelection.getMongoSelector(), { sort: ['sort'] }).forEach((card, i) => { const newSwimlaneId = targetSwimlaneId ? targetSwimlaneId : card.swimlaneId || defaultSwimlaneId; @@ -174,7 +174,6 @@ BlazeComponent.extendComponent({ const currentBoardId = Tracker.nonreactive(() => { return Session.get('currentBoard'); }); - Cards.find({ boardId: currentBoardId }).fetch(); Tracker.afterFlush(() => { $cards.find(itemsSelector).droppable({ hoverClass: 'draggable-hover-card', diff --git a/client/components/lists/listBody.jade b/client/components/lists/listBody.jade index 7102b6756..375d99f1b 100644 --- a/client/components/lists/listBody.jade +++ b/client/components/lists/listBody.jade @@ -1,7 +1,7 @@ template(name="listBody") .list-body .minicards.clearfix.js-minicards(class="{{#if reachedWipLimit}}js-list-full{{/if}}") - if cards.count + if cards.length +inlinedForm(autoclose=false position="top") +addCardForm(listId=_id position="top") ul.sidebar-list diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index 1578cc7c2..99458977b 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -113,7 +113,7 @@ BlazeComponent.extendComponent({ // to appear const cardCount = this.data() .cards(this.idOrNull(swimlaneId)) - .count(); + .length; if (this.cardlimit.get() < cardCount) { this.cardlimit.set(this.cardlimit.get() + InfiniteScrollIter); } @@ -201,16 +201,17 @@ BlazeComponent.extendComponent({ archived: false, }; if (swimlaneId) selector.swimlaneId = swimlaneId; - return Cards.find(Filter.mongoSelector(selector), { + const ret = ReactiveCache.getCards(Filter.mongoSelector(selector), { // sort: ['sort'], sort: sortBy, limit, }); + return ret; }, showSpinner(swimlaneId) { const list = Template.currentData(); - return list.cards(swimlaneId).count() > this.cardlimit.get(); + return list.cards(swimlaneId).length > this.cardlimit.get(); }, canSeeAddCard() { @@ -225,7 +226,7 @@ BlazeComponent.extendComponent({ return ( !list.getWipLimit('soft') && list.getWipLimit('enabled') && - list.getWipLimit('value') <= list.cards().count() + list.getWipLimit('value') <= list.cards().length ); }, @@ -494,7 +495,7 @@ BlazeComponent.extendComponent({ return []; } const ownCardsIds = this.board.cards().map(card => card.getRealId()); - return Cards.find( + const ret = ReactiveCache.getCards( { boardId: this.selectedBoardId.get(), swimlaneId: this.selectedSwimlaneId.get(), @@ -507,6 +508,7 @@ BlazeComponent.extendComponent({ { sort: { sort: 1 }, }); + return ret; }, getSortIndex() { diff --git a/client/components/lists/listHeader.jade b/client/components/lists/listHeader.jade index 847ea3ab2..90f3ea750 100644 --- a/client/components/lists/listHeader.jade +++ b/client/components/lists/listHeader.jade @@ -15,11 +15,11 @@ template(name="listHeader") = title if wipLimit.enabled | ( - span(class="{{#if exceededWipLimit}}highlight{{/if}}") {{cards.count}} + span(class="{{#if exceededWipLimit}}highlight{{/if}}") {{cards.length}} |/#{wipLimit.value}) - if showCardsCountForList cards.count - span.cardCount {{cardsCount}} {{cardsCountForListIsOne cards.count}} + if showCardsCountForList cards.length + span.cardCount {{cardsCount}} {{cardsCountForListIsOne cards.length}} if isMiniScreen if currentList @@ -79,7 +79,7 @@ template(name="listActionPopup") i.fa.fa-paint-brush | {{_ 'set-color-list'}} ul.pop-over-list - if cards.count + if cards.length li a.js-select-cards i.fa.fa-check-square diff --git a/client/components/lists/listHeader.js b/client/components/lists/listHeader.js index 0c1b2cdef..798d336ce 100644 --- a/client/components/lists/listHeader.js +++ b/client/components/lists/listHeader.js @@ -64,14 +64,15 @@ BlazeComponent.extendComponent({ .parentComponent() .data()._id; - return list.cards(swimlaneId).count(); + const ret = list.cards(swimlaneId).length; + return ret; }, reachedWipLimit() { const list = Template.currentData(); return ( list.getWipLimit('enabled') && - list.getWipLimit('value') <= list.cards().count() + list.getWipLimit('value') <= list.cards().length ); }, @@ -79,7 +80,7 @@ BlazeComponent.extendComponent({ const list = Template.currentData(); return ( list.getWipLimit('enabled') && - list.getWipLimit('value') < list.cards().count() + list.getWipLimit('value') < list.cards().length ); }, @@ -184,7 +185,7 @@ BlazeComponent.extendComponent({ 10, ); - if (limit < list.cards().count() && !list.getWipLimit('soft')) { + if (limit < list.cards().length && !list.getWipLimit('soft')) { Template.instance() .$('.wip-limit-error') .click(); @@ -199,9 +200,9 @@ BlazeComponent.extendComponent({ if ( list.getWipLimit('soft') && - list.getWipLimit('value') < list.cards().count() + list.getWipLimit('value') < list.cards().length ) { - list.setWipLimit(list.cards().count()); + list.setWipLimit(list.cards().length); } Meteor.call('enableSoftLimit', Template.currentData()._id); }, @@ -211,9 +212,9 @@ BlazeComponent.extendComponent({ // Prevent user from using previously stored wipLimit.value if it is less than the current number of cards in the list if ( !list.getWipLimit('enabled') && - list.getWipLimit('value') < list.cards().count() + list.getWipLimit('value') < list.cards().length ) { - list.setWipLimit(list.cards().count()); + list.setWipLimit(list.cards().length); } Meteor.call('enableWipLimit', list._id); }, @@ -250,12 +251,12 @@ Template.listMorePopup.events({ const allCardIds = _.pluck(allCards, '_id'); // it's okay if the linked cards are on the same list if ( - Cards.find({ + ReactiveCache.getCards({ $and: [ { listId: { $ne: this._id } }, { linkedId: { $in: allCardIds } }, ], - }).count() === 0 + }).length === 0 ) { allCardIds.map(_id => Cards.remove(_id)); Lists.remove(this._id); diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js index 6747feabb..b8f35557f 100644 --- a/client/components/sidebar/sidebar.js +++ b/client/components/sidebar/sidebar.js @@ -279,10 +279,10 @@ Template.memberPopup.events({ // This works from removing member from board, card members and assignees. const boardId = Session.get('currentBoard'); const memberId = this.userId; - Cards.find({ boardId, members: memberId }).forEach(card => { + ReactiveCache.getCards({ boardId, members: memberId }).forEach(card => { card.unassignMember(memberId); }); - Cards.find({ boardId, assignees: memberId }).forEach(card => { + ReactiveCache.getCards({ boardId, assignees: memberId }).forEach(card => { card.unassignAssignee(memberId); }); ReactiveCache.getBoard(boardId).removeMember(memberId); diff --git a/client/components/sidebar/sidebarArchives.js b/client/components/sidebar/sidebarArchives.js index 988400af3..05331c252 100644 --- a/client/components/sidebar/sidebarArchives.js +++ b/client/components/sidebar/sidebarArchives.js @@ -34,7 +34,7 @@ BlazeComponent.extendComponent({ }, archivedCards() { - return Cards.find( + const ret = ReactiveCache.getCards( { archived: true, boardId: Session.get('currentBoard'), @@ -43,6 +43,7 @@ BlazeComponent.extendComponent({ sort: { archivedAt: -1, modifiedAt: -1 }, }, ); + return ret; }, archivedLists() { diff --git a/client/components/sidebar/sidebarFilters.js b/client/components/sidebar/sidebarFilters.js index 667373c42..64c6f3d8c 100644 --- a/client/components/sidebar/sidebarFilters.js +++ b/client/components/sidebar/sidebarFilters.js @@ -95,7 +95,7 @@ BlazeComponent.extendComponent({ }, 'click .js-filter-to-selection'(evt) { evt.preventDefault(); - const selectedCards = Cards.find(Filter.mongoSelector()).map(c => { + const selectedCards = ReactiveCache.getCards(Filter.mongoSelector()).map(c => { return c._id; }); MultiSelection.add(selectedCards); @@ -106,14 +106,14 @@ BlazeComponent.extendComponent({ }).register('filterSidebar'); function mutateSelectedCards(mutationName, ...args) { - Cards.find(MultiSelection.getMongoSelector(), {sort: ['sort']}).forEach(card => { + ReactiveCache.getCards(MultiSelection.getMongoSelector(), {sort: ['sort']}).forEach(card => { card[mutationName](...args); }); } BlazeComponent.extendComponent({ mapSelection(kind, _id) { - return Cards.find(MultiSelection.getMongoSelector(), {sort: ['sort']}).map(card => { + return ReactiveCache.getCards(MultiSelection.getMongoSelector(), {sort: ['sort']}).map(card => { const methodName = kind === 'label' ? 'hasLabel' : 'isAssigned'; return card[methodName](_id); }); diff --git a/client/components/swimlanes/swimlanes.js b/client/components/swimlanes/swimlanes.js index 49dd89590..cafb68649 100644 --- a/client/components/swimlanes/swimlanes.js +++ b/client/components/swimlanes/swimlanes.js @@ -170,7 +170,7 @@ BlazeComponent.extendComponent({ .parentComponent() .data()._id; const cards = list.cards(swimlaneId); - if (cards.count() === 0) { + if (cards.length === 0) { return false; } } @@ -306,7 +306,7 @@ BlazeComponent.extendComponent({ .parentComponent() .data()._id; const cards = list.cards(swimlaneId); - if (cards.count() === 0) { + if (cards.length === 0) { return false; } } diff --git a/client/lib/multiSelection.js b/client/lib/multiSelection.js index 60c3b8305..9d5a51151 100644 --- a/client/lib/multiSelection.js +++ b/client/lib/multiSelection.js @@ -50,7 +50,7 @@ function getCardsBetween(idA, idB) { }; } - return Cards.find(Filter.mongoSelector(selector)).map(pluckId); + return ReactiveCache.getCards(Filter.mongoSelector(selector)).map(pluckId); } MultiSelection = { @@ -79,7 +79,7 @@ MultiSelection = { }, count() { - return Cards.find(this.getMongoSelector()).count(); + return ReactiveCache.getCards(this.getMongoSelector()).length; }, isEmpty() {