This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/imports/api/tasks.js b/imports/api/tasks.js | |
| index 0201eb4..234a839 100644 | |
| --- a/imports/api/tasks.js | |
| +++ b/imports/api/tasks.js | |
| @@ -4,6 +4,13 @@ import { check } from 'meteor/check'; | |
| export const Tasks = new Mongo.Collection('tasks'); | |
| +if (Meteor.isServer) { | |
| + // This code only runs on the server |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/imports/ui/App.jsx b/imports/ui/App.jsx | |
| index 4f41c39..d6e5f0a 100644 | |
| --- a/imports/ui/App.jsx | |
| +++ b/imports/ui/App.jsx | |
| @@ -90,6 +90,8 @@ App.propTypes = { | |
| }; | |
| export default createContainer(() => { | |
| + Meteor.subscribe('tasks'); | |
| + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/imports/api/tasks.js b/imports/api/tasks.js | |
| index 234a839..f1d2c92 100644 | |
| --- a/imports/api/tasks.js | |
| +++ b/imports/api/tasks.js | |
| @@ -38,4 +38,17 @@ Meteor.methods({ | |
| Tasks.update(taskId, { $set: { checked: setChecked } }); | |
| }, | |
| + 'tasks.setPrivate'(taskId, setToPrivate) { | |
| + check(taskId, String); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/imports/ui/App.jsx b/imports/ui/App.jsx | |
| index d6e5f0a..06262c5 100644 | |
| --- a/imports/ui/App.jsx | |
| +++ b/imports/ui/App.jsx | |
| @@ -41,9 +41,18 @@ class App extends Component { | |
| if (this.state.hideCompleted) { | |
| filteredTasks = filteredTasks.filter(task => !task.checked); | |
| } | |
| - return filteredTasks.map((task) => ( | |
| - <Task key={task._id} task={task} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/imports/ui/Task.jsx b/imports/ui/Task.jsx | |
| index ee040c5..deba74a 100644 | |
| --- a/imports/ui/Task.jsx | |
| +++ b/imports/ui/Task.jsx | |
| @@ -42,4 +42,5 @@ Task.propTypes = { | |
| // This component gets the task to display through a React prop. | |
| // We can use propTypes to indicate it is required | |
| task: PropTypes.object.isRequired, | |
| + showPrivateButton: React.PropTypes.bool.isRequired, | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/imports/ui/Task.jsx b/imports/ui/Task.jsx | |
| index deba74a..bec76ba 100644 | |
| --- a/imports/ui/Task.jsx | |
| +++ b/imports/ui/Task.jsx | |
| @@ -30,6 +30,12 @@ export default class Task extends Component { | |
| onClick={this.toggleChecked.bind(this)} | |
| /> | |
| + { this.props.showPrivateButton ? ( | |
| + <button className="toggle-private" onClick={this.togglePrivate.bind(this)}> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/imports/ui/Task.jsx b/imports/ui/Task.jsx | |
| index bec76ba..db0999e 100644 | |
| --- a/imports/ui/Task.jsx | |
| +++ b/imports/ui/Task.jsx | |
| @@ -12,6 +12,10 @@ export default class Task extends Component { | |
| Meteor.call('tasks.remove', this.props.task._id); | |
| } | |
| + togglePrivate() { | |
| + Meteor.call('tasks.setPrivate', this.props.task._id, ! this.props.task.private); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/imports/ui/Task.jsx b/imports/ui/Task.jsx | |
| index db0999e..52450c3 100644 | |
| --- a/imports/ui/Task.jsx | |
| +++ b/imports/ui/Task.jsx | |
| @@ -1,5 +1,6 @@ | |
| import React, { Component, PropTypes } from 'react'; | |
| import { Meteor } from 'meteor/meteor'; | |
| +import classnames from 'classnames'; | |
| // Task component - represents a single todo item |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/imports/api/tasks.js b/imports/api/tasks.js | |
| index f1d2c92..441feee 100644 | |
| --- a/imports/api/tasks.js | |
| +++ b/imports/api/tasks.js | |
| @@ -6,8 +6,14 @@ export const Tasks = new Mongo.Collection('tasks'); | |
| if (Meteor.isServer) { | |
| // This code only runs on the server | |
| + // Only publish tasks that are public or belong to the current user | |
| Meteor.publish('tasks', function tasksPublication() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/imports/api/tasks.js b/imports/api/tasks.js | |
| index 441feee..9d5b56a 100644 | |
| --- a/imports/api/tasks.js | |
| +++ b/imports/api/tasks.js | |
| @@ -36,12 +36,24 @@ Meteor.methods({ | |
| 'tasks.remove'(taskId) { | |
| check(taskId, String); | |
| + const task = Tasks.findOne(taskId); | |
| + if (task.private && task.owner !== Meteor.userId()) { |