activity note added deticated button for copy

This commit is contained in:
Simon Pocrnjič 2025-10-19 10:16:15 +02:00
parent 424151497d
commit 90bbf1942c

View File

@ -7,9 +7,9 @@ import SecondaryButton from "@/Components/SecondaryButton.vue";
import DangerButton from "@/Components/DangerButton.vue";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { library } from "@fortawesome/fontawesome-svg-core";
import { faTrash, faEllipsisVertical } from "@fortawesome/free-solid-svg-icons";
import { faTrash, faEllipsisVertical, faCopy } from "@fortawesome/free-solid-svg-icons";
library.add(faTrash, faEllipsisVertical);
library.add(faTrash, faEllipsisVertical, faCopy);
const props = defineProps({
client_case: Object,
@ -83,6 +83,22 @@ const confirmDeleteAction = () => {
confirmDelete.value = false;
toDeleteRow.value = null;
};
// Copy function
const copyToClipboard = async (text) => {
try {
await navigator.clipboard.writeText(text);
// You could add a toast notification here if available
} catch (err) {
// Fallback for older browsers
const textArea = document.createElement('textarea');
textArea.value = text;
document.body.appendChild(textArea);
textArea.select();
document.execCommand('copy');
document.body.removeChild(textArea);
}
};
</script>
<template>
@ -157,11 +173,23 @@ const confirmDeleteAction = () => {
</button>
</template>
<template #content>
<div
class="max-h-60 overflow-auto text-[12px] whitespace-pre-wrap break-words"
@click.stop
>
{{ row.note }}
<div class="relative" @click.stop>
<div class="flex items-center justify-between p-1 border-b border-gray-200">
<span class="text-xs font-medium text-gray-600">Opomba</span>
<button
@click="copyToClipboard(row.note)"
class="flex items-center gap-1 px-2 py-1 text-xs text-indigo-600 hover:text-indigo-800 hover:bg-indigo-50 rounded transition-colors"
title="Kopiraj v odložišče"
>
<FontAwesomeIcon :icon="faCopy" class="text-xs" />
<span>Kopiraj</span>
</button>
</div>
<div
class="max-h-60 overflow-auto text-[12px] whitespace-pre-wrap break-words p-2"
>
{{ row.note }}
</div>
</div>
</template>
</Dropdown>