mirror of
https://github.com/wekan/wekan.git
synced 2025-12-22 18:30:13 +01: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() {
|
cards() {
|
||||||
const currentId = Utils.getCurrentCardId();
|
const currentId = Utils.getCurrentCardId();
|
||||||
if (this.parentBoard.get()) {
|
if (this.parentBoard.get()) {
|
||||||
return Cards.find({
|
const ret = ReactiveCache.getCards({
|
||||||
boardId: this.parentBoard.get(),
|
boardId: this.parentBoard.get(),
|
||||||
_id: { $ne: currentId },
|
_id: { $ne: currentId },
|
||||||
});
|
});
|
||||||
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
@ -1023,7 +1024,7 @@ BlazeComponent.extendComponent({
|
||||||
'click .js-delete': Popup.afterConfirm('cardDelete', function () {
|
'click .js-delete': Popup.afterConfirm('cardDelete', function () {
|
||||||
Popup.close();
|
Popup.close();
|
||||||
// verify that there are no linked cards
|
// 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);
|
Cards.remove(this._id);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Maybe later we can list where the linked cards are.
|
// TODO: Maybe later we can list where the linked cards are.
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ BlazeComponent.extendComponent({
|
||||||
$cards.sortable('cancel');
|
$cards.sortable('cancel');
|
||||||
|
|
||||||
if (MultiSelection.isActive()) {
|
if (MultiSelection.isActive()) {
|
||||||
Cards.find(MultiSelection.getMongoSelector(), { sort: ['sort'] }).forEach((card, i) => {
|
ReactiveCache.getCards(MultiSelection.getMongoSelector(), { sort: ['sort'] }).forEach((card, i) => {
|
||||||
const newSwimlaneId = targetSwimlaneId
|
const newSwimlaneId = targetSwimlaneId
|
||||||
? targetSwimlaneId
|
? targetSwimlaneId
|
||||||
: card.swimlaneId || defaultSwimlaneId;
|
: card.swimlaneId || defaultSwimlaneId;
|
||||||
|
|
@ -174,7 +174,6 @@ BlazeComponent.extendComponent({
|
||||||
const currentBoardId = Tracker.nonreactive(() => {
|
const currentBoardId = Tracker.nonreactive(() => {
|
||||||
return Session.get('currentBoard');
|
return Session.get('currentBoard');
|
||||||
});
|
});
|
||||||
Cards.find({ boardId: currentBoardId }).fetch();
|
|
||||||
Tracker.afterFlush(() => {
|
Tracker.afterFlush(() => {
|
||||||
$cards.find(itemsSelector).droppable({
|
$cards.find(itemsSelector).droppable({
|
||||||
hoverClass: 'draggable-hover-card',
|
hoverClass: 'draggable-hover-card',
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
template(name="listBody")
|
template(name="listBody")
|
||||||
.list-body
|
.list-body
|
||||||
.minicards.clearfix.js-minicards(class="{{#if reachedWipLimit}}js-list-full{{/if}}")
|
.minicards.clearfix.js-minicards(class="{{#if reachedWipLimit}}js-list-full{{/if}}")
|
||||||
if cards.count
|
if cards.length
|
||||||
+inlinedForm(autoclose=false position="top")
|
+inlinedForm(autoclose=false position="top")
|
||||||
+addCardForm(listId=_id position="top")
|
+addCardForm(listId=_id position="top")
|
||||||
ul.sidebar-list
|
ul.sidebar-list
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ BlazeComponent.extendComponent({
|
||||||
// to appear
|
// to appear
|
||||||
const cardCount = this.data()
|
const cardCount = this.data()
|
||||||
.cards(this.idOrNull(swimlaneId))
|
.cards(this.idOrNull(swimlaneId))
|
||||||
.count();
|
.length;
|
||||||
if (this.cardlimit.get() < cardCount) {
|
if (this.cardlimit.get() < cardCount) {
|
||||||
this.cardlimit.set(this.cardlimit.get() + InfiniteScrollIter);
|
this.cardlimit.set(this.cardlimit.get() + InfiniteScrollIter);
|
||||||
}
|
}
|
||||||
|
|
@ -201,16 +201,17 @@ BlazeComponent.extendComponent({
|
||||||
archived: false,
|
archived: false,
|
||||||
};
|
};
|
||||||
if (swimlaneId) selector.swimlaneId = swimlaneId;
|
if (swimlaneId) selector.swimlaneId = swimlaneId;
|
||||||
return Cards.find(Filter.mongoSelector(selector), {
|
const ret = ReactiveCache.getCards(Filter.mongoSelector(selector), {
|
||||||
// sort: ['sort'],
|
// sort: ['sort'],
|
||||||
sort: sortBy,
|
sort: sortBy,
|
||||||
limit,
|
limit,
|
||||||
});
|
});
|
||||||
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
showSpinner(swimlaneId) {
|
showSpinner(swimlaneId) {
|
||||||
const list = Template.currentData();
|
const list = Template.currentData();
|
||||||
return list.cards(swimlaneId).count() > this.cardlimit.get();
|
return list.cards(swimlaneId).length > this.cardlimit.get();
|
||||||
},
|
},
|
||||||
|
|
||||||
canSeeAddCard() {
|
canSeeAddCard() {
|
||||||
|
|
@ -225,7 +226,7 @@ BlazeComponent.extendComponent({
|
||||||
return (
|
return (
|
||||||
!list.getWipLimit('soft') &&
|
!list.getWipLimit('soft') &&
|
||||||
list.getWipLimit('enabled') &&
|
list.getWipLimit('enabled') &&
|
||||||
list.getWipLimit('value') <= list.cards().count()
|
list.getWipLimit('value') <= list.cards().length
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -494,7 +495,7 @@ BlazeComponent.extendComponent({
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
const ownCardsIds = this.board.cards().map(card => card.getRealId());
|
const ownCardsIds = this.board.cards().map(card => card.getRealId());
|
||||||
return Cards.find(
|
const ret = ReactiveCache.getCards(
|
||||||
{
|
{
|
||||||
boardId: this.selectedBoardId.get(),
|
boardId: this.selectedBoardId.get(),
|
||||||
swimlaneId: this.selectedSwimlaneId.get(),
|
swimlaneId: this.selectedSwimlaneId.get(),
|
||||||
|
|
@ -507,6 +508,7 @@ BlazeComponent.extendComponent({
|
||||||
{
|
{
|
||||||
sort: { sort: 1 },
|
sort: { sort: 1 },
|
||||||
});
|
});
|
||||||
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
getSortIndex() {
|
getSortIndex() {
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,11 @@ template(name="listHeader")
|
||||||
= title
|
= title
|
||||||
if wipLimit.enabled
|
if wipLimit.enabled
|
||||||
| (
|
| (
|
||||||
span(class="{{#if exceededWipLimit}}highlight{{/if}}") {{cards.count}}
|
span(class="{{#if exceededWipLimit}}highlight{{/if}}") {{cards.length}}
|
||||||
|/#{wipLimit.value})
|
|/#{wipLimit.value})
|
||||||
|
|
||||||
if showCardsCountForList cards.count
|
if showCardsCountForList cards.length
|
||||||
span.cardCount {{cardsCount}} {{cardsCountForListIsOne cards.count}}
|
span.cardCount {{cardsCount}} {{cardsCountForListIsOne cards.length}}
|
||||||
|
|
||||||
if isMiniScreen
|
if isMiniScreen
|
||||||
if currentList
|
if currentList
|
||||||
|
|
@ -79,7 +79,7 @@ template(name="listActionPopup")
|
||||||
i.fa.fa-paint-brush
|
i.fa.fa-paint-brush
|
||||||
| {{_ 'set-color-list'}}
|
| {{_ 'set-color-list'}}
|
||||||
ul.pop-over-list
|
ul.pop-over-list
|
||||||
if cards.count
|
if cards.length
|
||||||
li
|
li
|
||||||
a.js-select-cards
|
a.js-select-cards
|
||||||
i.fa.fa-check-square
|
i.fa.fa-check-square
|
||||||
|
|
|
||||||
|
|
@ -64,14 +64,15 @@ BlazeComponent.extendComponent({
|
||||||
.parentComponent()
|
.parentComponent()
|
||||||
.data()._id;
|
.data()._id;
|
||||||
|
|
||||||
return list.cards(swimlaneId).count();
|
const ret = list.cards(swimlaneId).length;
|
||||||
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
reachedWipLimit() {
|
reachedWipLimit() {
|
||||||
const list = Template.currentData();
|
const list = Template.currentData();
|
||||||
return (
|
return (
|
||||||
list.getWipLimit('enabled') &&
|
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();
|
const list = Template.currentData();
|
||||||
return (
|
return (
|
||||||
list.getWipLimit('enabled') &&
|
list.getWipLimit('enabled') &&
|
||||||
list.getWipLimit('value') < list.cards().count()
|
list.getWipLimit('value') < list.cards().length
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -184,7 +185,7 @@ BlazeComponent.extendComponent({
|
||||||
10,
|
10,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (limit < list.cards().count() && !list.getWipLimit('soft')) {
|
if (limit < list.cards().length && !list.getWipLimit('soft')) {
|
||||||
Template.instance()
|
Template.instance()
|
||||||
.$('.wip-limit-error')
|
.$('.wip-limit-error')
|
||||||
.click();
|
.click();
|
||||||
|
|
@ -199,9 +200,9 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
if (
|
if (
|
||||||
list.getWipLimit('soft') &&
|
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);
|
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
|
// Prevent user from using previously stored wipLimit.value if it is less than the current number of cards in the list
|
||||||
if (
|
if (
|
||||||
!list.getWipLimit('enabled') &&
|
!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);
|
Meteor.call('enableWipLimit', list._id);
|
||||||
},
|
},
|
||||||
|
|
@ -250,12 +251,12 @@ Template.listMorePopup.events({
|
||||||
const allCardIds = _.pluck(allCards, '_id');
|
const allCardIds = _.pluck(allCards, '_id');
|
||||||
// it's okay if the linked cards are on the same list
|
// it's okay if the linked cards are on the same list
|
||||||
if (
|
if (
|
||||||
Cards.find({
|
ReactiveCache.getCards({
|
||||||
$and: [
|
$and: [
|
||||||
{ listId: { $ne: this._id } },
|
{ listId: { $ne: this._id } },
|
||||||
{ linkedId: { $in: allCardIds } },
|
{ linkedId: { $in: allCardIds } },
|
||||||
],
|
],
|
||||||
}).count() === 0
|
}).length === 0
|
||||||
) {
|
) {
|
||||||
allCardIds.map(_id => Cards.remove(_id));
|
allCardIds.map(_id => Cards.remove(_id));
|
||||||
Lists.remove(this._id);
|
Lists.remove(this._id);
|
||||||
|
|
|
||||||
|
|
@ -279,10 +279,10 @@ Template.memberPopup.events({
|
||||||
// This works from removing member from board, card members and assignees.
|
// This works from removing member from board, card members and assignees.
|
||||||
const boardId = Session.get('currentBoard');
|
const boardId = Session.get('currentBoard');
|
||||||
const memberId = this.userId;
|
const memberId = this.userId;
|
||||||
Cards.find({ boardId, members: memberId }).forEach(card => {
|
ReactiveCache.getCards({ boardId, members: memberId }).forEach(card => {
|
||||||
card.unassignMember(memberId);
|
card.unassignMember(memberId);
|
||||||
});
|
});
|
||||||
Cards.find({ boardId, assignees: memberId }).forEach(card => {
|
ReactiveCache.getCards({ boardId, assignees: memberId }).forEach(card => {
|
||||||
card.unassignAssignee(memberId);
|
card.unassignAssignee(memberId);
|
||||||
});
|
});
|
||||||
ReactiveCache.getBoard(boardId).removeMember(memberId);
|
ReactiveCache.getBoard(boardId).removeMember(memberId);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
archivedCards() {
|
archivedCards() {
|
||||||
return Cards.find(
|
const ret = ReactiveCache.getCards(
|
||||||
{
|
{
|
||||||
archived: true,
|
archived: true,
|
||||||
boardId: Session.get('currentBoard'),
|
boardId: Session.get('currentBoard'),
|
||||||
|
|
@ -43,6 +43,7 @@ BlazeComponent.extendComponent({
|
||||||
sort: { archivedAt: -1, modifiedAt: -1 },
|
sort: { archivedAt: -1, modifiedAt: -1 },
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
return ret;
|
||||||
},
|
},
|
||||||
|
|
||||||
archivedLists() {
|
archivedLists() {
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ BlazeComponent.extendComponent({
|
||||||
},
|
},
|
||||||
'click .js-filter-to-selection'(evt) {
|
'click .js-filter-to-selection'(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
const selectedCards = Cards.find(Filter.mongoSelector()).map(c => {
|
const selectedCards = ReactiveCache.getCards(Filter.mongoSelector()).map(c => {
|
||||||
return c._id;
|
return c._id;
|
||||||
});
|
});
|
||||||
MultiSelection.add(selectedCards);
|
MultiSelection.add(selectedCards);
|
||||||
|
|
@ -106,14 +106,14 @@ BlazeComponent.extendComponent({
|
||||||
}).register('filterSidebar');
|
}).register('filterSidebar');
|
||||||
|
|
||||||
function mutateSelectedCards(mutationName, ...args) {
|
function mutateSelectedCards(mutationName, ...args) {
|
||||||
Cards.find(MultiSelection.getMongoSelector(), {sort: ['sort']}).forEach(card => {
|
ReactiveCache.getCards(MultiSelection.getMongoSelector(), {sort: ['sort']}).forEach(card => {
|
||||||
card[mutationName](...args);
|
card[mutationName](...args);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
BlazeComponent.extendComponent({
|
BlazeComponent.extendComponent({
|
||||||
mapSelection(kind, _id) {
|
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';
|
const methodName = kind === 'label' ? 'hasLabel' : 'isAssigned';
|
||||||
return card[methodName](_id);
|
return card[methodName](_id);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ BlazeComponent.extendComponent({
|
||||||
.parentComponent()
|
.parentComponent()
|
||||||
.data()._id;
|
.data()._id;
|
||||||
const cards = list.cards(swimlaneId);
|
const cards = list.cards(swimlaneId);
|
||||||
if (cards.count() === 0) {
|
if (cards.length === 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -306,7 +306,7 @@ BlazeComponent.extendComponent({
|
||||||
.parentComponent()
|
.parentComponent()
|
||||||
.data()._id;
|
.data()._id;
|
||||||
const cards = list.cards(swimlaneId);
|
const cards = list.cards(swimlaneId);
|
||||||
if (cards.count() === 0) {
|
if (cards.length === 0) {
|
||||||
return false;
|
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 = {
|
MultiSelection = {
|
||||||
|
|
@ -79,7 +79,7 @@ MultiSelection = {
|
||||||
},
|
},
|
||||||
|
|
||||||
count() {
|
count() {
|
||||||
return Cards.find(this.getMongoSelector()).count();
|
return ReactiveCache.getCards(this.getMongoSelector()).length;
|
||||||
},
|
},
|
||||||
|
|
||||||
isEmpty() {
|
isEmpty() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue