feat(dashboard): sort/filter by color

This commit is contained in:
Jake Fulmine 2023-01-21 20:47:40 +01:00
parent 65dea53c64
commit f22c23c5f1
3 changed files with 31 additions and 2 deletions

View file

@ -121,6 +121,22 @@ function sort<T extends Member|Group>(list: T[], options: ListOptions): T[] {
return aa.localeCompare(bb);
});
} else if (options.sort === 'color') {
newList = [...list].sort((a, b) => {
let aa = Number("0x" + a.color);
let bb = Number("0x" + b.color);
if (a.color === null) return 1;
if (b.color === null) return -1;
if (aa === bb) return a.name.localeCompare(b.name);
if (Number.isNaN(aa)) return 1;
if (Number.isNaN(bb)) return -1;
if (aa > bb) return 1;
if (aa < bb) return -1;
})
}
return newList;
}