Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Split list.html to list.html and detail.html

michal50072b62fb08
diff --git a/saleor/dashboard/category/urls.py b/saleor/dashboard/category/urls.py
index 2796755f7d..d0d00ecafc 100644
--- a/saleor/dashboard/category/urls.py
+++ b/saleor/dashboard/category/urls.py
@@ -7,8 +7,8 @@ from . import views
urlpatterns = [
url(r'^$',
views.category_list, name='category-list'),
- url(r'^(?P<root_pk>[0-9]+)/$',
- views.category_list, name='category-list'),
+ url(r'^(?P<pk>[0-9]+)/$',
+ views.category_detail, name='category-detail'),
url(r'^add/$',
views.category_create, name='category-add'),
url(r'^(?P<root_pk>[0-9]+)/add/$',
diff --git a/saleor/dashboard/category/views.py b/saleor/dashboard/category/views.py
index 3d54b378fd..2361855ec1 100644
--- a/saleor/dashboard/category/views.py
+++ b/saleor/dashboard/category/views.py
@@ -78,6 +78,19 @@ def category_edit(request, root_pk=None):
return TemplateResponse(request, template, ctx, status=status)
+@staff_member_required
+@permission_required('product.view_category')
+def category_detail(request, pk):
+ # categories = Category.tree.root_nodes()
+ root = get_object_or_404(Category, pk=pk)
+ path = root.get_ancestors(include_self=True) if root else []
+ categories = root.get_children()
+ categories = get_paginator_items(
+ categories, DASHBOARD_PAGINATE_BY, request.GET.get('page'))
+ ctx = {'categories': categories, 'path': path, 'root': root}
+ return TemplateResponse(request, 'dashboard/category/detail.html', ctx)
+
+
@staff_member_required
@permission_required('product.edit_category')
def category_delete(request, pk):
diff --git a/templates/dashboard/category/detail.html b/templates/dashboard/category/detail.html
new file mode 100644
index 0000000000..0218815209
--- /dev/null
+++ b/templates/dashboard/category/detail.html
@@ -0,0 +1,169 @@
+{% extends "dashboard/base.html" %}
+{% load i18n %}
+{% load mptt_tags %}
+{% load materializecss %}
+{% load staticfiles %}
+{% load utils %}
+
+{% block title %}{% trans "Categories" context "Category list page title" %} -
+ {{ block.super }}{% endblock %}
+
+{% block body_class %}body-categories{% endblock %}
+
+{% block menu_categories_class %}active{% endblock %}
+
+{% block header_menu %}
+ {% if root %}
+ {% if root.parent %}
+ {% url 'dashboard:category-list' root_pk=root.parent.pk as url %}
+ {% else %}
+ {% url 'dashboard:category-list' as url %}
+ {% endif %}
+ {% include "dashboard/includes/_back-link.html" with url=url %}
+ {% else %}
+ {{ block.super }}
+ {% endif %}
+{% endblock %}
+
+{% block breadcrumbs %}
+ <ul class="breadcrumbs breadcrumbs--history">
+ {% if path %}
+ <li>
+ <a href="{% url 'dashboard:category-list' %}">
+ {% trans "Categories" context "Dashboard categories list" %}
+ </a>
+ </li>
+ {% else %}
+ <li class="visible-s">
+ <span>
+ {% trans "Categories" context "Dashboard categories list" %}
+ </span>
+ </li>
+ {% endif %}
+ {% 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 %}
+ <li title="{{ node.name }}">
+ <span class="breadcrumbs--ellipsed-item">
+ {{ node.name }}
+ </span>
+ </li>
+ {% else %}
+ <li class="hide-on-med-and-down">
+ <a title="{{ node.name }}"
+ href="{% url 'dashboard:category-list' root_pk=node.pk %}"
+ class="breadcrumbs--ellipsed-item">
+ {{ node.name }}
+ </a>
+ </li>
+ {% endif %}
+ {% endfor %}
+ {% endif %}
+ </ul>
+{% endblock %}
+
+{% block menu_catalogue_class %} active{% endblock %}
+
+{% block content %}
+ {% if root %}
+ <div class="row">
+ <div class="col m12">
+ <div class="card">
+ <div class="card-content">
+ <span class="card-title">
+ {{ root.name }}
+ </span>
+ <div class="row">
+ {% if root.description %}
+ <div class="col s12 m4 l12">
+ <h4>
+ {% trans "Description" context "Shipping method field" %}
+ </h4>
+ <p>
+ {{ root.description }}
+ </p>
+ </div>
+ {% endif %}
+ </div>
+ </div>
+ {% if perms.product.edit_category %}
+ <div class="card-action">
+ <a class="btn btn-flat" href="{% url 'dashboard:category-edit' root_pk=root.pk %}">
+ {% trans "Edit category" context "Category detail view action" %}
+ </a>
+ <a class="btn btn-flat modal-trigger-custom"
+ data-href="{% url 'dashboard:category-delete' pk=root.pk %}"
+ href="#base-modal">
+ {% trans "Remove category" context "Category detail view action" %}
+ </a>
+ </div>
+ {% endif %}
+ </div>
+ </div>
+ </div>
+ {% endif %}
+
+ <div class="row">
+ <div class="col s12">
+ <div class="card">
+ <div class="data-table-header-action">
+ <a href="{% if root%}{% url 'dashboard:category-add' root_pk=root.pk %}{% else %}{% url 'dashboard:category-add' %}{% endif %}" class="btn-data-table btn btn-flat">
+ {% trans "Add" %}
+ </a>
+ </div>
+ <div class="data-table-container">
+ <table class="bordered highlight responsive data-table data-table-description">
+ <thead>
+ <tr>
+ <th>
+ {% trans "Name" context "Category list table header name" %}
+ </th>
+ <th>
+ {% trans "Description" context "Category list table header description" %}
+ </th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for node in categories %}
+ <tr data-action-go="{% url 'dashboard:category-detail' pk=node.pk %}">
+ <td>
+ {{ node.name }}
+ </td>
+ <td class="nowrap">
+ {% if node.description %}
+ {{ node.description }}
+ {% else %}
+ &nbsp;
+ {% endif %}
+ </td>
+ <td class="right-align">
+ <a href="{% url 'dashboard:category-edit' root_pk=node.pk %}" class="btn btn-flat">
+ {% trans 'Edit' context 'Category edit action' %}
+ </a>
+ <a class="btn btn-flat modal-trigger-custom"
+ data-href="{% url 'dashboard:category-delete' pk=node.pk %}"
+ href="#base-modal">
+ {% trans "Remove" context "Category list action link" %}
+ </a>
+ </td>
+ </tr>
+ {% empty %}
+ <tr>
+ <td colspan="2">{% trans "No categories" context "Empty list of categories" %}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ </div>
+ </div>
+ {% paginate categories %}
+ </div>
+ </div>
+{% endblock %}
diff --git a/templates/dashboard/category/list.html b/templates/dashboard/category/list.html
index 465be2a213..ad7cb1eeda 100644
--- a/templates/dashboard/category/list.html
+++ b/templates/dashboard/category/list.html
@@ -26,6 +26,42 @@
{% endif %}
{% endblock %}
+{% block header_extra %}
+ {% if perms.product.edit_category %}
+ <div class="fixed-action-btn">
+ <a class="btn-fab btn-floating btn-large waves-effect waves-light"
+ title="{% trans "Add category" context "Category list add button text" %}"
+ href="
+ {% if root %}{% url 'dashboard:category-add' root_pk=root.pk %}{% else %}{% url 'dashboard:category-add' %}{% endif %}">
+ <svg data-src="{% static "dashboard/images/add.svg" %}"/>
+ </a>
+ </div>
+ {% if root %}
+ <a class="dropdown-button right" href="#" data-activates="category-delete"
+ data-constrainwidth="false">
+ <svg data-src="{% static "dashboard/images/more_vert.svg" %}" height="24"
+ width="24"/>
+ </a>
+ <ul id="category-delete" class="dropdown-content">
+ <li>
+ <a class="modal-trigger-custom"
+ data-href="{% url 'dashboard:category-edit' root_pk=root.pk %}"
+ href="#base-modal">
+ {% trans "Edit category" context "Dashboard edit action" %}
+ </a>
+ </li>
+ <li>
+ <a class="modal-trigger-custom"
+ data-href="{% url 'dashboard:category-delete' pk=root.pk %}"
+ href="#base-modal">
+ {% trans "Remove category" context "Category list action link" %}
+ </a>
+ </li>
+ </ul>
+ {% endif %}
+ {% endif %}
+{% endblock %}
+
{% block breadcrumbs %}
<ul class="breadcrumbs breadcrumbs--history">
{% if path %}
@@ -72,44 +108,6 @@
{% block menu_catalogue_class %} active{% endblock %}
{% block content %}
- {% if root %}
- <div class="row">
- <div class="col m12">
- <div class="card">
- <div class="card-content">
- <span class="card-title">
- {{ root.name }}
- </span>
- <div class="row">
- {% if root.description %}
- <div class="col s12 m4 l12">
- <h4>
- {% trans "Description" context "Shipping method field" %}
- </h4>
- <p>
- {{ root.description }}
- </p>
- </div>
- {% endif %}
- </div>
- </div>
- {% if perms.product.edit_category %}
- <div class="card-action">
- <a class="btn btn-flat" href="{% url 'dashboard:category-edit' root_pk=root.pk %}">
- {% trans "Edit shipping method" context "Shipping method action" %}
- </a>
- <a class="btn btn-flat modal-trigger-custom"
- data-href="{% url 'dashboard:category-delete' pk=root.pk %}"
- href="#base-modal">
- {% trans "Remove category" context "Category list action link" %}
- </a>
- </div>
- {% endif %}
- </div>
- </div>
- </div>
- {% endif %}
-
<div class="row">
<div class="col s12 l9">
<div class="card">
@@ -161,14 +159,10 @@
</a>
</td>
</tr>
- {% empty %}
- <tr>
- <td colspan="2">{% trans "No categories" context "Empty list of categories" %}</td>
- </tr>
{% endfor %}
- </tbody>
- </table>
- </div>
+ </table>
+ </div>
+ </div>
{% paginate categories %}
</div>
</div>