From 39ccf7bbcf5758d45d246dc53d61097f2147f456 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Tue, 22 Nov 2022 07:58:12 +0100 Subject: [PATCH] added plural migration and pass param trough in recipe view --- ...redient_always_use_plural_food_and_more.py | 38 +++++++++++++++++++ vue/src/apps/ModelListView/ModelListView.vue | 3 +- vue/src/apps/RecipeView/RecipeView.vue | 11 +++++- vue/src/components/IngredientComponent.vue | 4 +- vue/src/components/StepComponent.vue | 7 +++- 5 files changed, 57 insertions(+), 6 deletions(-) create mode 100644 cookbook/migrations/0185_food_plural_name_ingredient_always_use_plural_food_and_more.py diff --git a/cookbook/migrations/0185_food_plural_name_ingredient_always_use_plural_food_and_more.py b/cookbook/migrations/0185_food_plural_name_ingredient_always_use_plural_food_and_more.py new file mode 100644 index 000000000..f29ec9d28 --- /dev/null +++ b/cookbook/migrations/0185_food_plural_name_ingredient_always_use_plural_food_and_more.py @@ -0,0 +1,38 @@ +# Generated by Django 4.0.8 on 2022-11-22 06:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('cookbook', '0184_alter_userpreference_image'), + ] + + operations = [ + migrations.AddField( + model_name='food', + name='plural_name', + field=models.CharField(blank=True, default=None, max_length=128, null=True), + ), + migrations.AddField( + model_name='ingredient', + name='always_use_plural_food', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='ingredient', + name='always_use_plural_unit', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='space', + name='use_plural', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='unit', + name='plural_name', + field=models.CharField(blank=True, default=None, max_length=128, null=True), + ), + ] diff --git a/vue/src/apps/ModelListView/ModelListView.vue b/vue/src/apps/ModelListView/ModelListView.vue index 4be8b693c..37d417c9b 100644 --- a/vue/src/apps/ModelListView/ModelListView.vue +++ b/vue/src/apps/ModelListView/ModelListView.vue @@ -23,8 +23,7 @@ - + diff --git a/vue/src/apps/RecipeView/RecipeView.vue b/vue/src/apps/RecipeView/RecipeView.vue index 2b1e3b9b8..53386c084 100644 --- a/vue/src/apps/RecipeView/RecipeView.vue +++ b/vue/src/apps/RecipeView/RecipeView.vue @@ -90,6 +90,7 @@ :ingredient_factor="ingredient_factor" :servings="servings" :header="true" + :use_plural="use_plural" id="ingredient_container" @checked-state-changed="updateIngredientCheckedState" @change-servings="servings = $event" @@ -123,6 +124,7 @@ :step="s" :ingredient_factor="ingredient_factor" :index="index" + :use_plural="use_plural" :start_time="start_time" @update-start-time="updateStartTime" @checked-state-changed="updateIngredientCheckedState" @@ -179,6 +181,7 @@ import KeywordsComponent from "@/components/KeywordsComponent" import NutritionComponent from "@/components/NutritionComponent" import RecipeSwitcher from "@/components/Buttons/RecipeSwitcher" import CustomInputSpinButton from "@/components/CustomInputSpinButton" +import {ApiApiFactory} from "@/utils/openapi/api"; Vue.prototype.moment = moment @@ -218,6 +221,7 @@ export default { }, data() { return { + use_plural: false, loading: true, recipe: undefined, rootrecipe: undefined, @@ -226,7 +230,7 @@ export default { start_time: "", share_uid: window.SHARE_UID, wake_lock: null, - ingredient_height: '250' + ingredient_height: '250', } }, watch: { @@ -239,6 +243,11 @@ export default { this.$i18n.locale = window.CUSTOM_LOCALE this.requestWakeLock() window.addEventListener('resize', this.handleResize); + + let apiClient = new ApiApiFactory() + apiClient.retrieveSpace(window.ACTIVE_SPACE_ID).then(r => { + this.use_plural = r.data.use_plural + }) }, beforeUnmount() { this.destroyWakeLock() diff --git a/vue/src/components/IngredientComponent.vue b/vue/src/components/IngredientComponent.vue index cbb7c91be..cb5de51ce 100644 --- a/vue/src/components/IngredientComponent.vue +++ b/vue/src/components/IngredientComponent.vue @@ -18,11 +18,11 @@