copy link into clipboard and open mail client
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
All checks were successful
InnoHub Processor/tatort/pipeline/head This commit looks good
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { fade } from 'svelte/transition';
|
||||||
import shortenFileSize from '$lib/helper/shortenFileSize';
|
import shortenFileSize from '$lib/helper/shortenFileSize';
|
||||||
import timeElapsed from '$lib/helper/timeElapsed';
|
import timeElapsed from '$lib/helper/timeElapsed';
|
||||||
import { deserialize } from '$app/forms';
|
import { deserialize } from '$app/forms';
|
||||||
@@ -46,6 +47,9 @@
|
|||||||
let openUL = $state(false);
|
let openUL = $state(false);
|
||||||
let inProgressUL = $state(form === null);
|
let inProgressUL = $state(form === null);
|
||||||
|
|
||||||
|
// Variablen für Copy-Funktion
|
||||||
|
let copied = $state(false);
|
||||||
|
|
||||||
async function buttonClick(event: MouseEvent) {
|
async function buttonClick(event: MouseEvent) {
|
||||||
if (!(await validateForm())) {
|
if (!(await validateForm())) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -248,9 +252,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function constructMailToLink() {
|
async function copyAndOpenMail() {
|
||||||
const subject = 'Link zum Tatvorgang';
|
const subject = 'Link zum Tatvorgang';
|
||||||
|
|
||||||
const link = data.url.origin + data.url.pathname;
|
const link = data.url.origin + data.url.pathname;
|
||||||
const body = `Hallo,
|
const body = `Hallo,
|
||||||
|
|
||||||
@@ -262,9 +265,22 @@ Der Zugangs-PIN wird zur Sicherheit über einen zweiten Kommunikationskanal übe
|
|||||||
Mit freundlichen Grüßen,
|
Mit freundlichen Grüßen,
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const mailtoLink = `mailto:?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
|
try {
|
||||||
|
await navigator.clipboard.writeText(body);
|
||||||
|
|
||||||
return mailtoLink;
|
copied = true;
|
||||||
|
|
||||||
|
// Kurz warten, dann Mail öffnen
|
||||||
|
setTimeout(() => {
|
||||||
|
const mailtoLink = `mailto:?subject=${encodeURIComponent(subject)}`;
|
||||||
|
window.location.href = mailtoLink;
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
setTimeout(() => copied = false, 2000);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Clipboard-Fehler:', err);
|
||||||
|
error = 'Konnte Text nicht kopieren. Bitte manuell markieren und kopieren.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeModal() {
|
function closeModal() {
|
||||||
@@ -288,9 +304,10 @@ Mit freundlichen Grüßen,
|
|||||||
onDelete={null}
|
onDelete={null}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<a class="pt-2 pb-6" href={constructMailToLink()}
|
<Button on:click={copyAndOpenMail} disabled={isEmptyList}>Link kopieren und Mail verfassen</Button>
|
||||||
><Button disabled={isEmptyList}>Share Link</Button></a
|
{#if copied}
|
||||||
>
|
<p transition:fade>✔ Kopiert! Per Ctrl+V einfügen.</p>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="mx-auto flex justify-center max-w-7xl h-full">
|
<div class="mx-auto flex justify-center max-w-7xl h-full">
|
||||||
|
|||||||
Reference in New Issue
Block a user