update to v2.1.0 #5
|
@ -1,6 +1,7 @@
|
|||
import { defineStore } from 'pinia';
|
||||
import { api } from '../internal';
|
||||
import { isAxiosError, useMainStore } from '.';
|
||||
import { DisplayNameMode } from '@flaschengeist/users';
|
||||
|
||||
export function fixUser(u?: FG.User) {
|
||||
return !u ? u : Object.assign(u, { birthday: u.birthday ? new Date(u.birthday) : undefined });
|
||||
|
@ -33,16 +34,40 @@ export const useUserStore = defineStore({
|
|||
getters: {
|
||||
users(state) {
|
||||
const u = state._users.filter((u) => !u.deleted);
|
||||
u.sort((a, b) => {
|
||||
const a_lastname = a.lastname.toLowerCase();
|
||||
const b_lastname = b.lastname.toLowerCase();
|
||||
const a_firstname = a.firstname.toLowerCase();
|
||||
const b_firstname = b.firstname.toLowerCase();
|
||||
if (a_lastname === b_lastname) {
|
||||
return a_firstname < b_firstname ? -1 : 1;
|
||||
}
|
||||
return a_lastname < b_lastname ? -1 : 1;
|
||||
});
|
||||
|
||||
switch (this.userSettings['display_name']) {
|
||||
case DisplayNameMode.FIRSTNAME_LASTNAME || DisplayNameMode.FIRSTNAME:
|
||||
u.sort((a, b) => {
|
||||
const a_lastname = a.lastname.toLowerCase();
|
||||
const b_lastname = b.lastname.toLowerCase();
|
||||
const a_firstname = a.firstname.toLowerCase();
|
||||
const b_firstname = b.firstname.toLowerCase();
|
||||
if (a_firstname === b_firstname) {
|
||||
return a_lastname < b_lastname ? -1 : 1;
|
||||
}
|
||||
return a_firstname < b_firstname ? -1 : 1;
|
||||
});
|
||||
break;
|
||||
case <string>DisplayNameMode.DISPLAYNAME:
|
||||
u.sort((a, b) => {
|
||||
const a_displayname = a.display_name.toLowerCase();
|
||||
const b_displayname = b.display_name.toLowerCase();
|
||||
return a_displayname < b_displayname ? -1 : 1;
|
||||
});
|
||||
break;
|
||||
default:
|
||||
u.sort((a, b) => {
|
||||
const a_lastname = a.lastname.toLowerCase();
|
||||
const b_lastname = b.lastname.toLowerCase();
|
||||
const a_firstname = a.firstname.toLowerCase();
|
||||
const b_firstname = b.firstname.toLowerCase();
|
||||
if (a_lastname === b_lastname) {
|
||||
return a_firstname < b_firstname ? -1 : 1;
|
||||
}
|
||||
return a_lastname < b_lastname ? -1 : 1;
|
||||
});
|
||||
}
|
||||
|
||||
return u;
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue