From b99228688997d93a41c508e883b288637a7f8579 Mon Sep 17 00:00:00 2001 From: hay-kot Date: Sat, 1 May 2021 16:45:00 -0800 Subject: [PATCH] initial context menu --- .../src/components/Recipe/ContextMenu.vue | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/frontend/src/components/Recipe/ContextMenu.vue b/frontend/src/components/Recipe/ContextMenu.vue index 4219fc017..005589a32 100644 --- a/frontend/src/components/Recipe/ContextMenu.vue +++ b/frontend/src/components/Recipe/ContextMenu.vue @@ -42,6 +42,12 @@ export default { loggedIn() { return this.$store.getters.getIsLoggedIn; }, + baseURL() { + return window.location.origin; + }, + recipeURL() { + return `${this.baseURL}/recipe/${this.slug}`; + }, }, data() { return { @@ -52,6 +58,24 @@ export default { color: "error", action: "delete", }, + { + title: "Edit", + icon: "mdi-square-edit-outline", + color: "accent", + action: "edit", + }, + { + title: "Download", + icon: "mdi-download", + color: "accent", + action: "download", + }, + { + title: "Link", + icon: "mdi-content-copy", + color: "accent", + action: "share", + }, ], loading: false, }; @@ -64,12 +88,32 @@ export default { case "delete": await api.recipes.delete(this.slug); break; + case "share": + this.updateClipboard(); + break; + case "edit": + this.$router.push(`/recipe/${this.slug}` + "?edit=true"); + break; + case "download": + console.log("Download"); + break; default: break; } this.loading = false; }, + updateClipboard() { + const copyText = this.recipeURL; + navigator.clipboard.writeText(copyText).then( + function() { + console.log("Copied", copyText); + }, + function() { + console.log("Copy Failed", copyText); + } + ); + }, }, }; \ No newline at end of file