|
@@ -47,6 +47,7 @@ class App extends Component {
|
|
|
};
|
|
|
this.handleAddItem = this.handleAddItem.bind(this);
|
|
|
this.handleToggleAllComplete = this.handleToggleAllComplete.bind(this);
|
|
|
+ this.handleToggleComplete = this.handleToggleComplete.bind(this);
|
|
|
this.setSource = this.setSource.bind(this);
|
|
|
}
|
|
|
|
|
@@ -75,6 +76,19 @@ class App extends Component {
|
|
|
this.setSource(newItems, newItems, { allComplete: complete });
|
|
|
}
|
|
|
|
|
|
+ handleToggleComplete(key, complete) {
|
|
|
+ const newItems = this.state.items.map((item) => {
|
|
|
+ if (item.key !== key) {
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ complete
|
|
|
+ };
|
|
|
+ });
|
|
|
+ this.setSource(newItems, newItems);
|
|
|
+ }
|
|
|
+
|
|
|
render() {
|
|
|
|
|
|
return (
|
|
@@ -95,6 +109,7 @@ class App extends Component {
|
|
|
return (
|
|
|
<Row
|
|
|
key={key}
|
|
|
+ onComplete={(complete) => this.handleToggleComplete(key, complete)}
|
|
|
{ ...value }
|
|
|
/>
|
|
|
);
|