added plural migration and pass param trough in recipe view

This commit is contained in:
vabene1111
2022-11-22 07:58:12 +01:00
parent f92ee32c01
commit 39ccf7bbcf
5 changed files with 57 additions and 6 deletions

View File

@ -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),
),
]

View File

@ -23,8 +23,7 @@
<span v-if="apiName !== 'Step' && apiName !== 'CustomFilter'"> <span v-if="apiName !== 'Step' && apiName !== 'CustomFilter'">
<b-button variant="link" @click="startAction({ action: 'new' })"> <b-button variant="link" @click="startAction({ action: 'new' })">
<i class="fas fa-plus-circle fa-2x"></i> <i class="fas fa-plus-circle fa-2x"></i>
</b-button> </span </b-button> </span >
>
<!-- TODO add proper field to model config to determine if create should be available or not --> <!-- TODO add proper field to model config to determine if create should be available or not -->
</h3> </h3>
</div> </div>

View File

@ -90,6 +90,7 @@
:ingredient_factor="ingredient_factor" :ingredient_factor="ingredient_factor"
:servings="servings" :servings="servings"
:header="true" :header="true"
:use_plural="use_plural"
id="ingredient_container" id="ingredient_container"
@checked-state-changed="updateIngredientCheckedState" @checked-state-changed="updateIngredientCheckedState"
@change-servings="servings = $event" @change-servings="servings = $event"
@ -123,6 +124,7 @@
:step="s" :step="s"
:ingredient_factor="ingredient_factor" :ingredient_factor="ingredient_factor"
:index="index" :index="index"
:use_plural="use_plural"
:start_time="start_time" :start_time="start_time"
@update-start-time="updateStartTime" @update-start-time="updateStartTime"
@checked-state-changed="updateIngredientCheckedState" @checked-state-changed="updateIngredientCheckedState"
@ -179,6 +181,7 @@ import KeywordsComponent from "@/components/KeywordsComponent"
import NutritionComponent from "@/components/NutritionComponent" import NutritionComponent from "@/components/NutritionComponent"
import RecipeSwitcher from "@/components/Buttons/RecipeSwitcher" import RecipeSwitcher from "@/components/Buttons/RecipeSwitcher"
import CustomInputSpinButton from "@/components/CustomInputSpinButton" import CustomInputSpinButton from "@/components/CustomInputSpinButton"
import {ApiApiFactory} from "@/utils/openapi/api";
Vue.prototype.moment = moment Vue.prototype.moment = moment
@ -218,6 +221,7 @@ export default {
}, },
data() { data() {
return { return {
use_plural: false,
loading: true, loading: true,
recipe: undefined, recipe: undefined,
rootrecipe: undefined, rootrecipe: undefined,
@ -226,7 +230,7 @@ export default {
start_time: "", start_time: "",
share_uid: window.SHARE_UID, share_uid: window.SHARE_UID,
wake_lock: null, wake_lock: null,
ingredient_height: '250' ingredient_height: '250',
} }
}, },
watch: { watch: {
@ -239,6 +243,11 @@ export default {
this.$i18n.locale = window.CUSTOM_LOCALE this.$i18n.locale = window.CUSTOM_LOCALE
this.requestWakeLock() this.requestWakeLock()
window.addEventListener('resize', this.handleResize); 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() { beforeUnmount() {
this.destroyWakeLock() this.destroyWakeLock()

View File

@ -18,11 +18,11 @@
<td @click="done"> <td @click="done">
<template v-if="ingredient.unit !== null && !ingredient.no_amount"> <template v-if="ingredient.unit !== null && !ingredient.no_amount">
<template v-if="!use_plural"> <template v-if="!use_plural">
<span>{{ ingredient.unit.name }} <span>{{ ingredient.unit.name }}</span>
</template> </template>
<template v-else> <template v-else>
<template v-if="ingredient.unit.plural_name === '' || ingredient.unit.plural_name === null"> <template v-if="ingredient.unit.plural_name === '' || ingredient.unit.plural_name === null">
<span>{{ ingredient.unit.name }} <span>{{ ingredient.unit.name }}</span>
</template> </template>
<template v-else> <template v-else>
<span v-if="ingredient.always_use_plural_unit">{{ ingredient.unit.plural_name}}</span> <span v-if="ingredient.always_use_plural_unit">{{ ingredient.unit.plural_name}}</span>

View File

@ -35,7 +35,7 @@
<div class="col col-md-4" <div class="col col-md-4"
v-if="step.ingredients.length > 0 && (recipe.steps.length > 1 || force_ingredients)"> v-if="step.ingredients.length > 0 && (recipe.steps.length > 1 || force_ingredients)">
<table class="table table-sm"> <table class="table table-sm">
<ingredients-card :steps="[step]" :ingredient_factor="ingredient_factor" <ingredients-card :steps="[step]" :ingredient_factor="ingredient_factor" :use_plural="use_plural"
@checked-state-changed="$emit('checked-state-changed', $event)"/> @checked-state-changed="$emit('checked-state-changed', $event)"/>
</table> </table>
</div> </div>
@ -90,6 +90,7 @@
:index="index" :index="index"
:start_time="start_time" :start_time="start_time"
:force_ingredients="true" :force_ingredients="true"
:use_plural="use_plural"
></step-component> ></step-component>
</div> </div>
</div> </div>
@ -149,6 +150,10 @@ export default {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
use_plural: {
type: Boolean,
default: false,
},
}, },
computed: { computed: {
step_time: function() { step_time: function() {