From 37969612930eeeddc7a741cb34d9739ddca91215 Mon Sep 17 00:00:00 2001 From: James Collins Date: Tue, 16 May 2023 11:19:34 +1000 Subject: [PATCH] added copy shortlink option to dropdown --- .../js/views/dashboard/ShortlinkList.vue | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/resources/js/views/dashboard/ShortlinkList.vue b/resources/js/views/dashboard/ShortlinkList.vue index cf1941c..ef3651b 100644 --- a/resources/js/views/dashboard/ShortlinkList.vue +++ b/resources/js/views/dashboard/ShortlinkList.vue @@ -41,6 +41,7 @@ { const handleActionButton = (item: Shortlink, option: string): void => { if (option.length == 0) { handleEdit(item); + } else if (option.toLowerCase() == "copy") { + handleCopy(item); } else if (option.toLowerCase() == "delete") { handleDelete(item); } @@ -163,6 +166,25 @@ const handleEdit = (shortlink: Shortlink) => { }); }; +const handleCopy = (shortlink: Shortlink) => { + navigator.clipboard + .writeText(`https://stemmech.com.au/${shortlink.code}`) + .then(() => { + useToastStore().addToast({ + title: "Copied to Clipboard", + content: "The shortlink URL has been copied to the clipboard.", + type: "success", + }); + }) + .catch(() => { + useToastStore().addToast({ + title: "Copy to Clipboard", + content: "Failed to copy the shortlink URL to the clipboard.", + type: "danger", + }); + }); +}; + const handleDelete = async (shortlink: Shortlink) => { let result = await openDialog(DialogConfirm, { title: "Delete User?",