update to v2.1.0 #5
|
@ -1,6 +1,7 @@
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import { api } from '../internal';
|
import { api } from '../internal';
|
||||||
import { isAxiosError, useMainStore } from '.';
|
import { isAxiosError, useMainStore } from '.';
|
||||||
|
import { DisplayNameMode } from '@flaschengeist/users';
|
||||||
|
|
||||||
export function fixUser(u?: FG.User) {
|
export function fixUser(u?: FG.User) {
|
||||||
return !u ? u : Object.assign(u, { birthday: u.birthday ? new Date(u.birthday) : undefined });
|
return !u ? u : Object.assign(u, { birthday: u.birthday ? new Date(u.birthday) : undefined });
|
||||||
|
@ -33,6 +34,28 @@ export const useUserStore = defineStore({
|
||||||
getters: {
|
getters: {
|
||||||
users(state) {
|
users(state) {
|
||||||
const u = state._users.filter((u) => !u.deleted);
|
const u = state._users.filter((u) => !u.deleted);
|
||||||
|
|
||||||
|
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) => {
|
u.sort((a, b) => {
|
||||||
const a_lastname = a.lastname.toLowerCase();
|
const a_lastname = a.lastname.toLowerCase();
|
||||||
const b_lastname = b.lastname.toLowerCase();
|
const b_lastname = b.lastname.toLowerCase();
|
||||||
|
@ -43,6 +66,8 @@ export const useUserStore = defineStore({
|
||||||
}
|
}
|
||||||
return a_lastname < b_lastname ? -1 : 1;
|
return a_lastname < b_lastname ? -1 : 1;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return u;
|
return u;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue