Move every Cards.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory client/)

This commit is contained in:
Martin Filser 2023-02-14 18:52:36 +01:00
parent 66c2140911
commit 7673c77c57
11 changed files with 38 additions and 34 deletions

View file

@ -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',

View file

@ -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

View file

@ -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() {

View file

@ -15,11 +15,11 @@ template(name="listHeader")
= title
if wipLimit.enabled
|&nbsp;(
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

View file

@ -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);