From 9e5a7b2cc05d0e73af3f75e70c09478ef20e426f Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Wed, 13 Jan 2021 20:59:31 +0100 Subject: [PATCH] added loading spinner and made new view the main recipe view --- cookbook/templates/recipe_view.html | 586 +------------------------ cookbook/templates/test.html | 97 ---- cookbook/views/views.py | 14 +- vue/src/apps/RecipeView/RecipeView.vue | 204 ++++----- vue/src/components/LoadingSpinner.vue | 17 + vue/webpack-stats.json | 2 +- 6 files changed, 146 insertions(+), 774 deletions(-) create mode 100644 vue/src/components/LoadingSpinner.vue diff --git a/cookbook/templates/recipe_view.html b/cookbook/templates/recipe_view.html index 418c1b7a4..61308c50f 100644 --- a/cookbook/templates/recipe_view.html +++ b/cookbook/templates/recipe_view.html @@ -1,444 +1,19 @@ {% extends "base.html" %} +{% load render_bundle from webpack_loader %} {% load static %} -{% load crispy_forms_tags %} {% load i18n %} {% load l10n %} {% load custom_tags %} {% block title %}{{ recipe.name }}{% endblock %} -{% block extra_head %} - - {% include 'include/vue_base.html' %} - - - - - - - -{% endblock %} - {% block content %} -
-
- {% recipe_rating recipe request.user as rating %} -

{{ recipe.name }} {{ rating|safe }}

-
- {% if request.user.is_authenticated %} -
- -
- {% endif %} +
+
- {% if recipe.storage %} - {% trans 'in' %} {{ recipe.storage.name }}
- {% endif %} - - {% if recipe.internal %} - {% trans 'by' %} {{ recipe.created_by.get_user_name }}
- {% endif %} - - {% if recipe.keywords %} - {% for x in recipe.keywords.all %} - {{ x }} - {% endfor %} -
-
- {% endif %} - - {% if recipe.working_time and recipe.working_time != 0 %} - {% trans 'Preparation time ~' %} {{ recipe.working_time }} min - {% endif %} - - {% if recipe.waiting_time and recipe.waiting_time != 0 %} - {% trans 'Waiting time ~' %} {{ recipe.waiting_time }} min - {% endif %} - {% recipe_last recipe request.user as last_cooked %} - {% if last_cooked %} - {% trans 'Last cooked' %} {{ last_cooked|date }} - {% endif %} - - {% if recipe.waiting_time and recipe.waiting_time != 0 or recipe.working_time and recipe.working_time != 0 or last_cooked %} -
-
- {% endif %} - -
-
- -
-
-
-
-

{% trans 'Ingredients' %}

-
-
- -
- -
- -
-
-
-
-
-
-
- - - - - - - - - -
-
-
-
-
-
- {% if recipe.image %} -
- {% trans 'Recipe Image' %} -
-
-
- {% endif %} -
- - {% if recipe.nutrition %} -
-
-
-
-

{% trans 'Nutrition' %}

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- {% trans 'Calories' %} - {{ recipe.nutrition.calories|floatformat:2 }}kcal
- {% trans 'Carbohydrates' %} - {{ recipe.nutrition.carbohydrates|floatformat:2 }}g
- {% trans 'Fats' %} - {{ recipe.nutrition.fats|floatformat:2 }}g
- {% trans 'Proteins' %} - {{ recipe.nutrition.proteins|floatformat:2 }}g
- {% if recipe.nutrition.source %} - Source: {{ recipe.nutrition.source }} - {% endif %} -
-
-
-
- {% endif %} - - -
-
-

{% trans 'Instructions' %}

-
-
- -
- {% for s in recipe.steps.all %} -
-
- {% if recipe.steps.all|length > 1 %} -
- -
-
- {% if s.type == 'TEXT' %} - - {% elif s.type == 'TIME' %} - - {% endif %} - {% if s.name %}{{ s.name }}{% else %}{% trans 'Step' %} - {{ forloop.counter }}{% endif %} - {% if s.time != 0 %} - - {{ s.time }} {% trans 'Minutes' %} - {% endif %} -
-
- -
-
-
- -
-
- - - - - - - - -
-
-
- - {% endif %} - -
-
- {% if s.instruction %} - {{ s.get_instruction_render | safe }} - {% endif %} -
-
-
-
- {% endfor %} -
- - {% if recipe.storage %} -
- {% if recipe.internal %} - - {% else %} - - {% if '.pdf' in recipe.file_path %} -
- -
- {% endif %} - {% if '.jpg' in recipe.file_path or '.png' in recipe.file_path or '.jpeg' in recipe.file_path %} -
- {% trans 'External recipe image' %} -
- {% endif %} - -
-
-
-
{% trans 'External recipe' %}
-

- {% blocktrans %} - This is an external recipe, which means you can only view it by opening the link - above. - You can convert this recipe to a fancy recipe by pressing the convert button. The - original - file - will still be accessible. - {% endblocktrans %}. -
-
- {% trans 'Convert now!' %} - {% trans 'View external recipe' %} -

-
-
-
- - - {% endif %} -
- {% endif %} - {% if request.user.userpreference.comments %}

@@ -474,144 +49,27 @@ {% endif %} {% endif %} - {% if recipe.storage %} - {% include 'include/recipe_open_modal.html' %} - {% endif %} - - - - - {% include 'include/log_cooking.html' %} - {% endblock %} + {% block script %} + + + {% if debug %} + + {% else %} + + {% endif %} + + + + {% render_bundle 'chunk-vendors' %} + {% render_bundle 'recipe_view' %} {% endblock %} \ No newline at end of file diff --git a/cookbook/templates/test.html b/cookbook/templates/test.html index a524aa5e6..e69de29bb 100644 --- a/cookbook/templates/test.html +++ b/cookbook/templates/test.html @@ -1,97 +0,0 @@ -{% extends "base.html" %} -{% load render_bundle from webpack_loader %} -{% load static %} -{% load i18n %} -{% load l10n %} -{% load custom_tags %} - -{% block title %}{{ recipe.name }}{% endblock %} - -{% block content %} - {% recipe_rating recipe request.user as rating %} - - -
- -
- - {% if request.user.userpreference.comments %} -
-
- -
{% trans 'Comments' %} -
- {% for c in comments %} -
-
- {{ c.updated_at }} {% trans 'by' %} {{ c.created_by.username }}
- {{ c.text }} -
-
-
- {% endfor %} - - {% if request.user.is_authenticated %} -
- -
- {% csrf_token %} -
- -
- -
-
-
-
- {% endif %} - {% endif %} - -{% endblock %} - - -{% block script %} - - - {% if debug %} - - {% else %} - - {% endif %} - - - - - {% render_bundle 'chunk-vendors' %} - {% render_bundle 'recipe_view' %} -{% endblock %} \ No newline at end of file diff --git a/cookbook/views/views.py b/cookbook/views/views.py index d3b174680..13cc5b63d 100644 --- a/cookbook/views/views.py +++ b/cookbook/views/views.py @@ -153,7 +153,6 @@ def recipe_view(request, pk, share=None): ) comment_form = CommentForm() - bookmark_form = RecipeBookEntryForm() user_servings = None if request.user.is_authenticated: @@ -172,18 +171,7 @@ def recipe_view(request, pk, share=None): .exists(): ViewLog.objects.create(recipe=recipe, created_by=request.user) - return render( - request, - 'recipe_view.html', - { - 'recipe': recipe, - 'comments': comments, - 'comment_form': comment_form, - 'bookmark_form': bookmark_form, - 'share': share, - 'user_servings': user_servings - } - ) + return render(request, 'recipe_view.html', {'recipe': recipe, 'comments': comments, 'comment_form': comment_form, 'share': share, 'user_servings': user_servings}) @group_required('user') diff --git a/vue/src/apps/RecipeView/RecipeView.vue b/vue/src/apps/RecipeView/RecipeView.vue index 4a95e0d91..901e8817f 100644 --- a/vue/src/apps/RecipeView/RecipeView.vue +++ b/vue/src/apps/RecipeView/RecipeView.vue @@ -1,132 +1,136 @@