From f055df3b4de39b93bdb8214ba04bf1f0f97289f4 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sat, 30 Aug 2025 08:29:07 +0200 Subject: [PATCH] fixed original text for pasted ingredients --- cookbook/views/api.py | 4 ++-- vue3/src/components/inputs/StepEditor.vue | 3 ++- vue3/src/components/model_editors/RecipeEditor.vue | 6 +++--- vue3/src/openapi/models/ParsedIngredient.ts | 9 +++++++++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cookbook/views/api.py b/cookbook/views/api.py index a524ba2fe..6a1279a83 100644 --- a/cookbook/views/api.py +++ b/cookbook/views/api.py @@ -2507,7 +2507,7 @@ def meal_plans_to_ical(queryset, filename): request=inline_serializer(name="IngredientStringSerializer", fields={'text': CharField()}), responses=inline_serializer(name="ParsedIngredientSerializer", fields={'amount': IntegerField(), 'unit': CharField(), 'food': CharField(), - 'note': CharField()}) + 'note': CharField(), 'original_text': CharField()}) ) @api_view(['POST']) @permission_classes([CustomIsUser & CustomTokenHasReadWriteScope]) @@ -2517,7 +2517,7 @@ def ingredient_from_string(request): ingredient_parser = IngredientParser(request, False) amount, unit, food, note = ingredient_parser.parse(text) - ingredient = {'amount': amount, 'unit': None, 'food': None, 'note': note} + ingredient = {'amount': amount, 'unit': None, 'food': None, 'note': note, 'original_text': text} if food: food, created = Food.objects.get_or_create(space=request.space, name=food) ingredient['food'] = {'name': food.name, 'id': food.id} diff --git a/vue3/src/components/inputs/StepEditor.vue b/vue3/src/components/inputs/StepEditor.vue index aa6cfc54b..a35de4ca1 100644 --- a/vue3/src/components/inputs/StepEditor.vue +++ b/vue3/src/components/inputs/StepEditor.vue @@ -61,7 +61,7 @@
- + {{ ingredient.originalText }} @@ -306,6 +306,7 @@ function parseAndInsertIngredients() { r.forEach(i => { console.log(i) step.value.ingredients.push({ + originalText: i.value.originalText, amount: i.value.amount, food: i.value.food, unit: i.value.unit, diff --git a/vue3/src/components/model_editors/RecipeEditor.vue b/vue3/src/components/model_editors/RecipeEditor.vue index ecd554527..21b11e3d7 100644 --- a/vue3/src/components/model_editors/RecipeEditor.vue +++ b/vue3/src/components/model_editors/RecipeEditor.vue @@ -79,12 +79,12 @@ {{ $t('Add_Step') }} - + - {{ $t('Split') }} - {{ $t('Merge') }} + {{ $t('Split') }} + {{ $t('Merge') }} diff --git a/vue3/src/openapi/models/ParsedIngredient.ts b/vue3/src/openapi/models/ParsedIngredient.ts index e8f8110ad..c0b23ad3a 100644 --- a/vue3/src/openapi/models/ParsedIngredient.ts +++ b/vue3/src/openapi/models/ParsedIngredient.ts @@ -43,6 +43,12 @@ export interface ParsedIngredient { * @memberof ParsedIngredient */ note: string; + /** + * + * @type {string} + * @memberof ParsedIngredient + */ + originalText: string; } /** @@ -53,6 +59,7 @@ export function instanceOfParsedIngredient(value: object): value is ParsedIngred if (!('unit' in value) || value['unit'] === undefined) return false; if (!('food' in value) || value['food'] === undefined) return false; if (!('note' in value) || value['note'] === undefined) return false; + if (!('originalText' in value) || value['originalText'] === undefined) return false; return true; } @@ -70,6 +77,7 @@ export function ParsedIngredientFromJSONTyped(json: any, ignoreDiscriminator: bo 'unit': json['unit'], 'food': json['food'], 'note': json['note'], + 'originalText': json['original_text'], }; } @@ -83,6 +91,7 @@ export function ParsedIngredientToJSON(value?: ParsedIngredient | null): any { 'unit': value['unit'], 'food': value['food'], 'note': value['note'], + 'original_text': value['originalText'], }; }