|
@@ -16,10 +16,14 @@
|
|
|
<input class="toggle-all" id="toggle-all"
|
|
|
type="checkbox"
|
|
|
:checked="allChecked"
|
|
|
- @change="toggleAll({ done: !allChecked })">
|
|
|
+ @change="toggleAll(!allChecked)">
|
|
|
<label for="toggle-all"></label>
|
|
|
<ul class="todo-list">
|
|
|
- <todo v-for="(todo, index) in filteredTodos" :key="index" :todo="todo"></todo>
|
|
|
+ <TodoItem
|
|
|
+ v-for="(todo, index) in filteredTodos"
|
|
|
+ :key="index"
|
|
|
+ :todo="todo"
|
|
|
+ />
|
|
|
</ul>
|
|
|
</section>
|
|
|
<!-- footer -->
|
|
@@ -45,8 +49,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { mapMutations } from 'vuex'
|
|
|
-import Todo from './Todo.vue'
|
|
|
+import { mapActions } from 'vuex'
|
|
|
+import TodoItem from './TodoItem.vue'
|
|
|
|
|
|
const filters = {
|
|
|
all: todos => todos,
|
|
@@ -55,7 +59,7 @@ const filters = {
|
|
|
}
|
|
|
|
|
|
export default {
|
|
|
- components: { Todo },
|
|
|
+ components: { TodoItem },
|
|
|
data () {
|
|
|
return {
|
|
|
visibility: 'all',
|
|
@@ -77,17 +81,17 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ ...mapActions([
|
|
|
+ 'toggleAll',
|
|
|
+ 'clearCompleted'
|
|
|
+ ]),
|
|
|
addTodo (e) {
|
|
|
- var text = e.target.value
|
|
|
+ const text = e.target.value
|
|
|
if (text.trim()) {
|
|
|
- this.$store.commit('addTodo', { text })
|
|
|
+ this.$store.dispatch('addTodo', text)
|
|
|
}
|
|
|
e.target.value = ''
|
|
|
- },
|
|
|
- ...mapMutations([
|
|
|
- 'toggleAll',
|
|
|
- 'clearCompleted'
|
|
|
- ])
|
|
|
+ }
|
|
|
},
|
|
|
filters: {
|
|
|
pluralize: (n, w) => n === 1 ? w : (w + 's'),
|