| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <v-toolbar | 
					
						
							|  |  |  |     class="fixed-bar mt-0" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     style="z-index: 2; position: sticky; background: transparent; box-shadow: none;" | 
					
						
							|  |  |  |     density="compact" | 
					
						
							|  |  |  |     elevation="0" | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |   > | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <BaseDialog v-model="deleteDialog" :title="$t('recipe.delete-recipe')" color="error"
 | 
					
						
							|  |  |  |       :icon="$globals.icons.alertCircle" can-confirm @confirm="emitDelete()"> | 
					
						
							| 
									
										
										
										
											2021-08-02 22:15:11 -08:00
										 |  |  |       <v-card-text> | 
					
						
							|  |  |  |         {{ $t("recipe.delete-confirmation") }} | 
					
						
							|  |  |  |       </v-card-text> | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |     </BaseDialog> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     <v-spacer /> | 
					
						
							| 
									
										
										
										
											2022-08-27 10:44:58 -08:00
										 |  |  |     <div v-if="!open" class="custom-btn-group ma-1"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |       <RecipeFavoriteBadge v-if="loggedIn" color="info" button-style :recipe-id="recipe.id!" show-always /> | 
					
						
							|  |  |  |       <RecipeTimelineBadge v-if="loggedIn" class="ml-1" color="info" button-style :slug="recipe.slug" :recipe-name="recipe.name!" /> | 
					
						
							| 
									
										
										
										
											2023-02-19 19:28:57 -06:00
										 |  |  |       <div v-if="loggedIn"> | 
					
						
							| 
									
										
										
										
											2024-08-31 21:54:10 -05:00
										 |  |  |         <v-tooltip v-if="canEdit" bottom color="info"> | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |           <template #activator="{ props }"> | 
					
						
							|  |  |  |             <v-btn | 
					
						
							|  |  |  |               icon | 
					
						
							|  |  |  |               variant="flat" | 
					
						
							|  |  |  |               rounded="circle" | 
					
						
							|  |  |  |               size="small" | 
					
						
							|  |  |  |               color="info" | 
					
						
							|  |  |  |               class="ml-1" | 
					
						
							|  |  |  |               v-bind="props" | 
					
						
							|  |  |  |               @click="$emit('edit', true)" | 
					
						
							|  |  |  |             > | 
					
						
							|  |  |  |               <v-icon size="x-large"> | 
					
						
							|  |  |  |                 {{ $globals.icons.edit }} | 
					
						
							|  |  |  |               </v-icon> | 
					
						
							| 
									
										
										
										
											2023-02-19 19:28:57 -06:00
										 |  |  |             </v-btn> | 
					
						
							|  |  |  |           </template> | 
					
						
							|  |  |  |           <span>{{ $t("general.edit") }}</span> | 
					
						
							|  |  |  |         </v-tooltip> | 
					
						
							|  |  |  |       </div> | 
					
						
							| 
									
										
										
										
											2021-12-11 19:12:08 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-08-28 20:08:33 -08:00
										 |  |  |       <RecipeContextMenu | 
					
						
							|  |  |  |         show-print | 
					
						
							|  |  |  |         :menu-top="false" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         :name="recipe.name!" | 
					
						
							|  |  |  |         :slug="recipe.slug!" | 
					
						
							| 
									
										
										
										
											2022-08-28 20:08:33 -08:00
										 |  |  |         :menu-icon="$globals.icons.dotsVertical" | 
					
						
							|  |  |  |         fab | 
					
						
							|  |  |  |         color="info" | 
					
						
							|  |  |  |         :card-menu="false" | 
					
						
							| 
									
										
										
										
											2023-02-19 18:37:18 -06:00
										 |  |  |         :recipe="recipe" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         :recipe-id="recipe.id!" | 
					
						
							| 
									
										
										
										
											2022-12-30 16:47:35 -06:00
										 |  |  |         :recipe-scale="recipeScale" | 
					
						
							| 
									
										
										
										
											2022-08-28 20:08:33 -08:00
										 |  |  |         :use-items="{ | 
					
						
							|  |  |  |           edit: false, | 
					
						
							| 
									
										
										
										
											2023-02-19 19:28:57 -06:00
										 |  |  |           download: loggedIn, | 
					
						
							|  |  |  |           duplicate: loggedIn, | 
					
						
							|  |  |  |           mealplanner: loggedIn, | 
					
						
							|  |  |  |           shoppingList: loggedIn, | 
					
						
							| 
									
										
										
										
											2022-08-28 20:08:33 -08:00
										 |  |  |           print: true, | 
					
						
							| 
									
										
										
										
											2023-02-21 22:00:22 -06:00
										 |  |  |           printPreferences: true, | 
					
						
							| 
									
										
										
										
											2023-02-19 19:28:57 -06:00
										 |  |  |           share: loggedIn, | 
					
						
							| 
									
										
										
										
											2024-05-01 02:20:52 -05:00
										 |  |  |           recipeActions: true, | 
					
						
							| 
									
										
										
										
											2025-01-15 11:49:21 -05:00
										 |  |  |           delete: loggedIn, | 
					
						
							| 
									
										
										
										
											2022-08-28 20:08:33 -08:00
										 |  |  |         }" | 
					
						
							| 
									
										
										
										
											2024-08-31 21:54:10 -05:00
										 |  |  |         class="ml-1" | 
					
						
							| 
									
										
										
										
											2022-08-28 20:08:33 -08:00
										 |  |  |         @print="$emit('print')" | 
					
						
							|  |  |  |       /> | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |     </div> | 
					
						
							| 
									
										
										
										
											2023-01-08 10:50:26 -08:00
										 |  |  |     <div v-if="open" class="custom-btn-group gapped"> | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |       <v-btn | 
					
						
							|  |  |  |         v-for="(btn, index) in editorButtons" | 
					
						
							|  |  |  |         :key="index" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         :class="{ 'rounded-circle': $vuetify.display.xs }" | 
					
						
							|  |  |  |         :size="$vuetify.display.xs ? 'small' : undefined" | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |         :color="btn.color" | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         variant="elevated" | 
					
						
							| 
									
										
										
										
											2025-06-28 15:59:58 +02:00
										 |  |  |         :icon="$vuetify.display.xs" | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |         @click="emitHandler(btn.event)" | 
					
						
							|  |  |  |       > | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |         <v-icon :left="!$vuetify.display.xs"> | 
					
						
							|  |  |  |           {{ btn.icon }} | 
					
						
							|  |  |  |         </v-icon> | 
					
						
							|  |  |  |         {{ $vuetify.display.xs ? "" : btn.text }} | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |       </v-btn> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   </v-toolbar> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  | import RecipeContextMenu from "./RecipeContextMenu.vue"; | 
					
						
							|  |  |  | import RecipeFavoriteBadge from "./RecipeFavoriteBadge.vue"; | 
					
						
							| 
									
										
										
										
											2022-12-11 15:16:55 -06:00
										 |  |  | import RecipeTimelineBadge from "./RecipeTimelineBadge.vue"; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | import type { Recipe } from "~/lib/api/types/recipe"; | 
					
						
							| 
									
										
										
										
											2021-07-09 14:33:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  | const SAVE_EVENT = "save"; | 
					
						
							|  |  |  | const DELETE_EVENT = "delete"; | 
					
						
							|  |  |  | const CLOSE_EVENT = "close"; | 
					
						
							|  |  |  | const JSON_EVENT = "json"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  | export default defineNuxtComponent({ | 
					
						
							| 
									
										
										
										
											2025-01-07 20:19:30 +01:00
										 |  |  |   components: { RecipeContextMenu, RecipeFavoriteBadge, RecipeTimelineBadge }, | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |   props: { | 
					
						
							| 
									
										
										
										
											2022-08-28 20:08:33 -08:00
										 |  |  |     recipe: { | 
					
						
							|  |  |  |       required: true, | 
					
						
							|  |  |  |       type: Object as () => Recipe, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |     slug: { | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |       required: true, | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |       type: String, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2022-12-30 16:47:35 -06:00
										 |  |  |     recipeScale: { | 
					
						
							|  |  |  |       type: Number, | 
					
						
							|  |  |  |       default: 1, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2022-08-27 10:44:58 -08:00
										 |  |  |     open: { | 
					
						
							|  |  |  |       required: true, | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |     name: { | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |       required: true, | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |       type: String, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-06-21 16:25:37 -07:00
										 |  |  |     loggedIn: { | 
					
						
							|  |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: false, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-11-05 21:29:15 -08:00
										 |  |  |     recipeId: { | 
					
						
							|  |  |  |       required: true, | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  |       type: String, | 
					
						
							| 
									
										
										
										
											2021-11-05 21:29:15 -08:00
										 |  |  |     }, | 
					
						
							| 
									
										
										
										
											2024-08-31 21:54:10 -05:00
										 |  |  |     canEdit: { | 
					
						
							| 
									
										
										
										
											2021-12-11 19:12:08 -09:00
										 |  |  |       type: Boolean, | 
					
						
							|  |  |  |       default: false, | 
					
						
							|  |  |  |     }, | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   emits: ["print", "input", "delete", "close", "edit"], | 
					
						
							| 
									
										
										
										
											2024-01-09 08:37:22 -06:00
										 |  |  |   setup(_, context) { | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     const deleteDialog = ref(false); | 
					
						
							| 
									
										
										
										
											2021-06-16 18:55:32 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |     const i18n = useI18n(); | 
					
						
							|  |  |  |     const { $globals } = useNuxtApp(); | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     const editorButtons = [ | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         text: i18n.t("general.delete"), | 
					
						
							|  |  |  |         icon: $globals.icons.delete, | 
					
						
							|  |  |  |         event: DELETE_EVENT, | 
					
						
							|  |  |  |         color: "error", | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         text: i18n.t("general.json"), | 
					
						
							|  |  |  |         icon: $globals.icons.codeBraces, | 
					
						
							|  |  |  |         event: JSON_EVENT, | 
					
						
							|  |  |  |         color: "accent", | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         text: i18n.t("general.close"), | 
					
						
							|  |  |  |         icon: $globals.icons.close, | 
					
						
							|  |  |  |         event: CLOSE_EVENT, | 
					
						
							|  |  |  |         color: "", | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         text: i18n.t("general.save"), | 
					
						
							|  |  |  |         icon: $globals.icons.save, | 
					
						
							|  |  |  |         event: SAVE_EVENT, | 
					
						
							|  |  |  |         color: "success", | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function emitHandler(event: string) { | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |       switch (event) { | 
					
						
							|  |  |  |         case CLOSE_EVENT: | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |           context.emit(CLOSE_EVENT); | 
					
						
							|  |  |  |           context.emit("input", false); | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |           break; | 
					
						
							|  |  |  |         case DELETE_EVENT: | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |           deleteDialog.value = true; | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |           break; | 
					
						
							|  |  |  |         default: | 
					
						
							| 
									
										
										
										
											2022-09-25 15:00:45 -08:00
										 |  |  |           context.emit(event); | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |           break; | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function emitDelete() { | 
					
						
							|  |  |  |       context.emit(DELETE_EVENT); | 
					
						
							|  |  |  |       context.emit("input", false); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       deleteDialog, | 
					
						
							|  |  |  |       editorButtons, | 
					
						
							|  |  |  |       emitHandler, | 
					
						
							|  |  |  |       emitDelete, | 
					
						
							| 
									
										
										
										
											2022-02-13 12:23:42 -09:00
										 |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2022-01-09 07:15:23 +01:00
										 |  |  | }); | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style scoped> | 
					
						
							|  |  |  | .custom-btn-group { | 
					
						
							|  |  |  |   flex: 0, 1, auto; | 
					
						
							|  |  |  |   display: inline-flex; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-08 10:50:26 -08:00
										 |  |  | .gapped { | 
					
						
							|  |  |  |   gap: 0.25rem; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  | .vertical { | 
					
						
							|  |  |  |   flex-direction: column !important; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .sticky { | 
					
						
							|  |  |  |   margin-left: auto; | 
					
						
							|  |  |  |   position: fixed !important; | 
					
						
							|  |  |  |   margin-top: 4.25rem; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .fixed-bar { | 
					
						
							|  |  |  |   position: sticky; | 
					
						
							|  |  |  |   top: 4.5em; | 
					
						
							|  |  |  |   z-index: 2; | 
					
						
							| 
									
										
										
										
											2025-06-20 00:09:12 +07:00
										 |  |  |   background: transparent !important; | 
					
						
							|  |  |  |   box-shadow: none !important; | 
					
						
							|  |  |  |   min-height: 0 !important; | 
					
						
							|  |  |  |   height: 48px; | 
					
						
							|  |  |  |   padding: 0 8px; | 
					
						
							| 
									
										
										
										
											2021-06-10 18:32:03 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | .fixed-bar-mobile { | 
					
						
							|  |  |  |   top: 1.5em !important; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  | </style> |