From f63482b58775a2f52fdd5f932ce7d14f16757133 Mon Sep 17 00:00:00 2001 From: Angelo Gallarello Date: Fri, 3 Aug 2018 19:47:20 +0200 Subject: UI for rules list --- models/rules.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 models/rules.js (limited to 'models/rules.js') diff --git a/models/rules.js b/models/rules.js new file mode 100644 index 00000000..2304d2dc --- /dev/null +++ b/models/rules.js @@ -0,0 +1,38 @@ +Rules = new Mongo.Collection('rules'); + +Rules.attachSchema(new SimpleSchema({ + title: { + type: String, + optional: true, + }, + description: { + type: String, + optional: true, + }, +})); + +Rules.mutations({ + rename(description) { + return { $set: { description } }; + }, +}); + +Rules.allow({ + update: function () { + // add custom authentication code here + return true; + }, +}); + + + + +if (Meteor.isServer) { + Meteor.startup(() => { + const rules = Rules.findOne({}); + if(!rules){ + Rules.insert({title: "regola1", description: "bella"}); + Rules.insert({title: "regola2", description: "bella2"}); + } + }); +} -- cgit v1.2.3-1-g7c22 From 7e4bd4a0a753531c2716ff39ce88f05b7fc30c0d Mon Sep 17 00:00:00 2001 From: Angelo Gallarello Date: Fri, 3 Aug 2018 20:43:37 +0200 Subject: Add and remove ui --- models/rules.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'models/rules.js') diff --git a/models/rules.js b/models/rules.js index 2304d2dc..df0cccea 100644 --- a/models/rules.js +++ b/models/rules.js @@ -5,7 +5,11 @@ Rules.attachSchema(new SimpleSchema({ type: String, optional: true, }, - description: { + triggerId: { + type: String, + optional: true, + }, + actionId: { type: String, optional: true, }, @@ -17,11 +21,22 @@ Rules.mutations({ }, }); + + + Rules.allow({ update: function () { // add custom authentication code here return true; }, + remove: function () { + // add custom authentication code here + return true; + }, + insert: function () { + // add custom authentication code here + return true; + }, }); -- cgit v1.2.3-1-g7c22 From 9b0eb0a9f1973e05df7199cf2bff7518f2fa98dc Mon Sep 17 00:00:00 2001 From: Angelo Gallarello Date: Wed, 15 Aug 2018 18:47:09 +0200 Subject: Almost full circle --- models/rules.js | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'models/rules.js') diff --git a/models/rules.js b/models/rules.js index df0cccea..778622c4 100644 --- a/models/rules.js +++ b/models/rules.js @@ -39,15 +39,3 @@ Rules.allow({ }, }); - - - -if (Meteor.isServer) { - Meteor.startup(() => { - const rules = Rules.findOne({}); - if(!rules){ - Rules.insert({title: "regola1", description: "bella"}); - Rules.insert({title: "regola2", description: "bella2"}); - } - }); -} -- cgit v1.2.3-1-g7c22 From 6828ccd7f17d14f178e6742d78bdd14428ec6e07 Mon Sep 17 00:00:00 2001 From: Angelo Gallarello Date: Thu, 16 Aug 2018 00:32:31 +0200 Subject: Main flow implemented --- models/rules.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'models/rules.js') diff --git a/models/rules.js b/models/rules.js index 778622c4..271e6b52 100644 --- a/models/rules.js +++ b/models/rules.js @@ -21,6 +21,11 @@ Rules.mutations({ }, }); +Rules.helpers({ + getAction(){ + return Actions.findOne({_id:this.actionId}); + }, +}); -- cgit v1.2.3-1-g7c22 From 34b37116cf8c618a4ea12b13d969c24654f4248b Mon Sep 17 00:00:00 2001 From: Angelo Gallarello Date: Wed, 12 Sep 2018 00:52:29 +0200 Subject: Fixed rule allows --- models/rules.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'models/rules.js') diff --git a/models/rules.js b/models/rules.js index 271e6b52..fe6b04cb 100644 --- a/models/rules.js +++ b/models/rules.js @@ -3,15 +3,19 @@ Rules = new Mongo.Collection('rules'); Rules.attachSchema(new SimpleSchema({ title: { type: String, - optional: true, + optional: false, }, triggerId: { type: String, - optional: true, + optional: false, }, actionId: { type: String, - optional: true, + optional: false, + }, + boardId: { + type: String, + optional: false, }, })); @@ -25,22 +29,21 @@ Rules.helpers({ getAction(){ return Actions.findOne({_id:this.actionId}); }, + getTrigger(){ + return Triggers.findOne({_id:this.triggerId}); + } }); Rules.allow({ - update: function () { - // add custom authentication code here - return true; + insert(userId, doc) { + return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); }, - remove: function () { - // add custom authentication code here - return true; - }, - insert: function () { - // add custom authentication code here - return true; + update(userId, doc) { + return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); }, + remove(userId, doc) { + return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + } }); - -- cgit v1.2.3-1-g7c22