From 6785033a21de34fbef297d7236e464b3ce9e8096 Mon Sep 17 00:00:00 2001 From: srwareham Date: Sun, 9 Jul 2023 17:16:04 -0700 Subject: [PATCH] Add step-level configuration whether an ingredients table should be shown. User-level default added to settings --- cookbook/forms.py | 7 +++-- cookbook/helper/recipe_url_import.py | 2 +- cookbook/integration/cheftap.py | 2 +- cookbook/integration/chowdown.py | 2 +- cookbook/integration/cookbookapp.py | 2 +- cookbook/integration/cookmate.py | 2 +- cookbook/integration/copymethat.py | 2 +- cookbook/integration/domestica.py | 2 +- cookbook/integration/mealie.py | 2 +- cookbook/integration/mealmaster.py | 2 +- cookbook/integration/melarecipes.py | 2 +- cookbook/integration/nextcloud_cookbook.py | 4 +-- cookbook/integration/openeats.py | 2 +- cookbook/integration/paprika.py | 2 +- cookbook/integration/pepperplate.py | 2 +- cookbook/integration/plantoeat.py | 2 +- cookbook/integration/recettetek.py | 2 +- cookbook/integration/recipekeeper.py | 2 +- cookbook/integration/recipesage.py | 2 +- cookbook/integration/rezeptsuitede.py | 2 +- cookbook/integration/rezkonv.py | 2 +- cookbook/integration/saffron.py | 2 +- cookbook/models.py | 2 ++ cookbook/serializer.py | 7 ++--- cookbook/tests/factories/__init__.py | 2 ++ cookbook/views/new.py | 2 +- .../apps/ImportView/ImportViewStepEditor.vue | 5 +++- .../apps/RecipeEditView/RecipeEditView.vue | 26 ++++++++++++++++--- .../Settings/CosmeticSettingsComponent.vue | 6 +++++ vue/src/components/StepComponent.vue | 7 ++--- vue/src/locales/en.json | 5 ++++ vue/src/utils/openapi/api.ts | 12 +++++++++ 32 files changed, 87 insertions(+), 38 deletions(-) diff --git a/cookbook/forms.py b/cookbook/forms.py index 3d5160a4..12bbce44 100644 --- a/cookbook/forms.py +++ b/cookbook/forms.py @@ -46,6 +46,7 @@ class UserPreferenceForm(forms.ModelForm): fields = ( 'default_unit', 'use_fractions', 'use_kj', 'theme', 'nav_color', 'sticky_navbar', 'default_page', 'plan_share', 'ingredient_decimals', 'comments', 'left_handed', + 'show_step_ingredients', ) labels = { @@ -60,7 +61,8 @@ class UserPreferenceForm(forms.ModelForm): 'ingredient_decimals': _('Ingredient decimal places'), 'shopping_auto_sync': _('Shopping list auto sync period'), 'comments': _('Comments'), - 'left_handed': _('Left-handed mode') + 'left_handed': _('Left-handed mode'), + 'show_step_ingredients': _('Show step ingredients table') } help_texts = { @@ -82,7 +84,8 @@ class UserPreferenceForm(forms.ModelForm): 'sticky_navbar': _('Makes the navbar stick to the top of the page.'), 'mealplan_autoadd_shopping': _('Automatically add meal plan ingredients to shopping list.'), 'mealplan_autoexclude_onhand': _('Exclude ingredients that are on hand.'), - 'left_handed': _('Will optimize the UI for use with your left hand.') + 'left_handed': _('Will optimize the UI for use with your left hand.'), + 'show_step_ingredients': _('Add ingredients table next to recipe steps. Applies at creation time for manually created and URL imported recipes. Individual steps can be overridden in the edit recipe view.') } widgets = { diff --git a/cookbook/helper/recipe_url_import.py b/cookbook/helper/recipe_url_import.py index a15df5e8..f3e624d4 100644 --- a/cookbook/helper/recipe_url_import.py +++ b/cookbook/helper/recipe_url_import.py @@ -147,7 +147,7 @@ def get_from_scraper(scrape, request): recipe_json['steps'] = [] try: for i in parse_instructions(scrape.instructions()): - recipe_json['steps'].append({'instruction': i, 'ingredients': [], }) + recipe_json['steps'].append({'instruction': i, 'ingredients': [], 'show_ingredients_table': request.user.userpreference.show_step_ingredients,}) except Exception: pass if len(recipe_json['steps']) == 0: diff --git a/cookbook/integration/cheftap.py b/cookbook/integration/cheftap.py index cf462d9a..2979f013 100644 --- a/cookbook/integration/cheftap.py +++ b/cookbook/integration/cheftap.py @@ -36,7 +36,7 @@ class ChefTap(Integration): recipe = Recipe.objects.create(name=title, created_by=self.request.user, internal=True, space=self.request.space, ) - step = Step.objects.create(instruction='\n'.join(directions), space=self.request.space,) + step = Step.objects.create(instruction='\n'.join(directions), space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients,) if source_url != '': step.instruction += '\n' + source_url diff --git a/cookbook/integration/chowdown.py b/cookbook/integration/chowdown.py index 2f635436..3d41cf48 100644 --- a/cookbook/integration/chowdown.py +++ b/cookbook/integration/chowdown.py @@ -55,7 +55,7 @@ class Chowdown(Integration): recipe.keywords.add(keyword) step = Step.objects.create( - instruction='\n'.join(directions) + '\n\n' + '\n'.join(descriptions), space=self.request.space, + instruction='\n'.join(directions) + '\n\n' + '\n'.join(descriptions), space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) ingredient_parser = IngredientParser(self.request, True) diff --git a/cookbook/integration/cookbookapp.py b/cookbook/integration/cookbookapp.py index c35de64f..99cccea4 100644 --- a/cookbook/integration/cookbookapp.py +++ b/cookbook/integration/cookbookapp.py @@ -47,7 +47,7 @@ class CookBookApp(Integration): pass # assuming import files only contain single step - step = Step.objects.create(instruction=recipe_json['steps'][0]['instruction'], space=self.request.space, ) + step = Step.objects.create(instruction=recipe_json['steps'][0]['instruction'], space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) if 'nutrition' in recipe_json: step.instruction = step.instruction + '\n\n' + recipe_json['nutrition'] diff --git a/cookbook/integration/cookmate.py b/cookbook/integration/cookmate.py index 940952ce..58fd0824 100644 --- a/cookbook/integration/cookmate.py +++ b/cookbook/integration/cookmate.py @@ -50,7 +50,7 @@ class Cookmate(Integration): for step in recipe_text.getchildren(): if step.text: step = Step.objects.create( - instruction=step.text.strip(), space=self.request.space, + instruction=step.text.strip(), space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) recipe.steps.add(step) diff --git a/cookbook/integration/copymethat.py b/cookbook/integration/copymethat.py index 421c967d..21ea6652 100644 --- a/cookbook/integration/copymethat.py +++ b/cookbook/integration/copymethat.py @@ -51,7 +51,7 @@ class CopyMeThat(Integration): except AttributeError: pass - step = Step.objects.create(instruction='', space=self.request.space, ) + step = Step.objects.create(instruction='', space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) ingredient_parser = IngredientParser(self.request, True) diff --git a/cookbook/integration/domestica.py b/cookbook/integration/domestica.py index d1cc3bc1..dd0b3649 100644 --- a/cookbook/integration/domestica.py +++ b/cookbook/integration/domestica.py @@ -28,7 +28,7 @@ class Domestica(Integration): recipe.save() step = Step.objects.create( - instruction=file['directions'], space=self.request.space, + instruction=file['directions'], space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) if file['source'] != '': diff --git a/cookbook/integration/mealie.py b/cookbook/integration/mealie.py index ccd16ce9..5e4e1578 100644 --- a/cookbook/integration/mealie.py +++ b/cookbook/integration/mealie.py @@ -25,7 +25,7 @@ class Mealie(Integration): created_by=self.request.user, internal=True, space=self.request.space) for s in recipe_json['recipe_instructions']: - step = Step.objects.create(instruction=s['text'], space=self.request.space, ) + step = Step.objects.create(instruction=s['text'], space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) recipe.steps.add(step) step = recipe.steps.first() diff --git a/cookbook/integration/mealmaster.py b/cookbook/integration/mealmaster.py index dcd70efa..9dce4fdd 100644 --- a/cookbook/integration/mealmaster.py +++ b/cookbook/integration/mealmaster.py @@ -39,7 +39,7 @@ class MealMaster(Integration): recipe.keywords.add(keyword) step = Step.objects.create( - instruction='\n'.join(directions) + '\n\n', space=self.request.space, + instruction='\n'.join(directions) + '\n\n', space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) ingredient_parser = IngredientParser(self.request, True) diff --git a/cookbook/integration/melarecipes.py b/cookbook/integration/melarecipes.py index 88ff4d35..9679a90f 100644 --- a/cookbook/integration/melarecipes.py +++ b/cookbook/integration/melarecipes.py @@ -67,7 +67,7 @@ class MelaRecipes(Integration): f = ingredient_parser.get_food(food) u = ingredient_parser.get_unit(unit) step.ingredients.add(Ingredient.objects.create( - food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space, + food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, )) recipe.steps.add(step) diff --git a/cookbook/integration/nextcloud_cookbook.py b/cookbook/integration/nextcloud_cookbook.py index f2db21cc..f43501f8 100644 --- a/cookbook/integration/nextcloud_cookbook.py +++ b/cookbook/integration/nextcloud_cookbook.py @@ -54,11 +54,11 @@ class NextcloudCookbook(Integration): instruction_text = '' if 'text' in s: step = Step.objects.create( - instruction=s['text'], name=s['name'], space=self.request.space, + instruction=s['text'], name=s['name'], space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) else: step = Step.objects.create( - instruction=s, space=self.request.space, + instruction=s, space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) if not ingredients_added: if len(recipe_json['description'].strip()) > 500: diff --git a/cookbook/integration/openeats.py b/cookbook/integration/openeats.py index 9188ca8d..406c9978 100644 --- a/cookbook/integration/openeats.py +++ b/cookbook/integration/openeats.py @@ -51,7 +51,7 @@ class OpenEats(Integration): recipe.image = f'recipes/openeats-import/{file["photo"]}' recipe.save() - step = Step.objects.create(instruction=instructions, space=self.request.space,) + step = Step.objects.create(instruction=instructions, space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients,) ingredient_parser = IngredientParser(self.request, True) for ingredient in file['ingredients']: diff --git a/cookbook/integration/paprika.py b/cookbook/integration/paprika.py index 3d78b9eb..9904f330 100644 --- a/cookbook/integration/paprika.py +++ b/cookbook/integration/paprika.py @@ -58,7 +58,7 @@ class Paprika(Integration): pass step = Step.objects.create( - instruction=instructions, space=self.request.space, + instruction=instructions, space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) if 'description' in recipe_json and len(recipe_json['description'].strip()) > 500: diff --git a/cookbook/integration/pepperplate.py b/cookbook/integration/pepperplate.py index 7cfafa84..570d702c 100644 --- a/cookbook/integration/pepperplate.py +++ b/cookbook/integration/pepperplate.py @@ -35,7 +35,7 @@ class Pepperplate(Integration): recipe = Recipe.objects.create(name=title, description=description, created_by=self.request.user, internal=True, space=self.request.space) step = Step.objects.create( - instruction='\n'.join(directions) + '\n\n', space=self.request.space, + instruction='\n'.join(directions) + '\n\n', space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) ingredient_parser = IngredientParser(self.request, True) diff --git a/cookbook/integration/plantoeat.py b/cookbook/integration/plantoeat.py index 2affd377..c4cc0f13 100644 --- a/cookbook/integration/plantoeat.py +++ b/cookbook/integration/plantoeat.py @@ -46,7 +46,7 @@ class Plantoeat(Integration): recipe = Recipe.objects.create(name=title, description=description, created_by=self.request.user, internal=True, space=self.request.space) step = Step.objects.create( - instruction='\n'.join(directions) + '\n\n', space=self.request.space, + instruction='\n'.join(directions) + '\n\n', space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) if tags: diff --git a/cookbook/integration/recettetek.py b/cookbook/integration/recettetek.py index d92fa18c..87e145ff 100644 --- a/cookbook/integration/recettetek.py +++ b/cookbook/integration/recettetek.py @@ -46,7 +46,7 @@ class RecetteTek(Integration): if not instructions: instructions = '' - step = Step.objects.create(instruction=instructions, space=self.request.space,) + step = Step.objects.create(instruction=instructions, space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients,) # Append the original import url to the step (if it exists) try: diff --git a/cookbook/integration/recipekeeper.py b/cookbook/integration/recipekeeper.py index cd783bfa..e4f1ee8e 100644 --- a/cookbook/integration/recipekeeper.py +++ b/cookbook/integration/recipekeeper.py @@ -41,7 +41,7 @@ class RecipeKeeper(Integration): except AttributeError: pass - step = Step.objects.create(instruction='', space=self.request.space, ) + step = Step.objects.create(instruction='', space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) ingredient_parser = IngredientParser(self.request, True) for ingredient in file.find("div", {"itemprop": "recipeIngredients"}).findChildren("p"): diff --git a/cookbook/integration/recipesage.py b/cookbook/integration/recipesage.py index 593ce059..70b8838c 100644 --- a/cookbook/integration/recipesage.py +++ b/cookbook/integration/recipesage.py @@ -49,7 +49,7 @@ class RecipeSage(Integration): f = ingredient_parser.get_food(food) u = ingredient_parser.get_unit(unit) step.ingredients.add(Ingredient.objects.create( - food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space, + food=f, unit=u, amount=amount, note=note, original_text=ingredient, space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, )) recipe.steps.add(step) diff --git a/cookbook/integration/rezeptsuitede.py b/cookbook/integration/rezeptsuitede.py index 7f2f3962..a3334d84 100644 --- a/cookbook/integration/rezeptsuitede.py +++ b/cookbook/integration/rezeptsuitede.py @@ -37,7 +37,7 @@ class Rezeptsuitede(Integration): try: if prep.find('step').text: step = Step.objects.create( - instruction=prep.find('step').text.strip(), space=self.request.space, + instruction=prep.find('step').text.strip(), space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) recipe.steps.add(step) except Exception: diff --git a/cookbook/integration/rezkonv.py b/cookbook/integration/rezkonv.py index c0bfcc8e..4f5f7fc9 100644 --- a/cookbook/integration/rezkonv.py +++ b/cookbook/integration/rezkonv.py @@ -38,7 +38,7 @@ class RezKonv(Integration): recipe.keywords.add(keyword) step = Step.objects.create( - instruction=' \n'.join(directions) + '\n\n', space=self.request.space, + instruction=' \n'.join(directions) + '\n\n', space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) ingredient_parser = IngredientParser(self.request, True) diff --git a/cookbook/integration/saffron.py b/cookbook/integration/saffron.py index a7ec34f1..4c75d1a0 100644 --- a/cookbook/integration/saffron.py +++ b/cookbook/integration/saffron.py @@ -43,7 +43,7 @@ class Saffron(Integration): recipe = Recipe.objects.create(name=title, description=description, created_by=self.request.user, internal=True, space=self.request.space, ) - step = Step.objects.create(instruction='\n'.join(directions), space=self.request.space, ) + step = Step.objects.create(instruction='\n'.join(directions), space=self.request.space, show_ingredients_table=self.request.user.userpreference.show_step_ingredients, ) ingredient_parser = IngredientParser(self.request, True) for ingredient in ingredients: diff --git a/cookbook/models.py b/cookbook/models.py index 5a931024..f05cf3bf 100644 --- a/cookbook/models.py +++ b/cookbook/models.py @@ -394,6 +394,7 @@ class UserPreference(models.Model, PermissionModelMixin): shopping_add_onhand = models.BooleanField(default=False) filter_to_supermarket = models.BooleanField(default=False) left_handed = models.BooleanField(default=False) + show_step_ingredients = models.BooleanField(default=True) default_delay = models.DecimalField(default=4, max_digits=8, decimal_places=4) shopping_recent_days = models.PositiveIntegerField(default=7) csv_delim = models.CharField(max_length=2, default=",") @@ -737,6 +738,7 @@ class Step(ExportModelOperationsMixin('step'), models.Model, PermissionModelMixi order = models.IntegerField(default=0) file = models.ForeignKey('UserFile', on_delete=models.PROTECT, null=True, blank=True) show_as_header = models.BooleanField(default=True) + show_ingredients_table = models.BooleanField(default=True) search_vector = SearchVectorField(null=True) step_recipe = models.ForeignKey('Recipe', default=None, blank=True, null=True, on_delete=models.PROTECT) diff --git a/cookbook/serializer.py b/cookbook/serializer.py index c867b2a6..4cb7b231 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -375,7 +375,7 @@ class UserPreferenceSerializer(WritableNestedModelSerializer): 'food_inherit_default', 'default_delay', 'mealplan_autoinclude_related', 'mealplan_autoexclude_onhand', 'shopping_share', 'shopping_recent_days', 'csv_delim', 'csv_prefix', - 'filter_to_supermarket', 'shopping_add_onhand', 'left_handed', 'food_children_exist' + 'filter_to_supermarket', 'shopping_add_onhand', 'left_handed', 'show_step_ingredients', 'food_children_exist' ) @@ -770,7 +770,8 @@ class StepSerializer(WritableNestedModelSerializer, ExtendedRecipeMixin): model = Step fields = ( 'id', 'name', 'instruction', 'ingredients', 'ingredients_markdown', - 'ingredients_vue', 'time', 'order', 'show_as_header', 'file', 'step_recipe', 'step_recipe_data', 'numrecipe' + 'ingredients_vue', 'time', 'order', 'show_as_header', 'file', 'step_recipe', + 'step_recipe_data', 'numrecipe', 'show_ingredients_table' ) @@ -1350,7 +1351,7 @@ class StepExportSerializer(WritableNestedModelSerializer): class Meta: model = Step - fields = ('name', 'instruction', 'ingredients', 'time', 'order', 'show_as_header') + fields = ('name', 'instruction', 'ingredients', 'time', 'order', 'show_as_header', 'show_ingredients_table') class RecipeExportSerializer(WritableNestedModelSerializer): diff --git a/cookbook/tests/factories/__init__.py b/cookbook/tests/factories/__init__.py index 2f740cf9..db1ac743 100644 --- a/cookbook/tests/factories/__init__.py +++ b/cookbook/tests/factories/__init__.py @@ -334,6 +334,8 @@ class StepFactory(factory.django.DjangoModelFactory): order = factory.Sequence(lambda x: x) # file = models.ForeignKey('UserFile', on_delete=models.PROTECT, null=True, blank=True) show_as_header = True + # TODO: need to update to fetch from User's preferences + show_step_ingredients = True step_recipe__has_recipe = False ingredients__food_recipe_count = 0 space = factory.SubFactory(SpaceFactory) diff --git a/cookbook/views/new.py b/cookbook/views/new.py index f32b4261..0bae4689 100644 --- a/cookbook/views/new.py +++ b/cookbook/views/new.py @@ -37,7 +37,7 @@ class RecipeCreate(GroupRequiredMixin, CreateView): obj.space = self.request.space obj.internal = True obj.save() - obj.steps.add(Step.objects.create(space=self.request.space, show_as_header=False)) + obj.steps.add(Step.objects.create(space=self.request.space, show_as_header=False, show_ingredients_table=self.request.user.userpreference.show_step_ingredients)) return HttpResponseRedirect(reverse('edit_recipe', kwargs={'pk': obj.pk})) def get_success_url(self): diff --git a/vue/src/apps/ImportView/ImportViewStepEditor.vue b/vue/src/apps/ImportView/ImportViewStepEditor.vue index 5bda6ea9..f1cb9da4 100644 --- a/vue/src/apps/ImportView/ImportViewStepEditor.vue +++ b/vue/src/apps/ImportView/ImportViewStepEditor.vue @@ -103,6 +103,7 @@ import draggable from "vuedraggable"; import stringSimilarity from "string-similarity" +import {getUserPreference} from "@/utils/utils" export default { name: "ImportViewStepEditor", @@ -117,6 +118,7 @@ export default { recipe_json: undefined, current_edit_ingredient: null, current_edit_step: null, + user_preferences: null, } }, watch: { @@ -126,6 +128,7 @@ export default { }, mounted() { this.recipe_json = this.recipe + this.user_preferences = getUserPreference(); }, methods: { /** @@ -138,7 +141,7 @@ export default { let steps = [] step.instruction.split(split_character).forEach(part => { if (part.trim() !== '') { - steps.push({'instruction': part, 'ingredients': []}) + steps.push({'instruction': part, 'ingredients': [], 'show_ingredients_table': this.user_preferences.show_step_ingredients}) } }) steps[0].ingredients = step.ingredients // put all ingredients from the original step in the ingredients of the first step of the split step list diff --git a/vue/src/apps/RecipeEditView/RecipeEditView.vue b/vue/src/apps/RecipeEditView/RecipeEditView.vue index 4315867d..7045a312 100644 --- a/vue/src/apps/RecipeEditView/RecipeEditView.vue +++ b/vue/src/apps/RecipeEditView/RecipeEditView.vue @@ -240,6 +240,16 @@ v-if="step_index !== recipe.steps.length - 1"> {{ $t("Move_Down") }} + + + + @@ -270,7 +280,6 @@ @click="step.time_visible = true" v-if="!step.time_visible"> {{ $t("Time") }} - {{ $t("Ingredients") }} @@ -770,7 +779,8 @@ import { ResolveUrlMixin, StandardToasts, convertEnergyToCalories, - energyHeading + energyHeading, + getUserPreference } from "@/utils/utils" import Multiselect from "vue-multiselect" import {ApiApiFactory} from "@/utils/openapi/api" @@ -813,6 +823,7 @@ export default { show_file_create: false, step_for_file_create: undefined, use_plural: false, + user_preferences: undefined, additional_visible: false, create_food: undefined, md_editor_toolbars: { @@ -858,9 +869,9 @@ export default { this.searchKeywords("") this.searchFiles("") this.searchRecipes("") - this.$i18n.locale = window.CUSTOM_LOCALE let apiClient = new ApiApiFactory() + this.user_preferences = getUserPreference() apiClient.retrieveSpace(window.ACTIVE_SPACE_ID).then(r => { this.use_plural = r.data.use_plural }) @@ -925,7 +936,10 @@ export default { // set default visibility style for each component of the step this.recipe.steps.forEach((s) => { this.$set(s, "time_visible", s.time !== 0) - this.$set(s, "ingredients_visible", s.ingredients.length > 0 || this.recipe.steps.length === 1) + // ingredients_visible determines whether or not the ingredients UI is shown in the edit view + // show_ingredients_table determine whether the ingredients table is shown in the read view + // these are seperate as one might want to add ingredients but not want the step-level view + this.$set(s, "ingredients_visible", s.show_ingredients_table && (s.ingredients.length > 0 || this.recipe.steps.length === 1)) this.$set(s, "instruction_visible", s.instruction !== "" || this.recipe.steps.length === 1) this.$set(s, "step_recipe_visible", s.step_recipe !== null) this.$set(s, "file_visible", s.file !== null) @@ -1028,6 +1042,7 @@ export default { show_as_header: false, time_visible: false, ingredients_visible: true, + show_ingredients_table: this.user_preferences.show_step_ingredients, instruction_visible: true, step_recipe_visible: false, file_visible: false, @@ -1083,6 +1098,9 @@ export default { this.recipe.steps.splice(new_index < 0 ? 0 : new_index, 0, step) this.sortSteps() }, + setStepShowIngredientsTable: function (step, show_state) { + step.show_ingredients_table = show_state + }, moveIngredient: function (step, ingredient, new_index) { step.ingredients.splice(step.ingredients.indexOf(ingredient), 1) step.ingredients.splice(new_index < 0 ? 0 : new_index, 0, ingredient) diff --git a/vue/src/components/Settings/CosmeticSettingsComponent.vue b/vue/src/components/Settings/CosmeticSettingsComponent.vue index 4e82d129..01bc1c7d 100644 --- a/vue/src/components/Settings/CosmeticSettingsComponent.vue +++ b/vue/src/components/Settings/CosmeticSettingsComponent.vue @@ -31,6 +31,12 @@ + + + {{ $t('show_step_ingredients_setting') }} + + +
diff --git a/vue/src/components/StepComponent.vue b/vue/src/components/StepComponent.vue index 8b5fbfb8..c60a28e8 100644 --- a/vue/src/components/StepComponent.vue +++ b/vue/src/components/StepComponent.vue @@ -33,7 +33,7 @@
+ v-if="step.show_ingredients_table && step.ingredients.length > 0 && (recipe.steps.length > 1 || force_ingredients)"> @@ -124,10 +124,7 @@