[FIX] examples: update benchmarks/todoapp to new code

This commit is contained in:
Géry Debongnie
2019-04-17 10:55:53 +02:00
parent 94ed6ebe60
commit ce87dd705e
5 changed files with 18 additions and 16 deletions
+4
View File
@@ -54,6 +54,10 @@ class TodoApp extends Component {
toggleAll() {
this.env.store.dispatch("toggleAll", !this.allChecked);
}
setFilter(filter) {
this.state.filter = filter;
}
}
export default connect(mapStateToProps)(TodoApp);
+8 -6
View File
@@ -15,10 +15,12 @@ export class TodoItem extends owl.Component {
}
async editTodo() {
await this.updateState({ isEditing: true });
this.refs.input.value = "";
this.refs.input.focus();
this.refs.input.value = this.props.title;
this.state.isEditing = true;
setTimeout(() => {
this.refs.input.value = "";
this.refs.input.focus();
this.refs.input.value = this.props.title;
});
}
handleKeyup(ev) {
@@ -27,7 +29,7 @@ export class TodoItem extends owl.Component {
}
if (ev.keyCode === ESC_KEY) {
ev.target.value = this.props.title;
this.updateState({ isEditing: false });
this.state.isEditing = false;
}
}
@@ -43,7 +45,7 @@ export class TodoItem extends owl.Component {
id: this.props.id,
title: value
});
this.updateState({ isEditing: false });
this.state.isEditing = false;
}
}
}
+3 -3
View File
@@ -27,13 +27,13 @@
</span>
<ul class="filters">
<li>
<a href="#/all" t-on-click="updateState({filter:'all'})" t-att-class="{selected: state.filter === 'all'}">All</a>
<a href="#/all" t-on-click="setFilter('all')" t-att-class="{selected: state.filter === 'all'}">All</a>
</li>
<li>
<a href="#/active" t-on-click="updateState({filter:'active'})" t-att-class="{selected: state.filter === 'active'}">Active</a>
<a href="#/active" t-on-click="setFilter('active')" t-att-class="{selected: state.filter === 'active'}">Active</a>
</li>
<li>
<a href="#/completed" t-on-click="updateState({filter:'completed'})" t-att-class="{selected: state.filter === 'completed'}">Completed</a>
<a href="#/completed" t-on-click="setFilter('completed')" t-att-class="{selected: state.filter === 'completed'}">Completed</a>
</li>
</ul>
<button class="clear-completed" t-if="props.todos.length gt remaining" t-on-click="clearCompleted">