fix: added tooltip for listview column cells

This commit is contained in:
Shariq Ansari 2023-08-26 12:00:10 +05:30
parent 46bcdf7a5d
commit 66420a1444
2 changed files with 31 additions and 9 deletions

View File

@ -1,15 +1,38 @@
<template>
<slot name="prefix"></slot>
<slot v-if="$slots.default" />
<div v-else class="text-base text-gray-900 truncate">
{{ value }}
</div>
<Tooltip :text="tooltipText" class="flex items-center space-x-2.5">
<slot name="prefix"></slot>
<div class="text-base truncate">
{{ label }}
</div>
</Tooltip>
</template>
<script setup>
import { dateFormat, timeAgo, dateTooltipFormat } from '@/utils'
import { Tooltip } from 'frappe-ui'
import { computed } from 'vue'
const props = defineProps({
value: {
type: {
type: String,
default: null,
default: 'text',
},
value: {
type: [String, Number, Object],
default: '',
},
})
const tooltipText = computed(() => {
if (props.type === 'pretty_date') {
return dateFormat(props.value, dateTooltipFormat)
}
return props.value?.toString()
})
const label = computed(() => {
if (props.type === 'pretty_date') {
return timeAgo(props.value)
}
return props.value?.toString()
})
</script>

View File

@ -39,10 +39,9 @@
<div
v-for="column in columns"
:key="column.key"
class="flex items-center space-x-2.5"
:class="[column.size, column.align]"
>
<ListRowItem :value="getValue(row[column.key]).label">
<ListRowItem :value="getValue(row[column.key]).label" :type="column.type">
<template #prefix>
<div v-if="column.type === 'indicator'">
<IndicatorIcon :class="getValue(row[column.key]).color" />