mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 13:37:09 -04:00
Move every Cards.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory client/)
This commit is contained in:
parent
66c2140911
commit
7673c77c57
11 changed files with 38 additions and 34 deletions
|
@ -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.
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue