diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-09-08 20:19:42 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-09-08 20:19:42 +0200 |
commit | 45b662a1ddb46a0f17fab7b2383c82aa1e1620ef (patch) | |
tree | cc7be215c7e7ebffd2597df70cf271b3dd435e1a /client/components/boards/boardHeader.js | |
parent | c04341f1ea5efe082bf7318cf9eb0e99b9b8374a (diff) | |
download | wekan-45b662a1ddb46a0f17fab7b2383c82aa1e1620ef.tar.gz wekan-45b662a1ddb46a0f17fab7b2383c82aa1e1620ef.tar.bz2 wekan-45b662a1ddb46a0f17fab7b2383c82aa1e1620ef.zip |
Centralize all mutations at the model level
This commit uses a new package that I need to document. It tries to
solve the long-standing debate in the Meteor community about
allow/deny rules versus methods (RPC).
This approach gives us both the centralized security rules of
allow/deny and the white-list of allowed mutations similarly to Meteor
methods. The idea to have static mutation descriptions is also
inspired by Facebook's Relay/GraphQL.
This will allow the development of a REST API using the high-level
methods instead of the MongoDB queries to do the mapping between the
HTTP requests and our collections.
Diffstat (limited to 'client/components/boards/boardHeader.js')
-rw-r--r-- | client/components/boards/boardHeader.js | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/client/components/boards/boardHeader.js b/client/components/boards/boardHeader.js index f259b2a6..19b463ed 100644 --- a/client/components/boards/boardHeader.js +++ b/client/components/boards/boardHeader.js @@ -7,8 +7,8 @@ Template.boardMenuPopup.events({ 'click .js-change-board-color': Popup.open('boardChangeColor'), 'click .js-change-language': Popup.open('changeLanguage'), 'click .js-archive-board ': Popup.afterConfirm('archiveBoard', () => { - const boardId = Session.get('currentBoard'); - Boards.update(boardId, { $set: { archived: true }}); + const currentBoard = Boards.findOne(Session.get('currentBoard')); + currentBoard.archive(); // XXX We should have some kind of notification on top of the page to // confirm that the board was successfully archived. FlowRouter.go('home'); @@ -17,13 +17,9 @@ Template.boardMenuPopup.events({ Template.boardChangeTitlePopup.events({ submit(evt, tpl) { - const title = tpl.$('.js-board-name').val().trim(); - if (title) { - Boards.update(this._id, { - $set: { - title, - }, - }); + const newTitle = tpl.$('.js-board-name').val().trim(); + if (newTitle) { + this.rename(newTitle); Popup.close(); } evt.preventDefault(); @@ -95,12 +91,9 @@ BlazeComponent.extendComponent({ events() { return [{ 'click .js-select-background'(evt) { - const currentBoardId = Session.get('currentBoard'); - Boards.update(currentBoardId, { - $set: { - color: this.currentData().toString(), - }, - }); + const currentBoard = Boards.findOne(Session.get('currentBoard')); + const newColor = this.currentData().toString(); + currentBoard.setColor(newColor); evt.preventDefault(); }, }]; @@ -168,11 +161,9 @@ BlazeComponent.extendComponent({ }, selectBoardVisibility() { - Boards.update(Session.get('currentBoard'), { - $set: { - permission: this.currentData(), - }, - }); + const currentBoard = Boards.findOne(Session.get('currentBoard')); + const visibility = this.currentData(); + currentBoard.setVisibility(visibility); Popup.close(); }, |