+
{{ $t("recipe.ingredients") }}
+
+
+
+
+
+
+
+ {{ showTitleEditor[index] ? $globals.icons.minus : $globals.icons.createAlt }}
+
+
+ {{
+ showTitleEditor[index] ? $t("recipe.remove-section") : $t("recipe.insert-section")
+ }}
+
+
{{ $globals.icons.arrowUpDown }}
@@ -35,18 +56,16 @@
-
-
-
-
-
-
-
+
+
{{ ingredient.title }}
+
+
+
+
+
+
+
+
@@ -76,10 +95,19 @@ export default {
return {
drag: false,
checked: [],
+ showTitleEditor: [],
};
},
mounted() {
this.checked = this.value.map(() => false);
+ this.showTitleEditor = this.value.map(x => this.validateTitle(x.title));
+ },
+ watch: {
+ value: {
+ handler() {
+ this.showTitleEditor = this.value.map(x => this.validateTitle(x.title));
+ },
+ },
},
methods: {
addIngredient(ingredients = null) {
@@ -118,6 +146,16 @@ export default {
removeByIndex(list, index) {
list.splice(index, 1);
},
+ validateTitle(title) {
+ return !(title === null || title === "");
+ },
+ toggleShowTitle(index) {
+ const newVal = !this.showTitleEditor[index];
+ if (!newVal) {
+ this.value[index].title = "";
+ }
+ this.$set(this.showTitleEditor, index, newVal);
+ },
},
};
diff --git a/frontend/src/components/Recipe/RecipePageActionMenu.vue b/frontend/src/components/Recipe/RecipePageActionMenu.vue
index df91e67c..5a1adae7 100644
--- a/frontend/src/components/Recipe/RecipePageActionMenu.vue
+++ b/frontend/src/components/Recipe/RecipePageActionMenu.vue
@@ -18,6 +18,7 @@
/>
+
import ConfirmationDialog from "@/components/UI/Dialogs/ConfirmationDialog.vue";
import ContextMenu from "@/components/Recipe/ContextMenu.vue";
+import FavoriteBadge from "@/components/Recipe/FavoriteBadge.vue";
+
const SAVE_EVENT = "save";
const DELETE_EVENT = "delete";
const CLOSE_EVENT = "close";
const JSON_EVENT = "json";
export default {
- components: { ConfirmationDialog, ContextMenu },
+ components: { ConfirmationDialog, ContextMenu, FavoriteBadge },
props: {
slug: {
type: String,
diff --git a/frontend/src/pages/Recipe/ViewRecipe.vue b/frontend/src/pages/Recipe/ViewRecipe.vue
index 61cb699b..3cc35325 100644
--- a/frontend/src/pages/Recipe/ViewRecipe.vue
+++ b/frontend/src/pages/Recipe/ViewRecipe.vue
@@ -12,7 +12,6 @@
class="d-print-none"
:key="imageKey"
>
-
import RecipePageActionMenu from "@/components/Recipe/RecipePageActionMenu.vue";
import { api } from "@/api";
-import FavoriteBadge from "@/components/Recipe/FavoriteBadge";
import RecipeViewer from "@/components/Recipe/RecipeViewer";
import PrintView from "@/components/Recipe/PrintView";
import RecipeEditor from "@/components/Recipe/RecipeEditor";
@@ -88,7 +86,6 @@ export default {
RecipePageActionMenu,
PrintView,
NoRecipe,
- FavoriteBadge,
CommentsSection,
},
mixins: [user],
@@ -233,7 +230,7 @@ export default {
async saveRecipe() {
if (this.validateRecipe()) {
let slug = await api.recipes.update(this.recipeDetails);
- if(!slug) return;
+ if (!slug) return;
if (this.fileObject) {
this.saveImage(true);