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

View File

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

View File

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