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,28 +84,76 @@ const forwardToHTWKalendar = () => {
}); });
}; };
const actions = computed(() => [ const shareLink = () => {
{ if (typeof navigator.share === 'function' && navigator.canShare()) {
label: t("calendarLink.copyToClipboard"), navigator
icon: "pi pi-copy", .share({
command: copyToClipboard, title: t("calendarLink.shareTitle"),
}, text: t("calendarLink.shareText") + getLink(),
{ url: "https://" + domain + "/",
label: t("calendarLink.toGoogleCalendar"), })
icon: "pi pi-google", .then(() => {
command: forwardToGoogle, toast.add({
}, severity: "info",
{ summary: t("calendarLink.shareToastSummary"),
label: t("calendarLink.toMicrosoftCalendar"), detail: t("calendarLink.shareToastNotification"),
icon: "pi pi-microsoft", life: 3000,
command: forwardToMicrosoft, });
}, })
{ .catch(() => {
label: t("calendarLink.toHTWKalendar"), toast.add({
icon: "pi pi-home", severity: "error",
command: forwardToHTWKalendar, 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"),
icon: "pi pi-copy",
command: copyToClipboard,
},
{
label: t("calendarLink.toGoogleCalendar"),
icon: "pi pi-google",
command: forwardToGoogle,
},
{
label: t("calendarLink.toMicrosoftCalendar"),
icon: "pi pi-microsoft",
command: forwardToMicrosoft,
},
{
label: t("calendarLink.toHTWKalendar"),
icon: "pi pi-home",
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": "プレビュー",