From 3804e1d52c2c73fe1a161dd9cb824d8d98ae4a81 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Fri, 14 May 2021 21:10:03 -0800 Subject: [PATCH] add print-view component (#407) Co-authored-by: hay-kot --- frontend/src/App.vue | 5 +- .../src/components/Recipe/ContextMenu.vue | 29 +--- frontend/src/components/Recipe/PrintView.vue | 155 +++++++++++++++++ .../src/components/Recipe/RecipePrint.vue | 162 ------------------ frontend/src/components/UI/TheRecipeFab.vue | 2 +- frontend/src/components/UI/TheSidebar.vue | 8 +- frontend/src/locales/messages/en-US.json | 1 + frontend/src/pages/Recipe/ViewRecipe.vue | 19 +- 8 files changed, 189 insertions(+), 192 deletions(-) create mode 100644 frontend/src/components/Recipe/PrintView.vue delete mode 100644 frontend/src/components/Recipe/RecipePrint.vue diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 83c7c2776258..d87abafaf490 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -4,7 +4,9 @@ -
This is a Demo of the v0.5.0 (BETA) | Username: changeme@email.com | Password: demo
+
+ This is a Demo of the v0.5.0 (BETA) | Username: changeme@email.com | Password: demo +
@@ -76,4 +78,5 @@ export default { :root { scrollbar-color: transparent transparent; } + diff --git a/frontend/src/components/Recipe/ContextMenu.vue b/frontend/src/components/Recipe/ContextMenu.vue index ca7a40c80847..c78b06847ec4 100644 --- a/frontend/src/components/Recipe/ContextMenu.vue +++ b/frontend/src/components/Recipe/ContextMenu.vue @@ -58,10 +58,10 @@ export default { defaultMenu() { return [ { - title: this.$t("general.download"), - icon: "mdi-download", + title: this.$t("general.print"), + icon: "mdi-printer", color: "accent", - action: "download", + action: "print", }, { title: this.$t("general.link"), @@ -108,8 +108,8 @@ export default { case "edit": this.$router.push(`/recipe/${this.slug}` + "?edit=true"); break; - case "download": - await this.downloadJson(); + case "print": + this.$router.push(`/recipe/${this.slug}` + "?print=true"); break; default: break; @@ -127,25 +127,6 @@ export default { () => console.log("Copied Failed", copyText) ); }, - async downloadJson() { - const recipe = await api.recipes.requestDetails(this.slug); - this.downloadString(JSON.stringify(recipe, "", 4), "text/json", recipe.slug + ".json"); - }, - downloadString(text, fileType, fileName) { - let blob = new Blob([text], { type: fileType }); - - let a = document.createElement("a"); - a.download = fileName; - a.href = URL.createObjectURL(blob); - a.dataset.downloadurl = [fileType, a.download, a.href].join(":"); - a.style.display = "none"; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - setTimeout(function() { - URL.revokeObjectURL(a.href); - }, 1500); - }, }, }; diff --git a/frontend/src/components/Recipe/PrintView.vue b/frontend/src/components/Recipe/PrintView.vue new file mode 100644 index 000000000000..69b3055091a4 --- /dev/null +++ b/frontend/src/components/Recipe/PrintView.vue @@ -0,0 +1,155 @@ + + + + + \ No newline at end of file diff --git a/frontend/src/components/Recipe/RecipePrint.vue b/frontend/src/components/Recipe/RecipePrint.vue deleted file mode 100644 index 0744ea533785..000000000000 --- a/frontend/src/components/Recipe/RecipePrint.vue +++ /dev/null @@ -1,162 +0,0 @@ - - - - - diff --git a/frontend/src/components/UI/TheRecipeFab.vue b/frontend/src/components/UI/TheRecipeFab.vue index 6bb8e267bc97..e810e13257b4 100644 --- a/frontend/src/components/UI/TheRecipeFab.vue +++ b/frontend/src/components/UI/TheRecipeFab.vue @@ -1,5 +1,5 @@