From 1f5f429fc4535d251d32335eea7e44904a924650 Mon Sep 17 00:00:00 2001 From: Angelo Gallarello Date: Sun, 19 Aug 2018 18:53:50 +0200 Subject: Completed rules --- models/actions.js | 4 ++++ models/checklistItems.js | 6 ++++++ models/checklists.js | 12 ++++++++++++ 3 files changed, 22 insertions(+) (limited to 'models') diff --git a/models/actions.js b/models/actions.js index 93d45928..daa5cc96 100644 --- a/models/actions.js +++ b/models/actions.js @@ -16,6 +16,10 @@ Actions.allow({ insert: function () { // add custom authentication code here return true; + }, + remove: function () { + // add custom authentication code here + return true; } }); diff --git a/models/checklistItems.js b/models/checklistItems.js index 669003bb..e24f0cbd 100644 --- a/models/checklistItems.js +++ b/models/checklistItems.js @@ -44,6 +44,12 @@ ChecklistItems.mutations({ setTitle(title) { return { $set: { title } }; }, + check(){ + return { $set: { isFinished: true } }; + }, + uncheck(){ + return { $set: { isFinished: false } }; + }, toggleItem() { return { $set: { isFinished: !this.isFinished } }; }, diff --git a/models/checklists.js b/models/checklists.js index 4a43818c..26429092 100644 --- a/models/checklists.js +++ b/models/checklists.js @@ -47,6 +47,18 @@ Checklists.helpers({ isFinished() { return 0 !== this.itemCount() && this.itemCount() === this.finishedCount(); }, + checkAllItems(){ + const checkItems = ChecklistItems.find({checklistId: this._id}); + checkItems.forEach(function(item){ + item.check(); + }); + }, + uncheckAllItems(){ + const checkItems = ChecklistItems.find({checklistId: this._id}); + checkItems.forEach(function(item){ + item.uncheck(); + }); + }, itemIndex(itemId) { const items = self.findOne({_id : this._id}).items; return _.pluck(items, '_id').indexOf(itemId); -- cgit v1.2.3-1-g7c22