Completed rules

This commit is contained in:
Angelo Gallarello 2018-08-19 18:53:50 +02:00
parent 3b62b5ec5d
commit 1f5f429fc4
21 changed files with 551 additions and 157 deletions

View file

@ -16,6 +16,10 @@ Actions.allow({
insert: function () {
// add custom authentication code here
return true;
},
remove: function () {
// add custom authentication code here
return true;
}
});

View file

@ -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 } };
},

View file

@ -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);