0
0
Fork 0

feat: refs #6630 VnAvatar letter feature added

This commit is contained in:
Jorge Penadés 2024-01-10 16:49:09 +01:00
parent cdadb57af3
commit 3c8022ac45
2 changed files with 21 additions and 4 deletions

View File

@ -422,13 +422,13 @@ setLogTree();
> >
<div class="timeline"> <div class="timeline">
<div class="user-avatar"> <div class="user-avatar">
<VnUserLink v-if="userLog.user.image" :worker-id="userLog.user.id"> <VnUserLink :worker-id="userLog.user.id">
<template #link> <template #link>
<VnAvatar <VnAvatar
:class="{ 'cursor-pointer': userLog.user.id }" :class="{ 'cursor-pointer': userLog.user.id }"
:worker-id="userLog.user.id" :worker-id="userLog.user.id"
:title="userLog.user.nickname" :title="userLog.user.nickname"
size="md" size="lg"
/> />
</template> </template>
</VnUserLink> </VnUserLink>

View File

@ -1,20 +1,37 @@
<script setup> <script setup>
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useSession } from 'src/composables/useSession'; import { useSession } from 'src/composables/useSession';
import { useColor } from 'src/composables/useColor';
const $props = defineProps({ const $props = defineProps({
workerId: { type: Number, required: true }, workerId: { type: Number, required: true },
description: { type: String, default: null }, description: { type: String, default: null },
size: { type: String, default: 'xl' }, size: { type: String, default: null },
title: { type: String, default: null },
}); });
const session = useSession(); const session = useSession();
const token = session.getToken(); const token = session.getToken();
const { t } = useI18n();
const title = computed(() => $props.title ?? t('globals.system'));
const showLetter = ref(false);
</script> </script>
<template> <template>
<div class="avatar-picture column items-center"> <div class="avatar-picture column items-center">
<QAvatar color="orange" :size="$props.size"> <QAvatar
:style="{
backgroundColor: useColor(title),
}"
:size="$props.size"
:title="title"
>
<template v-if="showLetter">{{ title.charAt(0) }}</template>
<QImg <QImg
v-else
:src="`/api/Images/user/160x160/${$props.workerId}/download?access_token=${token}`" :src="`/api/Images/user/160x160/${$props.workerId}/download?access_token=${token}`"
spinner-color="white" spinner-color="white"
@error="showLetter = true"
/> />
</QAvatar> </QAvatar>
<div class="description"> <div class="description">