Skip to content

Commit d190120

Browse files
committed
feat(tooltip): Add copy-to-clipboard and interactive tooltip to object tree's items
1 parent c528593 commit d190120

1 file changed

Lines changed: 39 additions & 7 deletions

File tree

app/components/Viewer/ObjectTree/Base/ItemLabel.vue

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<script setup>
22
import { middleTruncate } from "@ogw_front/utils/string";
3+
import { useFeedbackStore } from "@ogw_front/stores/feedback";
4+
5+
const feedbackStore = useFeedbackStore();
36
47
const { item, isLeaf } = defineProps({
58
item: { type: Object, required: true },
@@ -47,11 +50,22 @@ const tooltipDisabled = computed(() => {
4750
}
4851
return actualItem.value.children && actualItem.value.children.length > 0;
4952
});
53+
54+
async function copyToClipboard(text, label) {
55+
await navigator.clipboard.writeText(text);
56+
feedbackStore.add_success(`${label} copied to clipboard`);
57+
}
5058
</script>
5159

5260
<template>
5361
<div ref="label-container" class="tree-item-label-container w-100">
54-
<v-tooltip :disabled="tooltipDisabled" location="right" open-delay="400">
62+
<v-tooltip
63+
:disabled="tooltipDisabled"
64+
location="right"
65+
open-delay="400"
66+
close-delay="100"
67+
interactive
68+
>
5569
<template #activator="{ props: tooltipProps }">
5670
<span
5771
v-bind="tooltipProps"
@@ -66,14 +80,32 @@ const tooltipDisabled = computed(() => {
6680
</template>
6781

6882
<div class="d-flex flex-column ga-1">
69-
<span class="text-caption">
70-
<strong class="text-white">ID:</strong> {{ actualItem.id }}
83+
<span class="text-caption d-flex align-center">
84+
<strong class="text-white mr-1">ID:</strong>
85+
<span>{{ actualItem.id }}</span>
86+
<v-btn
87+
icon="mdi-content-copy"
88+
variant="text"
89+
size="x-small"
90+
density="compact"
91+
class="ml-1 text-white"
92+
@click.stop="copyToClipboard(actualItem.id, 'ID')"
93+
/>
7194
</span>
72-
<span v-if="actualItem.title" class="text-caption">
73-
<strong class="text-white">Name:</strong> {{ actualItem.title }}
95+
<span v-if="actualItem.title" class="text-caption d-flex align-center">
96+
<strong class="text-white mr-1">Name:</strong>
97+
<span>{{ actualItem.title }}</span>
98+
<v-btn
99+
icon="mdi-content-copy"
100+
variant="text"
101+
size="x-small"
102+
density="compact"
103+
class="ml-1 text-white"
104+
@click.stop="copyToClipboard(actualItem.title, 'Name')"
105+
/>
74106
</span>
75-
<span class="text-caption">
76-
<strong class="text-white">Status:</strong>
107+
<span class="text-caption d-flex align-center">
108+
<strong class="text-white mr-1">Status:</strong>
77109
<i class="ml-1">{{ actualItem.is_active ? "Active" : "Inactive" }}</i>
78110
</span>
79111
</div>

0 commit comments

Comments
 (0)