Skip to content

Commit ac3fbe0

Browse files
committed
feat(core): add complete all
1 parent 4138e3a commit ac3fbe0

File tree

4 files changed

+24
-19
lines changed

4 files changed

+24
-19
lines changed

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module.exports = {
22
presets: [
33
'@vue/app'
44
]
5-
}
5+
};

src/components/Footer.vue

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
<footer class="footer">
33
<span class="todo-count"><strong>{{ itemsLeft }}</strong><span> {{ itemText }} left</span></span>
44
<ul class="filters">
5-
<li v-for="filterKey in Object.keys(filterTitles)" :key="filterKey">
6-
<a
7-
href="#"
8-
:class="{ selected: filterKey === filter }"
9-
@click="onFilterSelect(filterKey)"
10-
>
11-
{{ filterTitles[filterKey] }}
12-
</a>
13-
</li>
5+
<li v-for="filterKey in Object.keys(filterTitles)" :key="filterKey">
6+
<a
7+
href="#"
8+
:class="{ selected: filterKey === filter }"
9+
@click="onFilterSelect(filterKey)"
10+
>
11+
{{ filterTitles[filterKey] }}
12+
</a>
13+
</li>
1414
</ul>
1515
<button v-if="!!completedCount" class="clear-completed" @click="onClearCompleted">Clear completed</button>
1616
</footer>

src/components/List.vue

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<template>
2-
<section class="main">
3-
<input id="toggle-all" class="toggle-all" type="checkbox" />
4-
<label htmlFor="toggle-all"></label>
2+
<section class="main">
3+
<input id="toggle-all" class="toggle-all" type="checkbox" :checked="areAllCompleted" readonly />
4+
<label htmlFor="toggle-all" @click="onCompleteAll"></label>
55

6-
<ul class="todo-list">
7-
<Item v-for="todo in todos" :key="todo.id" :todo="todo" @remove="onRemove" @update="onUpdate" />
8-
</ul>
9-
</section>
6+
<ul class="todo-list">
7+
<Item v-for="todo in todos" :key="todo.id" :todo="todo" @remove="onRemove" @update="onUpdate" />
8+
</ul>
9+
</section>
1010
</template>
1111

1212
<script>
@@ -19,8 +19,13 @@
1919
Item
2020
},
2121
props: ['todos'],
22+
computed: {
23+
areAllCompleted() {
24+
return this.todos.length && this.todos.every(todo => todo.completed);
25+
}
26+
},
2227
methods: {
23-
...mapActions(['onRemove', 'onUpdate'])
28+
...mapActions(['onRemove', 'onUpdate', 'onCompleteAll'])
2429
}
2530
};
2631
</script>

src/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ Vue.use(Vuex);
99

1010
new Vue({
1111
store: storeFactory(),
12-
render: h => h(App),
12+
render: h => h(App)
1313
}).$mount('#app');

0 commit comments

Comments
 (0)