feat:#17 add share button on calendar link page

This commit is contained in:
survellow
2024-08-14 23:53:07 +02:00
parent 00009f7bfe
commit ebbfb6b48e
4 changed files with 94 additions and 25 deletions

View File

@ -84,7 +84,42 @@ const forwardToHTWKalendar = () => {
}); });
}; };
const actions = computed(() => [ const shareLink = () => {
if (typeof navigator.share === 'function' && navigator.canShare()) {
navigator
.share({
title: t("calendarLink.shareTitle"),
text: t("calendarLink.shareText") + getLink(),
url: "https://" + domain + "/",
})
.then(() => {
toast.add({
severity: "info",
summary: t("calendarLink.shareToastSummary"),
detail: t("calendarLink.shareToastNotification"),
life: 3000,
});
})
.catch(() => {
toast.add({
severity: "error",
summary: t("calendarLink.shareToastError"),
detail: t("calendarLink.shareToastErrorDetail"),
life: 3000,
});
});
} else {
toast.add({
severity: "error",
summary: t("calendarLink.shareToastError"),
detail: t("calendarLink.shareToastErrorDetail"),
life: 3000,
});
}
};
const actions = computed(() => {
var actionList = [
{ {
label: t("calendarLink.copyToClipboard"), label: t("calendarLink.copyToClipboard"),
icon: "pi pi-copy", icon: "pi pi-copy",
@ -104,8 +139,21 @@ const actions = computed(() => [
label: t("calendarLink.toHTWKalendar"), label: t("calendarLink.toHTWKalendar"),
icon: "pi pi-home", icon: "pi pi-home",
command: forwardToHTWKalendar, command: forwardToHTWKalendar,
}, }
]); ];
if (typeof navigator.share === 'function' && navigator.canShare()) {
actionList.push({
label: t("calendarLink.share"),
icon: "pi pi-share-alt",
command: shareLink,
});
}
return actionList;
}
);
</script> </script>
<template> <template>

View File

@ -147,7 +147,14 @@
"copyToClipboard": "Link kopieren", "copyToClipboard": "Link kopieren",
"toGoogleCalendar": "Google Kalender", "toGoogleCalendar": "Google Kalender",
"toMicrosoftCalendar": "Microsoft Kalender", "toMicrosoftCalendar": "Microsoft Kalender",
"toHTWKalendar": "HTWKalender" "toHTWKalendar": "HTWKalender",
"share": "Teilen",
"shareTitle": "HTWKalender",
"shareText": "Ich habe diesen Stundenplan für dich mit dem HTWKalender erstellt. Schau ihn dir hier an: ",
"shareToastSummary": "Information",
"shareToastNotification": "Link zum Stundenplan erfolgreich geteilt",
"shareToastError": "Fehler",
"shareToastErrorDetail": "Link konnte nicht geteilt werden. Möglicherweise wird die Funktion nicht unterstützt."
}, },
"calendarPreview": { "calendarPreview": {
"preview": "Vorschau", "preview": "Vorschau",

View File

@ -152,7 +152,14 @@
"copyToClipboard": "copy to clipboard", "copyToClipboard": "copy to clipboard",
"toGoogleCalendar": "Google Calendar", "toGoogleCalendar": "Google Calendar",
"toMicrosoftCalendar": "Microsoft Calendar", "toMicrosoftCalendar": "Microsoft Calendar",
"toHTWKalendar": "HTWKalender" "toHTWKalendar": "HTWKalender",
"share": "Share",
"shareTitle": "HTWKalender",
"shareText": "Ive created this timetable for you with HTWKalender. Check it out here: ",
"shareToastSummary": "Information",
"shareToastNotification": "Timetable link successfully shared",
"shareToastError": "Error",
"shareToastErrorDetail": "Link could not be shared. The feature might not be supported."
}, },
"calendarPreview": { "calendarPreview": {
"preview": "preview", "preview": "preview",

View File

@ -147,7 +147,14 @@
"copyToClipboard": "クリップボードにコピー", "copyToClipboard": "クリップボードにコピー",
"toGoogleCalendar": "Googleカレンダー", "toGoogleCalendar": "Googleカレンダー",
"toMicrosoftCalendar": "Microsoftカレンダー", "toMicrosoftCalendar": "Microsoftカレンダー",
"toHTWKalendar": "HTWカレンダー" "toHTWKalendar": "HTWカレンダー",
"share": "共有",
"shareTitle": "HTWカレンダー",
"shareText": "HTWカレンダーでこの時間割を作成しました。こちらで確認してください: ",
"shareToastSummary": "情報",
"shareToastNotification": "時間割のリンクが正常に共有されました",
"shareToastError": "エラー",
"shareToastErrorDetail": "リンクを共有できませんでした。機能がサポートされていない可能性があります。"
}, },
"calendarPreview": { "calendarPreview": {
"preview": "プレビュー", "preview": "プレビュー",