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/actions.js | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 models/actions.js (limited to 'models/actions.js') diff --git a/models/actions.js b/models/actions.js new file mode 100644 index 00000000..0961abbb --- /dev/null +++ b/models/actions.js @@ -0,0 +1,62 @@ +Actions = new Mongo.Collection('actions'); + + + +Actions.mutations({ + rename(description) { + return { $set: { description } }; + }, +}); + +Actions.allow({ + update: function () { + // add custom authentication code here + return true; + }, + insert: function () { + // add custom authentication code here + return true; + } +}); + + +Actions.helpers({ + fromList() { + return Lists.findOne(this.fromId); + }, + + toList() { + return Lists.findOne(this.toId); + }, + + findList(title) { + return Lists.findOne({title:title}); + }, + + labels() { + const boardLabels = this.board().labels; + const cardLabels = _.filter(boardLabels, (label) => { + return _.contains(this.labelIds, label._id); + }); + return cardLabels; + }}); + + + +if (Meteor.isServer) { + Meteor.startup(() => { + const rules = Triggers.findOne({}); + if(!rules){ + Actions.insert({actionType: "moveCardToTop"}); + } + }); +} + + + + + + + + + -- 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/actions.js | 8 -------- 1 file changed, 8 deletions(-) (limited to 'models/actions.js') diff --git a/models/actions.js b/models/actions.js index 0961abbb..93d45928 100644 --- a/models/actions.js +++ b/models/actions.js @@ -43,14 +43,6 @@ Actions.helpers({ -if (Meteor.isServer) { - Meteor.startup(() => { - const rules = Triggers.findOne({}); - if(!rules){ - Actions.insert({actionType: "moveCardToTop"}); - } - }); -} -- cgit v1.2.3-1-g7c22 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 ++++ 1 file changed, 4 insertions(+) (limited to 'models/actions.js') 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; } }); -- 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/actions.js | 45 ++++++--------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) (limited to 'models/actions.js') diff --git a/models/actions.js b/models/actions.js index daa5cc96..da9b30fb 100644 --- a/models/actions.js +++ b/models/actions.js @@ -1,52 +1,19 @@ Actions = new Mongo.Collection('actions'); - -Actions.mutations({ - rename(description) { - return { $set: { description } }; - }, -}); - Actions.allow({ - update: function () { - // add custom authentication code here - return true; + insert(userId, doc) { + return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); }, - insert: function () { - // add custom authentication code here - return true; + update(userId, doc) { + return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); }, - remove: function () { - // add custom authentication code here - return true; + remove(userId, doc) { + return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); } }); -Actions.helpers({ - fromList() { - return Lists.findOne(this.fromId); - }, - - toList() { - return Lists.findOne(this.toId); - }, - - findList(title) { - return Lists.findOne({title:title}); - }, - - labels() { - const boardLabels = this.board().labels; - const cardLabels = _.filter(boardLabels, (label) => { - return _.contains(this.labelIds, label._id); - }); - return cardLabels; - }}); - - - -- cgit v1.2.3-1-g7c22 From fc73dc5bbcbbd203efc4f10ecb4bd1a66e0d9efb Mon Sep 17 00:00:00 2001 From: Angelo Gallarello Date: Fri, 14 Sep 2018 16:49:06 +0200 Subject: Refactoring rules description --- models/actions.js | 103 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 94 insertions(+), 9 deletions(-) (limited to 'models/actions.js') diff --git a/models/actions.js b/models/actions.js index da9b30fb..fd1d03e0 100644 --- a/models/actions.js +++ b/models/actions.js @@ -2,15 +2,100 @@ Actions = new Mongo.Collection('actions'); Actions.allow({ - insert(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); - }, - update(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); - }, - remove(userId, doc) { - return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); - } + insert(userId, doc) { + return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + }, + update(userId, doc) { + return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + }, + remove(userId, doc) { + return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); + } +}); + + +Actions.helpers({ + description() { + if(this.actionType == "moveCardToTop"){ + if(this.listTitle == "*"){ + return TAPi18n.__('r-d-move-to-top-gen'); + }else{ + return TAPi18n.__('r-d-move-to-top-spec') + " " + this.listTitle; + } + } + if(this.actionType == "moveCardToBottom"){ + if(this.listTitle == "*"){ + return TAPi18n.__('r-d-move-to-bottom-gen'); + }else{ + return TAPi18n.__('r-d-move-to-bottom-spec') + " " + this.listTitle; + } + } + if(this.actionType == "sendEmail"){ + const to = " " + TAPi18n.__('r-d-send-email-to') + ": " + this.emailTo + ", "; + const subject = TAPi18n.__('r-d-send-email-subject') + ": " + this.emailSubject + ", "; + const message = TAPi18n.__('r-d-send-email-message') + ": " + this.emailMsg; + const total = TAPi18n.__('r-d-send-email') + to + subject + message; + return total; + } + if(this.actionType == "archive"){ + return TAPi18n.__('r-d-archive'); + } + if(this.actionType == "unarchive"){ + return TAPi18n.__('r-d-unarchive'); + } + if(this.actionType == "addLabel"){ + const board = Boards.findOne(Session.get('currentBoard')); + const label = board.getLabelById(this.labelId); + let name; + if(label.name == "" || label.name == undefined){ + name = label.color.toUpperCase(); + }else{ + name = label.name; + } + + return TAPi18n.__('r-d-add-label') + ": "+name; + } + if(this.actionType == "removeLabel"){ + const board = Boards.findOne(Session.get('currentBoard')); + const label = board.getLabelById(this.labelId); + let name; + if(label.name == "" || label.name == undefined){ + name = label.color.toUpperCase(); + }else{ + name = label.name; + } + return TAPi18n.__('r-d-remove-label') + ": " + name; + } + if(this.actionType == "addMember"){ + return TAPi18n.__('r-d-add-member') + ": " + this.memberName; + } + if(this.actionType == "removeMember"){ + if(this.memberName == "*"){ + return TAPi18n.__('r-d-remove-all-member'); + } + return TAPi18n.__('r-d-remove-member') + ": "+ this.memberName; + } + if(this.actionType == "checkAll"){ + return TAPi18n.__('r-d-check-all') + ": " + this.checklistName; + } + if(this.actionType == "uncheckAll"){ + return TAPi18n.__('r-d-uncheck-all') + ": "+ this.checklistName; + } + if(this.actionType == "checkItem"){ + return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName; + } + if(this.actionType == "uncheckItem"){ + return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName; + } + if(this.actionType == "addChecklist"){ + return TAPi18n.__('r-d-add-checklist') + ": "+ this.checklistName; + } + if(this.actionType == "removeChecklist"){ + return TAPi18n.__('r-d-remove-checklist') + ": "+ this.checklistName; + } + + return "Ops not trigger description"; + } }); -- cgit v1.2.3-1-g7c22 From 30a3daa6af179009ac17b40a71bf3f9e9b1d698a Mon Sep 17 00:00:00 2001 From: Angelo Gallarello Date: Fri, 14 Sep 2018 17:35:14 +0200 Subject: Finished alpha rules --- models/actions.js | 80 +------------------------------------------------------ 1 file changed, 1 insertion(+), 79 deletions(-) (limited to 'models/actions.js') diff --git a/models/actions.js b/models/actions.js index fd1d03e0..8062b545 100644 --- a/models/actions.js +++ b/models/actions.js @@ -16,85 +16,7 @@ Actions.allow({ Actions.helpers({ description() { - if(this.actionType == "moveCardToTop"){ - if(this.listTitle == "*"){ - return TAPi18n.__('r-d-move-to-top-gen'); - }else{ - return TAPi18n.__('r-d-move-to-top-spec') + " " + this.listTitle; - } - } - if(this.actionType == "moveCardToBottom"){ - if(this.listTitle == "*"){ - return TAPi18n.__('r-d-move-to-bottom-gen'); - }else{ - return TAPi18n.__('r-d-move-to-bottom-spec') + " " + this.listTitle; - } - } - if(this.actionType == "sendEmail"){ - const to = " " + TAPi18n.__('r-d-send-email-to') + ": " + this.emailTo + ", "; - const subject = TAPi18n.__('r-d-send-email-subject') + ": " + this.emailSubject + ", "; - const message = TAPi18n.__('r-d-send-email-message') + ": " + this.emailMsg; - const total = TAPi18n.__('r-d-send-email') + to + subject + message; - return total; - } - if(this.actionType == "archive"){ - return TAPi18n.__('r-d-archive'); - } - if(this.actionType == "unarchive"){ - return TAPi18n.__('r-d-unarchive'); - } - if(this.actionType == "addLabel"){ - const board = Boards.findOne(Session.get('currentBoard')); - const label = board.getLabelById(this.labelId); - let name; - if(label.name == "" || label.name == undefined){ - name = label.color.toUpperCase(); - }else{ - name = label.name; - } - - return TAPi18n.__('r-d-add-label') + ": "+name; - } - if(this.actionType == "removeLabel"){ - const board = Boards.findOne(Session.get('currentBoard')); - const label = board.getLabelById(this.labelId); - let name; - if(label.name == "" || label.name == undefined){ - name = label.color.toUpperCase(); - }else{ - name = label.name; - } - return TAPi18n.__('r-d-remove-label') + ": " + name; - } - if(this.actionType == "addMember"){ - return TAPi18n.__('r-d-add-member') + ": " + this.memberName; - } - if(this.actionType == "removeMember"){ - if(this.memberName == "*"){ - return TAPi18n.__('r-d-remove-all-member'); - } - return TAPi18n.__('r-d-remove-member') + ": "+ this.memberName; - } - if(this.actionType == "checkAll"){ - return TAPi18n.__('r-d-check-all') + ": " + this.checklistName; - } - if(this.actionType == "uncheckAll"){ - return TAPi18n.__('r-d-uncheck-all') + ": "+ this.checklistName; - } - if(this.actionType == "checkItem"){ - return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName; - } - if(this.actionType == "uncheckItem"){ - return TAPi18n.__('r-d-check-one') + ": "+ this.checkItemName + " " + TAPi18n.__('r-d-check-of-list') + ": " +this.checklistName; - } - if(this.actionType == "addChecklist"){ - return TAPi18n.__('r-d-add-checklist') + ": "+ this.checklistName; - } - if(this.actionType == "removeChecklist"){ - return TAPi18n.__('r-d-remove-checklist') + ": "+ this.checklistName; - } - - return "Ops not trigger description"; + return this.desc; } }); -- cgit v1.2.3-1-g7c22 From 25da8376ca2ee3b7bedadf924557d4d7bb6c6771 Mon Sep 17 00:00:00 2001 From: Angelo Gallarello Date: Fri, 14 Sep 2018 17:39:37 +0200 Subject: Beautyfied --- models/actions.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'models/actions.js') diff --git a/models/actions.js b/models/actions.js index 8062b545..82ab0d19 100644 --- a/models/actions.js +++ b/models/actions.js @@ -1,6 +1,5 @@ Actions = new Mongo.Collection('actions'); - Actions.allow({ insert(userId, doc) { return allowIsBoardAdmin(userId, Boards.findOne(doc.boardId)); @@ -13,20 +12,8 @@ Actions.allow({ } }); - Actions.helpers({ description() { return this.desc; } -}); - - - - - - - - - - - +}); \ No newline at end of file -- cgit v1.2.3-1-g7c22