[feat] show names by display mode setting

This commit is contained in:
Tim Gröger 2024-10-08 14:46:44 +02:00
parent 923f5ec27c
commit aa3c172160
2 changed files with 25 additions and 4 deletions

View File

@ -101,6 +101,7 @@ import { PERMISSIONS } from '../../../permissions';
import TransferInviteDialog from './TransferInviteDialog.vue'; import TransferInviteDialog from './TransferInviteDialog.vue';
import ServiceUserChip from './ServiceUserChip.vue'; import ServiceUserChip from './ServiceUserChip.vue';
import { UserAvatar } from '@flaschengeist/api/components'; import { UserAvatar } from '@flaschengeist/api/components';
import { DisplayNameMode } from '@flaschengeist/users';
export default defineComponent({ export default defineComponent({
name: 'JobSlot', name: 'JobSlot',
@ -123,11 +124,34 @@ export default defineComponent({
const quasar = useQuasar(); const quasar = useQuasar();
// Make sure users are loaded if we can assign them // Make sure users are loaded if we can assign them
onBeforeMount(() => void userStore.getUsers()); onBeforeMount(() => {
void userStore.getUsers();
void userStore.getDisplayNameModeSetting(true);
});
/* Stuff used for general display */ /* Stuff used for general display */
// Get displayname of user // Get displayname of user
function userDisplay(id: string) { 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 (
`${<string>userStore.findUser(id)?.firstname} ${<string>(
userStore.findUser(id)?.lastname
)}` || id
);
case DisplayNameMode.LASTNAME_FIRSTNAME:
return (
`${<string>userStore.findUser(id)?.lastname}, ${<string>(
userStore.findUser(id)?.firstname
)}` || id
);
}
return userStore.findUser(id)?.display_name || id; return userStore.findUser(id)?.display_name || id;
} }

View File

@ -159,7 +159,6 @@ export default defineComponent({
}; };
onBeforeMount(async () => { onBeforeMount(async () => {
if (route.query.sent === 'true') { if (route.query.sent === 'true') {
showSent.value = true; showSent.value = true;
} }
@ -178,8 +177,6 @@ export default defineComponent({
await router.replace({ query: { sent: showSent.value ? 'true' : 'false' } }); await router.replace({ query: { sent: showSent.value ? 'true' : 'false' } });
}); });
function getType(row: RowData) { function getType(row: RowData) {
var idx = row.transferee === undefined ? 0 : 1; var idx = row.transferee === undefined ? 0 : 1;
if (row.inviter.userid === mainStore.currentUser.userid) idx += 2; if (row.inviter.userid === mainStore.currentUser.userid) idx += 2;