12.3 Make the Sort Criteria Configurable
This commit is contained in:
parent
96f167549d
commit
32f059e9f9
@ -24,7 +24,8 @@ const state = {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
},
|
},
|
||||||
search: ''
|
search: '',
|
||||||
|
sort: 'name'
|
||||||
}
|
}
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
@ -68,8 +69,8 @@ const getters = {
|
|||||||
const keysOrdered = Object.keys(state.tasks)
|
const keysOrdered = Object.keys(state.tasks)
|
||||||
|
|
||||||
keysOrdered.sort((a, b) => {
|
keysOrdered.sort((a, b) => {
|
||||||
const taskAProp = state.tasks[a].name.toLowerCase()
|
const taskAProp = state.tasks[a].[state.sort].toLowerCase()
|
||||||
const taskBProp = state.tasks[b].name.toLowerCase()
|
const taskBProp = state.tasks[b].[state.sort].toLowerCase()
|
||||||
if (taskAProp > taskBProp) return 1
|
if (taskAProp > taskBProp) return 1
|
||||||
else if (taskAProp < taskBProp) return -1
|
else if (taskAProp < taskBProp) return -1
|
||||||
else return 0
|
else return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user