Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Print Preferences Menu Missing #2162

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/components/Domain/Recipe/RecipeActionMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
mealplanner: loggedIn,
shoppingList: loggedIn,
print: true,
printPreferences: true,
share: loggedIn,
publicUrl: recipe.settings && loggedIn ? recipe.settings.public : false,
}"
Expand Down
20 changes: 12 additions & 8 deletions frontend/components/Domain/Recipe/RecipeContextMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="text-center">
<!-- Recipe Share Dialog -->
<RecipeDialogShare v-model="shareDialog" :recipe-id="recipeId" :name="name" />
<RecipeDialogPrintPreferences v-model="printPreferencesDialog" :recipe="recipe" />
<RecipeDialogPrintPreferences v-model="printPreferencesDialog" :recipe="recipeRef" />
<BaseDialog
v-model="recipeDeleteDialog"
:title="$t('recipe.delete-recipe')"
Expand Down Expand Up @@ -383,7 +383,7 @@ export default defineComponent({

const shoppingLists = ref<ShoppingListSummary[]>();
const selectedShoppingList = ref<ShoppingListSummary>();
const recipe = ref<Recipe>(props.recipe);
const recipeRef = ref<Recipe>(props.recipe);
const recipeIngredients = ref<{ checked: boolean; ingredient: RecipeIngredient; display: string }[]>([]);

async function getShoppingLists() {
Expand All @@ -396,22 +396,22 @@ export default defineComponent({
async function refreshRecipe() {
const { data } = await api.recipes.getOne(props.slug);
if (data) {
recipe.value = data;
recipeRef.value = data;
}
}

async function openShoppingListIngredientDialog(list: ShoppingListSummary) {
selectedShoppingList.value = list;
if (!recipe.value) {
if (!recipeRef.value) {
await refreshRecipe();
}

if (recipe.value?.recipeIngredient) {
recipeIngredients.value = recipe.value.recipeIngredient.map((ingredient) => {
if (recipeRef.value?.recipeIngredient) {
recipeIngredients.value = recipeRef.value.recipeIngredient.map((ingredient) => {
return {
checked: true,
ingredient,
display: parseIngredientText(ingredient, recipe.value?.settings?.disableAmount || false, props.recipeScale),
display: parseIngredientText(ingredient, recipeRef.value?.settings?.disableAmount || false, props.recipeScale),
};
});
}
Expand Down Expand Up @@ -510,7 +510,10 @@ export default defineComponent({
mealplanner: () => {
state.mealplannerDialog = true;
},
printPreferences: () => {
printPreferences: async () => {
if (!recipeRef.value) {
await refreshRecipe();
}
state.printPreferencesDialog = true;
},
shoppingList: () => {
Expand Down Expand Up @@ -547,6 +550,7 @@ export default defineComponent({

return {
...toRefs(state),
recipeRef,
shoppingLists,
selectedShoppingList,
openShoppingListIngredientDialog,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
<script lang="ts">
import { computed, defineComponent } from "@nuxtjs/composition-api";
import { Recipe } from "~/lib/api/types/recipe";
import { NoUndefinedField } from "~/lib/api/types/non-generated";
import { ImagePosition, useUserPrintPreferences } from "~/composables/use-users/preferences";
import RecipePrintView from "~/components/Domain/Recipe/RecipePrintView.vue";

Expand All @@ -62,8 +61,8 @@ export default defineComponent({
default: false,
},
recipe: {
type: Object as () => NoUndefinedField<Recipe>,
required: true,
type: Object as () => Recipe,
default: undefined,
},
},
setup(props, context) {
Expand Down
2 changes: 0 additions & 2 deletions frontend/components/global/SafeMarkdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ export default defineComponent({
ADD_ATTR: ["src", "alt", "height", "width", "class", "allow", "title", "allowfullscreen", "frameborder", "scrolling"],
});

console.log(sanitized)

return sanitized;
}

Expand Down