fix: show lead image, pass image_label also show contact image

if label has some prefix like Mr Mrs the avatar only shows M so added image_label
This commit is contained in:
Shariq Ansari 2023-07-25 19:49:42 +05:30
parent e9762935f7
commit 8784720c47
3 changed files with 24 additions and 12 deletions

View File

@ -68,18 +68,19 @@
>
<div v-if="column.type === 'user'">
<Avatar
v-if="getValue(row[column.key])"
v-if="getValue(row[column.key]).label"
class="flex items-center"
:image="getValue(row[column.key]).image"
:label="getValue(row[column.key]).label"
:label="getValue(row[column.key]).image_label"
size="md"
/>
</div>
<div v-else-if="column.type === 'logo'">
<Avatar
v-if="getValue(row[column.key]).label"
class="flex items-center"
:image="getValue(row[column.key]).logo"
:label="getValue(row[column.key]).label"
:label="getValue(row[column.key]).image_label"
size="md"
shape="square"
/>
@ -167,9 +168,10 @@ const viewsDropdownOptions = [
]
function getValue(value) {
if (typeof value === 'object') {
if (value && typeof value === 'object') {
value.label = value.full_name || value.label
value.image = value.user_image || value.logo
value.image = value.image || value.user_image || value.logo
value.image_label = value.image_label || value.label
return value
}
return {

View File

@ -12,7 +12,7 @@ const title = 'Contacts'
const contacts = createListResource({
type: 'list',
doctype: 'Contact',
fields: ['name', 'full_name', 'email_id', 'phone'],
fields: ['name', 'full_name', 'image', 'email_id', 'phone'],
orderBy: 'full_name asc',
cache: 'Contacts',
pageLength: 999,
@ -44,7 +44,11 @@ const columns = [
const rows = computed(() => {
return contacts.data?.map((contact) => {
return {
full_name: contact.full_name,
full_name: {
label: contact.full_name,
image_label: contact.full_name,
image: contact.image,
},
email: contact.email_id,
phone: contact.phone,
}

View File

@ -17,7 +17,8 @@ const leads = createListResource({
fields: [
'name',
'first_name',
'last_name',
'lead_name',
'image',
'organization_name',
'organization_logo',
'status',
@ -26,7 +27,7 @@ const leads = createListResource({
'lead_owner',
'modified',
],
orderBy: 'modified asc',
orderBy: 'modified desc',
cache: 'Leads',
pageLength: 999,
auto: true,
@ -36,7 +37,8 @@ leads.fetch()
const columns = [
{
label: 'Name',
key: 'full_name',
key: 'lead_name',
type: 'user',
size: 'w-44',
},
{
@ -74,7 +76,11 @@ const columns = [
const rows = computed(() => {
return leads.data?.map((lead) => {
return {
full_name: lead.first_name + ' ' + lead.last_name,
lead_name: {
label: lead.lead_name,
image: lead.image,
image_label: lead.first_name,
},
organization_name: {
label: lead.organization_name,
logo: lead.organization_logo,
@ -85,7 +91,7 @@ const rows = computed(() => {
},
email: lead.email,
mobile_no: lead.mobile_no,
lead_owner: getUser(lead.lead_owner),
lead_owner: lead.lead_owner && getUser(lead.lead_owner),
}
})
})