tweak(dashboard): re-add sorting by birthday and creation
This commit is contained in:
parent
2a5cadff13
commit
15a5f78cf1
@ -119,6 +119,9 @@ function resetPage() {
|
|||||||
<option value="pronouns">Pronouns</option>
|
<option value="pronouns">Pronouns</option>
|
||||||
<option value="birthday">Birthday</option>
|
<option value="birthday">Birthday</option>
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if !pageOptions.isPublic}
|
||||||
|
<option value="created">Creation date</option>
|
||||||
|
{/if}
|
||||||
<option value="none">API response order</option>
|
<option value="none">API response order</option>
|
||||||
</Input>
|
</Input>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
@ -100,24 +100,32 @@ function sort<T extends Member|Group>(list: T[], options: ListOptions): T[] {
|
|||||||
let aa = (a as Member).birthday;
|
let aa = (a as Member).birthday;
|
||||||
let bb = (b as Member).birthday;
|
let bb = (b as Member).birthday;
|
||||||
|
|
||||||
if (aa === null) {
|
if (aa === bb) return a.name.localeCompare(b.name);
|
||||||
return 1;
|
|
||||||
}
|
if (aa === null) return 1;
|
||||||
if (bb === null) {
|
if (bb === null) return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
let aBirthday = moment(aa.slice(5, aa.length), "MM-DD", true);
|
let aBirthday = moment(aa.slice(5, aa.length), "MM-DD", true);
|
||||||
let bBirthday = moment(bb.slice(5, bb.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.isBefore(bBirthday)) return -1;
|
||||||
if (aBirthday.isAfter(bBirthday)) {
|
});
|
||||||
return 1;
|
} else if (options.sort === 'created') {
|
||||||
}
|
newList = [...list].sort((a, b) => {
|
||||||
if (aBirthday === bBirthday) {
|
let aa = a.created;
|
||||||
return 0;
|
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;
|
return newList;
|
||||||
|
@ -47,7 +47,7 @@ export interface ListOptions {
|
|||||||
|
|
||||||
}
|
}
|
||||||
// what it says on the tin
|
// 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",
|
order: "ascending"|"descending",
|
||||||
show: "all"|"private"|"public",
|
show: "all"|"private"|"public",
|
||||||
// so we can change the key for duplicate members on the randomize page
|
// so we can change the key for duplicate members on the randomize page
|
||||||
|
Loading…
x
Reference in New Issue
Block a user