Skip to content

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

Add dotdotdot for category brdcrmbs ellipsis

Paweł Kowalewskid132b9ce3fb3
diff --git a/Gruntfile.js b/Gruntfile.js
index f4c54d5bef..6f76a15c8c 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -156,7 +156,8 @@ module.exports = function(grunt) {
"saleor/static/components/materialize/dist/js/materialize.js",
"saleor/static/components/Sortable/Sortable.js",
"saleor/static/components/select2/dist/js/select2.js",
- "saleor/static/js_src/dashboard.js"
+ "saleor/static/js_src/dashboard.js",
+ "saleor/static/components/dotdotdot/src/js/jquery.dotdotdot.js"
]
}
}
diff --git a/bower.json b/bower.json
index ce230d193c..688799459f 100644
--- a/bower.json
+++ b/bower.json
@@ -15,6 +15,7 @@
"jquery": "~2.1.4",
"Sortable": "~1.2.0",
"select2": "~4.0.0",
- "dropzone": "~4.0.1"
+ "dropzone": "~4.0.1",
+ "dotdotdot": "~1.7.3"
}
}
diff --git a/saleor/dashboard/templates/dashboard/base.html b/saleor/dashboard/templates/dashboard/base.html
index fd8c162587..56bf0dc4fa 100644
--- a/saleor/dashboard/templates/dashboard/base.html
+++ b/saleor/dashboard/templates/dashboard/base.html
@@ -95,6 +95,8 @@
</div>
</main>
+ <div class="hide-on-large-only"></div>
+
<!-- Core Scripts - Include with every page -->
<script src="{% static "js/dashboard.js" %}"></script>
<script src="{% static "versatileimagefield/js/versatileimagefield.js" %}"></script>
diff --git a/saleor/dashboard/templates/dashboard/category/list.html b/saleor/dashboard/templates/dashboard/category/list.html
index 4021f61563..cdc61ae787 100644
--- a/saleor/dashboard/templates/dashboard/category/list.html
+++ b/saleor/dashboard/templates/dashboard/category/list.html
@@ -1,29 +1,60 @@
{% extends "dashboard/base.html" %}
{% load i18n %}
{% load mptt_tags %}
+{% load materializecss %}
{% block title %}{% trans "Categories" %} - {{ block.super }}{% endblock %}
{% block body_class %}body-categories{% endblock %}
-{% block page_title %}{% trans "Categories" %}{% if current_node %}: {{ current_node }}{% endif %}{% 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 header_extra %}
- <a class="btn-fab btn-floating btn-large waves-effect waves-light teal" title="{% trans "Add category" %}"
- href="{% if root %}{% url 'dashboard:category-add' root_pk=root.pk %}{% else %}{% url 'dashboard:category-add' %}{% endif %}">
- <i class="mdi-content-add"></i>
+ <div class="fixed-action-btn">
+ <a class="btn-fab btn-floating btn-large waves-effect waves-light teal" title="{% trans "Add category" %}"
+ href="{% if root %}{% url 'dashboard:category-add' root_pk=root.pk %}{% else %}{% url 'dashboard:category-add' %}{% endif %}">
+ <i class="mdi-content-add"></i>
+ </a>
+ </div>
+
+ {% if root %}
+ <a class="dropdown-button" href="#" data-activates="category-delete" data-constrainwidth="false">
+ <i class="mdi-navigation-more-vert"></i>
</a>
+ <ul id="category-delete" class="dropdown-content">
+ <li>
+ <a class="modal-trigger" href="#modal-category-delete">
+ {% trans "Remove category" %}
+ </a>
+ </li>
+ </ul>
+ {% endif %}
{% endblock %}
{% block breadcrumbs %}
- <ul class="breadcrumbs breadcrumbs--with-menu">
+ <ul class="breadcrumbs breadcrumbs--with-menu breadcrumbs--ellipsed">
<li>{% if path %}<a href="{% url 'dashboard:category-list' %}">{% trans "Categories" %}</a>{% else %}{% trans "Categories" %}{% endif %}</li>
{% if path %}
{% for node in path %}
{% if forloop.last %}
- <li>{{ node.name }}</li>
+ <li title="{{ node.name }}"><span class="breadcrumbs--ellipsed-item">{{ node.name }}</span></li>
{% else %}
- <li><a href="{% url 'dashboard:category-list' root_pk=node.pk %}">{{ node.name }}</a></li>
+ <li>
+ <a title="{{ node.name }}" href="{% url 'dashboard:category-list' root_pk=node.pk %}">
+ <span class="breadcrumbs--ellipsed-item">{{ node.name }}</span>
+ </a>
+ </li>
{% endif %}
{% endfor %}
{% endif %}
diff --git a/saleor/static/js_src/dashboard.js b/saleor/static/js_src/dashboard.js
index 26be3f35f1..8da67f778b 100644
--- a/saleor/static/js_src/dashboard.js
+++ b/saleor/static/js_src/dashboard.js
@@ -15,6 +15,14 @@ $(document).ready(function() {
$tabs.find('a.active').parent().click();
}
+
+ var $breadcrumbs = $('.breadcrumbs--ellipsed');
+ if ($breadcrumbs && !$('.hide-on-large-only').is(':visible')) {
+ var $breadcrumbsItems = $('.breadcrumbs--ellipsed-item');
+ var breadcrumbsItemWidth = ($breadcrumbs.width() - $breadcrumbs.find('li:first').width()) / $breadcrumbsItems.length;
+ $breadcrumbsItems.css('max-width', breadcrumbsItemWidth).dotdotdot({'height': 50});
+ console.log($breadcrumbs.width() - $breadcrumbs.find('li:first').width(), $breadcrumbsItems.length);
+ }
});
Dropzone.options.productImageForm = {
paramName: "image",
diff --git a/saleor/static/scss/widget/_breadcrumbs.scss b/saleor/static/scss/widget/_breadcrumbs.scss
index 3e7f0881c5..80a5d635ba 100644
--- a/saleor/static/scss/widget/_breadcrumbs.scss
+++ b/saleor/static/scss/widget/_breadcrumbs.scss
@@ -57,6 +57,14 @@
width: calc(100% - 76px - 3rem);
}
}
+
+ &--ellipsed {
+ li span {
+ @media (min-width: $large-screen) {
+ display: inline-block;
+ }
+ }
+ }
}
.breadcrumbs {
diff --git a/saleor/static/scss/widget/_category-list.scss b/saleor/static/scss/widget/_category-list.scss
deleted file mode 100644
index 5a44d8cec0..0000000000
--- a/saleor/static/scss/widget/_category-list.scss
+++ /dev/null
@@ -1,37 +0,0 @@
-@mixin category-list {
- &-item {
- &-actions {
- font-size: $font-size-action-icon;
-
- @media (min-width: $medium-screen-up) {
- display: none;
- }
- }
-
- &:hover {
- .category-list-item-actions {
- @media (min-width: $medium-screen-up) {
- display: block;
- }
- }
- }
- }
-
- ul {
- li {
- .collapsible-header {
- padding-left: 2rem;
- }
-
- &:last-child {
- .collapsible-header {
- border-bottom: none;
- }
- }
- }
- }
-}
-
-.category-list {
- @include category-list;
-}
diff --git a/saleor/static/scss/widget/_product-list.scss b/saleor/static/scss/widget/_list.scss
similarity index 100%
rename from saleor/static/scss/widget/_product-list.scss
rename to saleor/static/scss/widget/_list.scss