Add Priority and label to sort by
This commit is contained in:
parent
933ca9a085
commit
587cc3989f
1 changed files with 21 additions and 0 deletions
|
@ -172,19 +172,40 @@ const MyChores = () => {
|
||||||
case 4:
|
case 4:
|
||||||
groupRaw['p4'].push(chore)
|
groupRaw['p4'].push(chore)
|
||||||
break
|
break
|
||||||
|
default:
|
||||||
|
groupRaw['no_priority'].push(chore)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
groups = [
|
||||||
|
{ name: 'Priority 1', content: groupRaw['p1'] },
|
||||||
|
{ name: 'Priority 2', content: groupRaw['p2'] },
|
||||||
|
{ name: 'Priority 3', content: groupRaw['p3'] },
|
||||||
|
{ name: 'Priority 4', content: groupRaw['p4'] },
|
||||||
|
{ name: 'No Priority', content: groupRaw['no_priority'] },
|
||||||
|
]
|
||||||
break
|
break
|
||||||
case 'labels':
|
case 'labels':
|
||||||
groupRaw = {}
|
groupRaw = {}
|
||||||
|
var labels = {}
|
||||||
chores.forEach(chore => {
|
chores.forEach(chore => {
|
||||||
chore.labelsV2.forEach(label => {
|
chore.labelsV2.forEach(label => {
|
||||||
|
labels[label.id] = label
|
||||||
if (groupRaw[label.id] === undefined) {
|
if (groupRaw[label.id] === undefined) {
|
||||||
groupRaw[label.id] = []
|
groupRaw[label.id] = []
|
||||||
}
|
}
|
||||||
groupRaw[label.id].push(chore)
|
groupRaw[label.id].push(chore)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
groups = Object.keys(groupRaw).map(key => {
|
||||||
|
return {
|
||||||
|
name: labels[key].name,
|
||||||
|
content: groupRaw[key],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
groups.sort((a, b) => {
|
||||||
|
a.name < b.name ? 1 : -1
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return groups
|
return groups
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue