12.3 Make the Sort Criteria Configurable

This commit is contained in:
Fredrick W Warren 2021-02-10 15:53:18 -08:00
parent 96f167549d
commit 32f059e9f9

View File

@ -24,7 +24,8 @@ const state = {
}
*/
},
search: ''
search: '',
sort: 'name'
}
const mutations = {
@ -68,8 +69,8 @@ const getters = {
const keysOrdered = Object.keys(state.tasks)
keysOrdered.sort((a, b) => {
const taskAProp = state.tasks[a].name.toLowerCase()
const taskBProp = state.tasks[b].name.toLowerCase()
const taskAProp = state.tasks[a].[state.sort].toLowerCase()
const taskBProp = state.tasks[b].[state.sort].toLowerCase()
if (taskAProp > taskBProp) return 1
else if (taskAProp < taskBProp) return -1
else return 0