Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix breadcrumbs and 'Cancel' buttons links
michal1ba492e1b035
diff --git a/saleor/dashboard/category/views.py b/saleor/dashboard/category/views.pyindex b79ec5cc5d..21a114f1fb 100644--- a/saleor/dashboard/category/views.py+++ b/saleor/dashboard/category/views.py@@ -39,6 +39,9 @@ def category_list(request, root_pk=None):@permission_required('product.edit_category')def category_create(request, root_pk=None):category = Category()+ if root_pk:+ root = get_object_or_404(Category, pk=root_pk)+ path = root.get_ancestors(include_self=True) if root else []form = CategoryForm(request.POST or None, parent_pk=root_pk)if form.is_valid():category = form.save()@@ -50,7 +53,7 @@ def category_create(request, root_pk=None):return redirect('dashboard:category-detail', pk=root_pk)else:return redirect('dashboard:category-list')- ctx = {'category': category, 'form': form}+ ctx = {'category': category, 'form': form, 'path': path}return TemplateResponse(request, 'dashboard/category/form.html', ctx)@@ -58,6 +61,9 @@ def category_create(request, root_pk=None):@permission_required('product.edit_category')def category_edit(request, root_pk=None):category = get_object_or_404(Category, pk=root_pk)+ if root_pk:+ root = get_object_or_404(Category, pk=root_pk)+ path = root.get_ancestors(include_self=True) if root else []form = CategoryForm(request.POST or None, instance=category,parent_pk=category.parent_id)status = 200@@ -73,7 +79,7 @@ def category_edit(request, root_pk=None):return redirect('dashboard:category-list')elif form.errors:status = 400- ctx = {'category': category, 'form': form, 'status': status}+ ctx = {'category': category, 'form': form, 'status': status, 'path': path}template = 'dashboard/category/form.html'return TemplateResponse(request, template, ctx, status=status)diff --git a/templates/dashboard/category/form.html b/templates/dashboard/category/form.htmlindex 8bc8c3ba78..d7aae8158f 100644--- a/templates/dashboard/category/form.html+++ b/templates/dashboard/category/form.html@@ -6,7 +6,7 @@{% block title %}{% if category.pk %}- {{ category }}+ {% trans "Edit category" context "Category form page title" %} {{ category }}{% else %}{% trans "Add new category" context "Category detail page title" %}{% endif %}@@ -21,7 +21,7 @@{% if category.pk %}{{ category }}{% else %}- {% trans "Add new category" context "Category detail page title" %}+ {% trans "Add new category" context "Category form page title" %}{% endif %}{% endblock %}@@ -37,15 +37,43 @@<svg data-src="{% static "dashboard/images/arrow-left.svg" %}" fill="#fff" width="20px" height="20px" /></a></li>- <li>- {% if category.pk %}- <span class="breadcrumbs--ellipsed-item">{{ category }}</span>- {% else %}- <span class="breadcrumbs--ellipsed-item">- {% trans "Add new category" context "Category detail breadcrumbs" %}- </span>- {% endif %}- </li>+ {% if path %}+ <li class="back-mobile">+ <a href="{% url 'dashboard:category-list' %}">+ <svg data-src="{% static "dashboard/images/arrow_left.svg" %}" fill="#fff" width="20px" height="20px"/>+ </a>+ </li>+ {% for node in path %}+ {% if forloop.last %}+ {% if node.pk %}+ <li>+ <a href="{% url 'dashboard:category-detail' pk=node.pk %}" class="breadcrumbs--ellipsed-item">{{ node }}</a>+ </li>+ <li>+ {% if category.pk %}+ <span class="breadcrumbs--ellipsed-item">+ {% trans "Edit" context "Category form page title" %}+ </span>+ </li>+ {% else %}+ <li>+ <span class="breadcrumbs--ellipsed-item">+ {% trans "Add new category" context "Category detail breadcrumbs" %}+ </span>+ </li>+ {% endif %}+ {% endif %}+ {% else %}+ <li class="hide-on-med-and-down">+ <a title="{{ node.name }}"+ href="{% url 'dashboard:category-detail' pk=node.pk %}"+ class="breadcrumbs--ellipsed-item">+ {{ node.name }}+ </a>+ </li>+ {% endif %}+ {% endfor %}+ {% endif %}</ul>{% endblock %}@@ -75,15 +103,9 @@</div></div><div class="card-action right-align">- {% if category.parent %}- <a href="{% url 'dashboard:category-detail' pk=category.parent.pk %}" class="btn btn-flat">- {% trans "Cancel" context "Dashboard cancel action" %}- </a>- {% else %}- <a href="{% url 'dashboard:category-list' %}" class="btn btn-flat">- {% trans "Cancel" context "Dashboard cancel action" %}- </a>- {% endif %}+ <a href="{% url 'dashboard:category-detail' pk=path.last.pk %}" class="btn btn-flat">+ {% trans "Cancel" context "Dashboard cancel action" %}+ </a>{% if category.pk %}<button type="submit" class="btn waves-effect waves-light">{% trans "Update" context "Dashboard update action" %}