mirror of
https://github.com/wekan/wekan.git
synced 2026-01-27 19:56:09 +01:00
Replace mquandalle:collection-mutations with collection helpers
This commit is contained in:
parent
aca661583d
commit
94a3575e2c
35 changed files with 718 additions and 1321 deletions
|
|
@ -150,22 +150,49 @@ Checklists.helpers({
|
|||
}
|
||||
return ret;
|
||||
},
|
||||
checkAllItems() {
|
||||
async checkAllItems() {
|
||||
const checkItems = ReactiveCache.getChecklistItems({ checklistId: this._id });
|
||||
checkItems.forEach(function(item) {
|
||||
item.check();
|
||||
});
|
||||
for (const item of checkItems) {
|
||||
await item.check();
|
||||
}
|
||||
},
|
||||
uncheckAllItems() {
|
||||
async uncheckAllItems() {
|
||||
const checkItems = ReactiveCache.getChecklistItems({ checklistId: this._id });
|
||||
checkItems.forEach(function(item) {
|
||||
item.uncheck();
|
||||
});
|
||||
for (const item of checkItems) {
|
||||
await item.uncheck();
|
||||
}
|
||||
},
|
||||
itemIndex(itemId) {
|
||||
const items = ReactiveCache.getChecklist({ _id: this._id }).items;
|
||||
return _.pluck(items, '_id').indexOf(itemId);
|
||||
},
|
||||
|
||||
async setTitle(title) {
|
||||
return await Checklists.updateAsync(this._id, { $set: { title } });
|
||||
},
|
||||
/** move the checklist to another card
|
||||
* @param newCardId move the checklist to this cardId
|
||||
*/
|
||||
async move(newCardId) {
|
||||
// Note: Activities and ChecklistItems updates are now handled server-side
|
||||
// in the moveChecklist Meteor method to avoid client-side permission issues
|
||||
return await Checklists.updateAsync(this._id, { $set: { cardId: newCardId } });
|
||||
},
|
||||
async toggleHideCheckedChecklistItems() {
|
||||
return await Checklists.updateAsync(this._id, {
|
||||
$set: { hideCheckedChecklistItems: !this.hideCheckedChecklistItems },
|
||||
});
|
||||
},
|
||||
async toggleHideAllChecklistItems() {
|
||||
return await Checklists.updateAsync(this._id, {
|
||||
$set: { hideAllChecklistItems: !this.hideAllChecklistItems },
|
||||
});
|
||||
},
|
||||
async toggleShowChecklistAtMinicard() {
|
||||
return await Checklists.updateAsync(this._id, {
|
||||
$set: { showChecklistAtMinicard: !this.showChecklistAtMinicard },
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Checklists.allow({
|
||||
|
|
@ -191,46 +218,6 @@ Checklists.before.insert((userId, doc) => {
|
|||
}
|
||||
});
|
||||
|
||||
Checklists.mutations({
|
||||
setTitle(title) {
|
||||
return { $set: { title } };
|
||||
},
|
||||
/** move the checklist to another card
|
||||
* @param newCardId move the checklist to this cardId
|
||||
*/
|
||||
move(newCardId) {
|
||||
// Note: Activities and ChecklistItems updates are now handled server-side
|
||||
// in the moveChecklist Meteor method to avoid client-side permission issues
|
||||
|
||||
// update the checklist itself
|
||||
return {
|
||||
$set: {
|
||||
cardId: newCardId,
|
||||
},
|
||||
};
|
||||
},
|
||||
toggleHideCheckedChecklistItems() {
|
||||
return {
|
||||
$set: {
|
||||
hideCheckedChecklistItems: !this.hideCheckedChecklistItems,
|
||||
}
|
||||
};
|
||||
},
|
||||
toggleHideAllChecklistItems() {
|
||||
return {
|
||||
$set: {
|
||||
hideAllChecklistItems: !this.hideAllChecklistItems,
|
||||
}
|
||||
};
|
||||
},
|
||||
toggleShowChecklistAtMinicard() {
|
||||
return {
|
||||
$set: {
|
||||
showChecklistAtMinicard: !this.showChecklistAtMinicard,
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
Meteor.methods({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue