Compare commits

...

2 Commits

3 changed files with 20 additions and 15 deletions

View File

@ -16,7 +16,7 @@
<script lang="ts">
import { computed, defineComponent, PropType, onBeforeMount, ref } from 'vue';
import { useUserStore } from '@flaschengeist/api';
import { DisplayNameMode } from '../models';
import { showName } from '../utils';
export default defineComponent({
name: 'UserSelector',
@ -68,20 +68,6 @@ export default defineComponent({
get: () => props.modelValue,
set: (value: FG.User | undefined) => (value ? emit('update:modelValue', value) : undefined),
});
function showName(user: FG.User) {
switch (userStore.userSettings.display_name) {
case DisplayNameMode.DISPLAYNAME:
return user.display_name;
case DisplayNameMode.FIRSTNAME:
return user.firstname;
case DisplayNameMode.LASTNAME:
return user.lastname;
case DisplayNameMode.FIRSTNAME_LASTNAME:
return `${user.firstname} ${user.lastname}`;
case DisplayNameMode.LASTNAME_FIRSTNAME:
return `${user.lastname}, ${user.firstname}`;
}
}
return {
selected,

View File

@ -29,3 +29,4 @@ const plugin: FG_Plugin.Plugin = {
export default plugin;
export { DisplayNameMode };
export * from './utils';

18
src/utils/index.ts Normal file
View File

@ -0,0 +1,18 @@
import { DisplayNameMode } from '../models';
import { useUserStore } from '@flaschengeist/api';
export function showName(user: FG.User) {
const userStore = useUserStore();
switch (userStore.userSettings.display_name) {
case DisplayNameMode.DISPLAYNAME:
return user.display_name;
case DisplayNameMode.FIRSTNAME:
return user.firstname;
case DisplayNameMode.LASTNAME:
return user.lastname;
case DisplayNameMode.FIRSTNAME_LASTNAME:
return `${user.firstname} ${user.lastname}`;
case DisplayNameMode.LASTNAME_FIRSTNAME:
return `${user.lastname}, ${user.firstname}`;
}
}