scinote-web/app/javascript/vue/experiments/renderers/description.vue

52 lines
1.7 KiB
Vue
Raw Normal View History

2023-12-07 03:53:11 +08:00
<template>
<template v-if="params.dtComponent.currentViewRender === 'table'">
<div class="group relative flex items-center group-hover:marker text-xs h-full w-full leading-[unset]">
<div class="flex gap-2 w-full items-center text-sm leading-[unset]">
<span class="cursor-pointer line-clamp-1 leading-[unset]"
2024-03-01 20:37:31 +08:00
@click.stop="showDescriptionModal"
v-html="params.data.sa_description">
</span>
<span @click.stop="showDescriptionModal" class="text-sn-blue cursor-pointer shrink-0 inline-block text-sm">
{{ i18n.t('experiments.card.more') }}
</span>
2024-03-01 20:37:31 +08:00
</div>
2023-12-07 03:53:11 +08:00
</div>
</template>
<template v-else>
<div class="group relative flex items-center group-hover:marker text-xs h-full w-full">
<div class="flex gap-2 w-full items-end text-xs">
<span v-if="shouldTruncateText"
class="cursor-pointer grow line-clamp-2"
@click.stop="showDescriptionModal"
v-html="params.data.sa_description">
</span>
<span v-else class="grow" v-html="params.data.sa_description"></span>
<span v-if="shouldTruncateText" @click.stop="showDescriptionModal" class="text-sn-blue cursor-pointer shrink-0 inline-block text-xs">
{{ i18n.t('experiments.card.more') }}
</span>
</div>
</div>
</template>
2023-12-07 03:53:11 +08:00
</template>
<script>
export default {
name: 'DescriptionRenderer',
props: {
params: {
2024-03-01 20:37:31 +08:00
required: true
}
2023-12-07 03:53:11 +08:00
},
computed: {
shouldTruncateText() {
return this.params.data.description?.length > 60;
2024-03-01 20:37:31 +08:00
}
2023-12-07 03:53:11 +08:00
},
methods: {
showDescriptionModal() {
2023-12-11 16:18:22 +08:00
this.params.dtComponent.$emit('showDescription', null, [this.params.data]);
2023-12-07 03:53:11 +08:00
},
},
};
</script>