11.6 Filter the Tasks based on Search Value
This commit is contained in:
parent
bcc2b87e6e
commit
001b7c6b85
@ -63,20 +63,37 @@ const actions = {
|
||||
}
|
||||
|
||||
const getters = {
|
||||
tasksTodo: (state) => {
|
||||
const tasks = {}
|
||||
tasksFiltered: (state) => {
|
||||
const tasksFiltered = {}
|
||||
if (state.search) {
|
||||
Object.keys(state.tasks).forEach(function (key) {
|
||||
const task = state.tasks[key]
|
||||
const task = state.tasks[key],
|
||||
taskNameLowerCase = task.name.toLowerCase(),
|
||||
searchLowerCase = state.search.toLowerCase()
|
||||
if (taskNameLowerCase.includes(searchLowerCase)) {
|
||||
tasksFiltered[key] = task
|
||||
}
|
||||
})
|
||||
return tasksFiltered
|
||||
}
|
||||
return state.tasks
|
||||
},
|
||||
tasksTodo: (state, getters) => {
|
||||
const tasksFiltered = getters.tasksFiltered
|
||||
const tasks = {}
|
||||
Object.keys(tasksFiltered).forEach(function (key) {
|
||||
const task = tasksFiltered[key]
|
||||
if (!task.completed) {
|
||||
tasks[key] = task
|
||||
}
|
||||
})
|
||||
return tasks
|
||||
},
|
||||
tasksCompleted: (state) => {
|
||||
tasksCompleted: (state, getters) => {
|
||||
const tasksFiltered = getters.tasksFiltered
|
||||
const tasks = {}
|
||||
Object.keys(state.tasks).forEach(function (key) {
|
||||
const task = state.tasks[key]
|
||||
Object.keys(tasksFiltered).forEach(function (key) {
|
||||
const task = tasksFiltered[key]
|
||||
if (task.completed) {
|
||||
tasks[key] = task
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user