From e7cd0320bfc052ca9e0e08907b48047a2a4ace2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Fri, 11 Oct 2024 08:07:35 +0200 Subject: [PATCH] [fix] show name by display mode setting use showName from user plugin. No need to do it by itself. --- src/components/overview/slots/JobSlot.vue | 26 +++---------------- .../overview/slots/ServiceUserChip.vue | 3 ++- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/components/overview/slots/JobSlot.vue b/src/components/overview/slots/JobSlot.vue index 5853a80..dfda11f 100644 --- a/src/components/overview/slots/JobSlot.vue +++ b/src/components/overview/slots/JobSlot.vue @@ -101,7 +101,7 @@ import { PERMISSIONS } from '../../../permissions'; import TransferInviteDialog from './TransferInviteDialog.vue'; import ServiceUserChip from './ServiceUserChip.vue'; import { UserAvatar } from '@flaschengeist/api/components'; -import { DisplayNameMode } from '@flaschengeist/users'; +import { showName } from '@flaschengeist/users'; export default defineComponent({ name: 'JobSlot', @@ -132,27 +132,9 @@ export default defineComponent({ /* Stuff used for general display */ // Get displayname of user function userDisplay(id: string) { - switch (userStore.userSettings.display_name) { - case DisplayNameMode.FIRSTNAME: - return userStore.findUser(id)?.firstname || id; - case DisplayNameMode.LASTNAME: - return userStore.findUser(id)?.lastname || id; - case DisplayNameMode.DISPLAYNAME: - return userStore.findUser(id)?.display_name || id; - case DisplayNameMode.FIRSTNAME_LASTNAME: - return ( - `${userStore.findUser(id)?.firstname} ${( - userStore.findUser(id)?.lastname - )}` || id - ); - case DisplayNameMode.LASTNAME_FIRSTNAME: - return ( - `${userStore.findUser(id)?.lastname}, ${( - userStore.findUser(id)?.firstname - )}` || id - ); - } - return userStore.findUser(id)?.display_name || id; + const user = userStore.findUser(id); + + return user ? showName(user) : id; } // The name of the current job diff --git a/src/components/overview/slots/ServiceUserChip.vue b/src/components/overview/slots/ServiceUserChip.vue index 90929bd..264a624 100644 --- a/src/components/overview/slots/ServiceUserChip.vue +++ b/src/components/overview/slots/ServiceUserChip.vue @@ -21,6 +21,7 @@ import { useUserStore } from '@flaschengeist/api'; import { PropType, computed, defineComponent, onBeforeMount, ref, watch } from 'vue'; import { UserAvatar } from '@flaschengeist/api/components'; +import { showName } from '@flaschengeist/users'; export default defineComponent({ name: 'ServiceUserChip', @@ -50,7 +51,7 @@ export default defineComponent({ async () => (user.value = await userStore.getUser(props.modelValue.userid)) ); - const displayName = computed(() => user.value?.display_name || '...'); + const displayName = computed(() => (user.value ? showName(user.value) : '...')); const serviceValue = computed(() => props.modelValue.value.toFixed(Number.isInteger(props.modelValue.value) ? 0 : 1) );