11.2 Getters for Todo and Complete
This commit is contained in:
parent
2f230d473e
commit
36f6285e24
@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<q-page class="q-pa-md">
|
||||
<q-list
|
||||
v-if="Object.keys(tasks).length"
|
||||
v-if="Object.keys(tasksTodo).length"
|
||||
separator
|
||||
bordered>
|
||||
|
||||
<task
|
||||
v-for="(task, key) in tasks"
|
||||
v-for="(task, key) in tasksTodo"
|
||||
:key="key"
|
||||
:task="task"
|
||||
:id="key"
|
||||
@ -42,11 +42,11 @@ export default {
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
showAddTask: true
|
||||
showAddTask: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('tasks', ['tasks'])
|
||||
...mapGetters('tasks', ['tasksTodo'])
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -56,8 +56,25 @@ const actions = {
|
||||
}
|
||||
|
||||
const getters = {
|
||||
tasks: (state) => {
|
||||
return state.tasks
|
||||
tasksTodo: (state) => {
|
||||
const tasks = {}
|
||||
Object.keys(state.tasks).forEach(function (key) {
|
||||
const task = state.tasks[key]
|
||||
if (!task.completed) {
|
||||
tasks[key] = task
|
||||
}
|
||||
})
|
||||
return tasks
|
||||
},
|
||||
tasksCompleted: (state) => {
|
||||
const tasks = {}
|
||||
Object.keys(state.tasks).forEach(function (key) {
|
||||
const task = state.tasks[key]
|
||||
if (task.completed) {
|
||||
tasks[key] = task
|
||||
}
|
||||
})
|
||||
return tasks
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user