From 2af7b64d4fd33326656b950a8eea6935c8f31491 Mon Sep 17 00:00:00 2001 From: smilerz Date: Thu, 2 Dec 2021 09:50:01 -0600 Subject: [PATCH] visual indicator meal plan in shopping --- cookbook/serializer.py | 6 +- vue/src/components/MealPlanCard.vue | 222 ++++++++++++----------- vue/src/components/RecipeContextMenu.vue | 2 +- vue/src/locales/en.json | 5 +- 4 files changed, 122 insertions(+), 113 deletions(-) diff --git a/cookbook/serializer.py b/cookbook/serializer.py index 0da7f87b..304f414c 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -610,10 +610,14 @@ class MealPlanSerializer(SpacedModelSerializer, WritableNestedModelSerializer): note_markdown = serializers.SerializerMethodField('get_note_markdown') servings = CustomDecimalField() shared = UserNameSerializer(many=True, required=False, allow_null=True) + shopping = serializers.SerializerMethodField('in_shopping') def get_note_markdown(self, obj): return markdown(obj.note) + def in_shopping(self, obj): + return ShoppingListRecipe.objects.filter(mealplan=obj.id).exists() + def create(self, validated_data): validated_data['created_by'] = self.context['request'].user mealplan = super().create(validated_data) @@ -626,7 +630,7 @@ class MealPlanSerializer(SpacedModelSerializer, WritableNestedModelSerializer): fields = ( 'id', 'title', 'recipe', 'servings', 'note', 'note_markdown', 'date', 'meal_type', 'created_by', 'shared', 'recipe_name', - 'meal_type_name' + 'meal_type_name', 'shopping' ) read_only_fields = ('created_by',) diff --git a/vue/src/components/MealPlanCard.vue b/vue/src/components/MealPlanCard.vue index c0cdff5a..d72eb6b1 100644 --- a/vue/src/components/MealPlanCard.vue +++ b/vue/src/components/MealPlanCard.vue @@ -1,128 +1,132 @@ \ No newline at end of file + diff --git a/vue/src/components/RecipeContextMenu.vue b/vue/src/components/RecipeContextMenu.vue index 024f9321..a225dd77 100644 --- a/vue/src/components/RecipeContextMenu.vue +++ b/vue/src/components/RecipeContextMenu.vue @@ -17,7 +17,7 @@ {{ $t("Add_to_Shopping") }} - New {{ $t("create_shopping_new") }} + {{ $t("create_shopping_new") }} {{ $t("Add_to_Plan") }} diff --git a/vue/src/locales/en.json b/vue/src/locales/en.json index 05579373..a7e1eed4 100644 --- a/vue/src/locales/en.json +++ b/vue/src/locales/en.json @@ -265,7 +265,7 @@ "CategoryInstruction": "Drag categories to change the order categories appear in shopping list.", "shopping_recent_days_desc": "Days of recent shopping list entries to display.", "shopping_recent_days": "Recent Days", - "create_shopping_new": "NEW: Add to Shopping List", + "create_shopping_new": "Add to NEW Shopping List", "download_pdf": "Download PDF", "download_csv": "Download CSV", "csv_delim_help": "Delimiter to use for CSV exports.", @@ -274,5 +274,6 @@ "copy_to_clipboard": "Copy to Clipboard", "csv_prefix_help": "Prefix to add when copying list to the clipboard.", "csv_prefix_label": "List Prefix", - "copy_markdown_table": "Copy as Markdown Table" + "copy_markdown_table": "Copy as Markdown Table", + "in_shopping": "In Shopping List" }