Move every ChecklistItems.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory models/)

This commit is contained in:
Martin Filser 2023-02-22 23:10:41 +01:00
parent 981a641bce
commit 6fd3c0fa6b
4 changed files with 18 additions and 23 deletions

View file

@ -1,5 +1,4 @@
import { ReactiveCache } from '/imports/reactiveCache';
import { DataCache } from 'meteor-reactive-cache'
Checklists = new Mongo.Collection('checklists');
@ -73,7 +72,7 @@ Checklists.helpers({
delete copyObj._id;
copyObj.cardId = newCardId;
const newChecklistId = Checklists.insert(copyObj);
ChecklistItems.find({ checklistId: this._id }).forEach(function(
ReactiveCache.getChecklistItems({ checklistId: this._id }).forEach(function(
item,
) {
item._id = null;
@ -88,18 +87,14 @@ Checklists.helpers({
return ret;
},
items() {
if (!this._items) {
this._items = new DataCache(() => ChecklistItems.find(
{
checklistId: this._id,
},
{ sort: ['sort'] },
const ret = ReactiveCache.getChecklistItems(
{
checklistId: this._id,
},
{ sort: ['sort'] },
);
return ret;
)
.fetch()
, 1000);
}
return this._items.get();
},
firstItem() {
const ret = _.first(this.items());
@ -129,13 +124,13 @@ Checklists.helpers({
return 0 !== this.itemCount() && this.itemCount() === this.finishedCount();
},
checkAllItems() {
const checkItems = ChecklistItems.find({ checklistId: this._id });
const checkItems = ReactiveCache.getChecklistItems({ checklistId: this._id });
checkItems.forEach(function(item) {
item.check();
});
},
uncheckAllItems() {
const checkItems = ChecklistItems.find({ checklistId: this._id });
const checkItems = ReactiveCache.getChecklistItems({ checklistId: this._id });
checkItems.forEach(function(item) {
item.uncheck();
});
@ -185,7 +180,7 @@ Checklists.mutations({
});
});
// update every checklist-item
ChecklistItems.find(
ReactiveCache.getChecklistItems(
{checklistId: this._id}
).forEach(checklistItem => {
ChecklistItems.update(checklistItem._id, {
@ -311,7 +306,7 @@ if (Meteor.isServer) {
cardId: paramCardId,
});
if (checklist) {
checklist.items = ChecklistItems.find({
checklist.items = ReactiveCache.getChecklistItems({
checklistId: checklist._id,
}).map(function(doc) {
return {

View file

@ -119,9 +119,9 @@ export class Exporter {
}).fetch(),
);
result.checklistItems.push(
...ChecklistItems.find({
...ReactiveCache.getChecklistItems({
cardId: card._id,
}).fetch(),
}),
);
result.subtaskItems.push(
...ReactiveCache.getCards({

View file

@ -70,9 +70,9 @@ class ExporterCardPDF {
}).fetch(),
);
result.checklistItems.push(
...ChecklistItems.find({
...ReactiveCache.getChecklistItems({
cardId: card._id,
}).fetch(),
}),
);
result.subtaskItems.push(
...ReactiveCache.getCards({

View file

@ -72,9 +72,9 @@ class ExporterExcel {
}).fetch(),
);
result.checklistItems.push(
...ChecklistItems.find({
...ReactiveCache.getChecklistItems({
cardId: card._id,
}).fetch(),
}),
);
result.subtaskItems.push(
...ReactiveCache.getCards({