Skip to content

Commit

Permalink
Updated stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
acidjunk committed Dec 20, 2016
1 parent c25947c commit 25b61e7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions static/react/kanban-app/app/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default class App extends React.Component {
super(props);

this.state = {
// Temporary datastore for notes
notes: [
// Temporary datastore for tasks
tasks: [
{
id: uuid.v4(),
task: 'Implement other data structures'
Expand All @@ -27,13 +27,13 @@ export default class App extends React.Component {
}

render() {
const {notes} = this.state;
const {tasks} = this.state;

return (
<div>
<button onClick={this.addTask}>+</button>
<Tasks
notes={notes}
tasks={tasks}
onTaskClick={this.activateTaskEdit}
onEdit={this.editTask}
onDelete={this.deleteTask}
Expand All @@ -43,9 +43,9 @@ export default class App extends React.Component {
}

addTask = () => {
console.log('Adding a new note');
console.log('Adding a new task');
this.setState({
notes: this.state.notes.concat([{
tasks: this.state.tasks.concat([{
id: uuid.v4(),
task: 'New task'
}])
Expand All @@ -57,29 +57,29 @@ export default class App extends React.Component {
e.stopPropagation();

this.setState({
notes: this.state.notes.filter(note => note.id !== id)
tasks: this.state.tasks.filter(task => task.id !== id)
});
}

activateTaskEdit = (id) => {
this.setState({
notes: this.state.notes.map(note => {
if(note.id === id) {
note.editing = true;
tasks: this.state.tasks.map(task => {
if(task.id === id) {
task.editing = true;
}
return note;
return task;
})
});
}

editTask = (id, task) => {
this.setState({
notes: this.state.notes.map(note => {
if(note.id === id) {
note.editing = false;
note.task = task;
tasks: this.state.tasks.map(task => {
if(task.id === id) {
task.editing = false;
task.task = task;
}
return note;
return task;
})
});
}
Expand Down
4 changes: 2 additions & 2 deletions static/react/kanban-app/app/components/Tasks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import Task from './Task';
import Editable from './Editable';

export default ({
notes,
tasks,
onTaskClick=() => {}, onEdit=() => {}, onDelete=() => {}
}) => (
<ul>{notes.map(({id, editing, task}) =>
<ul>{tasks.map(({id, editing, task}) =>
<li key={id}>
<Task onClick={onTaskClick.bind(null, id)}>
<Editable
Expand Down

0 comments on commit 25b61e7

Please sign in to comment.