wekan/models/rules.js

50 lines
871 B
JavaScript
Raw Normal View History

2018-08-03 19:47:20 +02:00
Rules = new Mongo.Collection('rules');
Rules.attachSchema(new SimpleSchema({
title: {
type: String,
2018-09-12 00:52:29 +02:00
optional: false,
2018-08-03 19:47:20 +02:00
},
2018-08-03 20:43:37 +02:00
triggerId: {
type: String,
2018-09-12 00:52:29 +02:00
optional: false,
2018-08-03 20:43:37 +02:00
},
actionId: {
2018-08-03 19:47:20 +02:00
type: String,
2018-09-12 00:52:29 +02:00
optional: false,
},
boardId: {
type: String,
optional: false,
2018-08-03 19:47:20 +02:00
},
}));
Rules.mutations({
rename(description) {
return { $set: { description } };
},
});
2018-08-16 00:32:31 +02:00
Rules.helpers({
getAction(){
return Actions.findOne({_id:this.actionId});
},
2018-09-12 00:52:29 +02:00
getTrigger(){
return Triggers.findOne({_id:this.triggerId});
}
2018-08-16 00:32:31 +02:00
});
2018-08-03 20:43:37 +02:00
2018-08-03 19:47:20 +02:00
Rules.allow({
2018-09-12 00:52:29 +02:00
insert(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
2018-08-03 19:47:20 +02:00
},
2018-09-12 00:52:29 +02:00
update(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
2018-08-03 20:43:37 +02:00
},
2018-09-12 00:52:29 +02:00
remove(userId, doc) {
return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId));
}
2018-08-03 19:47:20 +02:00
});