mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2026-01-17 04:32:24 +01:00
feat:#17 add share button on calendar link page
This commit is contained in:
@@ -84,28 +84,76 @@ const forwardToHTWKalendar = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const actions = computed(() => [
|
||||
{
|
||||
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,
|
||||
},
|
||||
]);
|
||||
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"),
|
||||
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>
|
||||
|
||||
<template>
|
||||
|
||||
Reference in New Issue
Block a user