diff --git a/dashboard/src/components/list/ListControl.svelte b/dashboard/src/components/list/ListControl.svelte index d1577e19..df5ecef7 100644 --- a/dashboard/src/components/list/ListControl.svelte +++ b/dashboard/src/components/list/ListControl.svelte @@ -119,6 +119,9 @@ function resetPage() { {/if} + {#if !pageOptions.isPublic} + + {/if} diff --git a/dashboard/src/components/list/functions.ts b/dashboard/src/components/list/functions.ts index bdc01559..67f4a6f9 100644 --- a/dashboard/src/components/list/functions.ts +++ b/dashboard/src/components/list/functions.ts @@ -100,24 +100,32 @@ function sort(list: T[], options: ListOptions): T[] { let aa = (a as Member).birthday; let bb = (b as Member).birthday; - if (aa === null) { - return 1; - } - if (bb === null) { - return -1; - } + if (aa === bb) return a.name.localeCompare(b.name); + + if (aa === null) return 1; + if (bb === null) return -1; let aBirthday = moment(aa.slice(5, aa.length), "MM-DD", true); let bBirthday = moment(bb.slice(5, bb.length), "MM-DD", true); - if (aBirthday.isBefore(bBirthday)) { - return -1; - } - if (aBirthday.isAfter(bBirthday)) { - return 1; - } - if (aBirthday === bBirthday) { - return 0; - } + + if (aBirthday.isAfter(bBirthday)) return 1; + if (aBirthday.isBefore(bBirthday)) return -1; + }); + } else if (options.sort === 'created') { + newList = [...list].sort((a, b) => { + let aa = a.created; + let bb = b.created; + + if (aa === bb) return a.name.localeCompare(b.name); + + if (aa === null) return 1; + if (bb === null) return -1; + + let aCreated = moment(aa); + let bCreated = moment(bb); + + if (aCreated.isAfter(bCreated)) return 1; + if (aCreated.isBefore(bCreated)) return -1; }); } return newList; diff --git a/dashboard/src/components/list/types.ts b/dashboard/src/components/list/types.ts index 456029ca..ab093a29 100644 --- a/dashboard/src/components/list/types.ts +++ b/dashboard/src/components/list/types.ts @@ -47,7 +47,7 @@ export interface ListOptions { } // what it says on the tin - sort: 'name'|'description'|'birthday'|'pronouns'|'display_name'|'id'|'none', + sort: 'name'|'description'|'birthday'|'pronouns'|'display_name'|'id'|'none'|'created', order: "ascending"|"descending", show: "all"|"private"|"public", // so we can change the key for duplicate members on the randomize page