chore: refs #7283 update VnAvatar title handling
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-08-12 11:00:03 +02:00
parent f5ffe2a07b
commit 239e796d2e
3 changed files with 13 additions and 8 deletions

View File

@ -8,18 +8,18 @@ import { getCssVar } from 'quasar';
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 },
title: { type: [String, Boolean], default: null }, title: { type: [String], default: null },
color: { type: String, default: null }, color: { type: String, default: null },
}); });
const { getTokenMultimedia } = useSession(); const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia(); const token = getTokenMultimedia();
const { t } = useI18n(); const { t } = useI18n();
const src = computed( const src = computed(
() => `/api/Images/user/160x160/${$props.workerId}/download?access_token=${token}` () => `/api/Images/user/160x160/${$props.workerId}/download?access_token=${token}`
); );
const title = computed(() => const title = computed(() => $props.title?.toUpperCase() || t('globals.system'));
$props.title !== false ? $props.title || t('globals.system') : false
);
const showLetter = ref(false); const showLetter = ref(false);
const backgroundColor = computed(() => { const backgroundColor = computed(() => {
const color = $props.color || useColor(title.value); const color = $props.color || useColor(title.value);
@ -33,9 +33,9 @@ watch(src, () => (showLetter.value = false));
<QAvatar <QAvatar
:style="{ backgroundColor }" :style="{ backgroundColor }"
v-bind="$attrs" v-bind="$attrs"
:title="title !== false ? title : undefined" :title="title || t('globals.system')"
> >
<template v-if="showLetter && title !== false"> <template v-if="showLetter">
{{ title.charAt(0) }} {{ title.charAt(0) }}
</template> </template>
<QImg v-else :src="src" spinner-color="white" @error="showLetter = true" /> <QImg v-else :src="src" spinner-color="white" @error="showLetter = true" />

View File

@ -94,7 +94,9 @@ const statesFilter = {
<VnAvatar <VnAvatar
:worker-id="data.workerFk" :worker-id="data.workerFk"
size="md" size="md"
:title="false" :title="
workersOptions.find(({ id }) => id == data.workerFk)?.name
"
color="primary" color="primary"
/> />
</template> </template>

View File

@ -15,6 +15,7 @@ const { t } = useI18n();
const businessTypes = ref([]); const businessTypes = ref([]);
const contactChannels = ref([]); const contactChannels = ref([]);
const title = ref();
</script> </script>
<template> <template>
<FetchData <FetchData
@ -95,12 +96,14 @@ const contactChannels = ref([]);
:label="t('customer.basicData.salesPerson')" :label="t('customer.basicData.salesPerson')"
:rules="validate('client.salesPersonFk')" :rules="validate('client.salesPersonFk')"
:use-like="false" :use-like="false"
:emit-value="false"
@update:model-value="(val) => (title = val?.nickname)"
> >
<template #prepend> <template #prepend>
<VnAvatar <VnAvatar
:worker-id="data.salesPersonFk" :worker-id="data.salesPersonFk"
color="primary" color="primary"
:title="false" :title="title"
/> />
</template> </template>
</VnSelect> </VnSelect>