mirror of
https://github.com/wekan/wekan.git
synced 2025-09-22 01:50:48 +02:00
Move every ChecklistItems.find(idOrFirstObjectSelector, options) to the ReactiveCache (directory models/)
This commit is contained in:
parent
981a641bce
commit
6fd3c0fa6b
4 changed files with 18 additions and 23 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { ReactiveCache } from '/imports/reactiveCache';
|
import { ReactiveCache } from '/imports/reactiveCache';
|
||||||
import { DataCache } from 'meteor-reactive-cache'
|
|
||||||
|
|
||||||
Checklists = new Mongo.Collection('checklists');
|
Checklists = new Mongo.Collection('checklists');
|
||||||
|
|
||||||
|
@ -73,7 +72,7 @@ Checklists.helpers({
|
||||||
delete copyObj._id;
|
delete copyObj._id;
|
||||||
copyObj.cardId = newCardId;
|
copyObj.cardId = newCardId;
|
||||||
const newChecklistId = Checklists.insert(copyObj);
|
const newChecklistId = Checklists.insert(copyObj);
|
||||||
ChecklistItems.find({ checklistId: this._id }).forEach(function(
|
ReactiveCache.getChecklistItems({ checklistId: this._id }).forEach(function(
|
||||||
item,
|
item,
|
||||||
) {
|
) {
|
||||||
item._id = null;
|
item._id = null;
|
||||||
|
@ -88,18 +87,14 @@ Checklists.helpers({
|
||||||
return ret;
|
return ret;
|
||||||
},
|
},
|
||||||
items() {
|
items() {
|
||||||
if (!this._items) {
|
const ret = ReactiveCache.getChecklistItems(
|
||||||
this._items = new DataCache(() => ChecklistItems.find(
|
{
|
||||||
{
|
checklistId: this._id,
|
||||||
checklistId: this._id,
|
},
|
||||||
},
|
{ sort: ['sort'] },
|
||||||
{ sort: ['sort'] },
|
);
|
||||||
|
return ret;
|
||||||
|
|
||||||
)
|
|
||||||
.fetch()
|
|
||||||
, 1000);
|
|
||||||
}
|
|
||||||
return this._items.get();
|
|
||||||
},
|
},
|
||||||
firstItem() {
|
firstItem() {
|
||||||
const ret = _.first(this.items());
|
const ret = _.first(this.items());
|
||||||
|
@ -129,13 +124,13 @@ Checklists.helpers({
|
||||||
return 0 !== this.itemCount() && this.itemCount() === this.finishedCount();
|
return 0 !== this.itemCount() && this.itemCount() === this.finishedCount();
|
||||||
},
|
},
|
||||||
checkAllItems() {
|
checkAllItems() {
|
||||||
const checkItems = ChecklistItems.find({ checklistId: this._id });
|
const checkItems = ReactiveCache.getChecklistItems({ checklistId: this._id });
|
||||||
checkItems.forEach(function(item) {
|
checkItems.forEach(function(item) {
|
||||||
item.check();
|
item.check();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
uncheckAllItems() {
|
uncheckAllItems() {
|
||||||
const checkItems = ChecklistItems.find({ checklistId: this._id });
|
const checkItems = ReactiveCache.getChecklistItems({ checklistId: this._id });
|
||||||
checkItems.forEach(function(item) {
|
checkItems.forEach(function(item) {
|
||||||
item.uncheck();
|
item.uncheck();
|
||||||
});
|
});
|
||||||
|
@ -185,7 +180,7 @@ Checklists.mutations({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// update every checklist-item
|
// update every checklist-item
|
||||||
ChecklistItems.find(
|
ReactiveCache.getChecklistItems(
|
||||||
{checklistId: this._id}
|
{checklistId: this._id}
|
||||||
).forEach(checklistItem => {
|
).forEach(checklistItem => {
|
||||||
ChecklistItems.update(checklistItem._id, {
|
ChecklistItems.update(checklistItem._id, {
|
||||||
|
@ -311,7 +306,7 @@ if (Meteor.isServer) {
|
||||||
cardId: paramCardId,
|
cardId: paramCardId,
|
||||||
});
|
});
|
||||||
if (checklist) {
|
if (checklist) {
|
||||||
checklist.items = ChecklistItems.find({
|
checklist.items = ReactiveCache.getChecklistItems({
|
||||||
checklistId: checklist._id,
|
checklistId: checklist._id,
|
||||||
}).map(function(doc) {
|
}).map(function(doc) {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -119,9 +119,9 @@ export class Exporter {
|
||||||
}).fetch(),
|
}).fetch(),
|
||||||
);
|
);
|
||||||
result.checklistItems.push(
|
result.checklistItems.push(
|
||||||
...ChecklistItems.find({
|
...ReactiveCache.getChecklistItems({
|
||||||
cardId: card._id,
|
cardId: card._id,
|
||||||
}).fetch(),
|
}),
|
||||||
);
|
);
|
||||||
result.subtaskItems.push(
|
result.subtaskItems.push(
|
||||||
...ReactiveCache.getCards({
|
...ReactiveCache.getCards({
|
||||||
|
|
|
@ -70,9 +70,9 @@ class ExporterCardPDF {
|
||||||
}).fetch(),
|
}).fetch(),
|
||||||
);
|
);
|
||||||
result.checklistItems.push(
|
result.checklistItems.push(
|
||||||
...ChecklistItems.find({
|
...ReactiveCache.getChecklistItems({
|
||||||
cardId: card._id,
|
cardId: card._id,
|
||||||
}).fetch(),
|
}),
|
||||||
);
|
);
|
||||||
result.subtaskItems.push(
|
result.subtaskItems.push(
|
||||||
...ReactiveCache.getCards({
|
...ReactiveCache.getCards({
|
||||||
|
|
|
@ -72,9 +72,9 @@ class ExporterExcel {
|
||||||
}).fetch(),
|
}).fetch(),
|
||||||
);
|
);
|
||||||
result.checklistItems.push(
|
result.checklistItems.push(
|
||||||
...ChecklistItems.find({
|
...ReactiveCache.getChecklistItems({
|
||||||
cardId: card._id,
|
cardId: card._id,
|
||||||
}).fetch(),
|
}),
|
||||||
);
|
);
|
||||||
result.subtaskItems.push(
|
result.subtaskItems.push(
|
||||||
...ReactiveCache.getCards({
|
...ReactiveCache.getCards({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue