Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve menu and add transition for fab
Paweł Kowalewskia1ff244c91bb
diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex 101be573f7..016646965a 100644--- a/saleor/dashboard/product/views.py+++ b/saleor/dashboard/product/views.py@@ -41,6 +41,7 @@ def product_details(request, pk=None, product_cls=None):Product.objects.select_subclasses().prefetch_related('images', 'variants'), pk=pk)title = product.name+ attributes = product.attributes.all()images = product.images.all()variants = product.variants.select_subclasses()stock_items = Stock.objects.filter(variant__in=variants)@@ -54,8 +55,8 @@ def product_details(request, pk=None, product_cls=None):if creating and product:return redirect('dashboard:product-update', pk=product.pk)- ctx = {'title': title, 'product': product, 'images': images,- 'product_form': form, 'stock_items': stock_items,+ ctx = {'title': title, 'product': product, 'attributes': attributes,+ 'images': images, 'product_form': form, 'stock_items': stock_items,'variants': variants}if pk:images_reorder_url = reverse_lazy('dashboard:product-images-reorder',diff --git a/saleor/dashboard/templates/dashboard/base.html b/saleor/dashboard/templates/dashboard/base.htmlindex 4c3c539de5..8db1c6d163 100644--- a/saleor/dashboard/templates/dashboard/base.html+++ b/saleor/dashboard/templates/dashboard/base.html@@ -53,10 +53,10 @@</a></li><li class="nav-home"><a href="{% url 'dashboard:index' %}">Home</a></li>- <li class="nav-store">- <ul class="collapsible collapsible-accordion">+ <li>+ <ul class="collapsible collapsible-accordion" data-collapsible="accordion"><li>- <a class="waves-effect waves-teal collapsible-header">{% trans "Store" %}</a>+ <a class="waves-effect waves-teal collapsible-header{% block menu_store_class %}{% endblock %}">{% trans "Store" %}</a><div class="collapsible-body"><ul><li class="subnav-products"><a href="{% url 'dashboard:products' %}">{% trans "Products" %}</a></li>@@ -65,12 +65,11 @@</ul></div></li>- </ul>- </li>- <li class="nav-orders">- <ul class="collapsible collapsible-accordion">++ <li class="divider"></li>+<li>- <a class="waves-effect waves-teal collapsible-header">{% trans "Orders" %}</a>+ <a class="waves-effect waves-teal collapsible-header{% block menu_orders_class %}{% endblock %}">{% trans "Orders" %}</a><div class="collapsible-body"><ul><li class="subnav-order-list"><a href="{% url 'dashboard:orders' %}">{% trans "List" %}</a></li>diff --git a/saleor/dashboard/templates/dashboard/product/list.html b/saleor/dashboard/templates/dashboard/product/list.htmlindex e34bf10ee1..ae87f6657d 100644--- a/saleor/dashboard/templates/dashboard/product/list.html+++ b/saleor/dashboard/templates/dashboard/product/list.html@@ -6,7 +6,7 @@{% block title %}{% trans "Products" %} - {{ block.super }}{% endblock %}-{% block body_class %}body-store body-products{% endblock %}+{% block body_class %}body-products{% endblock %}{% block header_extra %}<div class="fixed-action-btn">@@ -23,6 +23,8 @@</ul>{% endblock %}+{% block menu_store_class %} active{% endblock %}+{% block content %}<div class="row"><div class="col s12">diff --git a/saleor/dashboard/templates/dashboard/product/product_form.html b/saleor/dashboard/templates/dashboard/product/product_form.htmlindex 44e68b876f..d18fb63ddb 100644--- a/saleor/dashboard/templates/dashboard/product/product_form.html+++ b/saleor/dashboard/templates/dashboard/product/product_form.html@@ -37,6 +37,8 @@</ul>{% endblock %}+{% block menu_store_class %} active{% endblock %}+{% block content %}<div class="row" hidden><div class="col s12">@@ -81,7 +83,7 @@</div>{% endif %}- <div class="row" id="details">+ <div class="row tab-content" id="details"><form method="post" id="form-product" enctype="multipart/form-data">{% csrf_token %}{{ product_form.name|materializecss:"s12 m8" }}@@ -114,27 +116,33 @@</div>{% if product.pk %}- <div id="variants" class="card">+ <div id="variants" class="card tab-content"><form><div class="data-table-header">- <a href="{% url 'dashboard:variant-add' product_pk=product.pk %}" class="btn-data-table btn-show-when-unchecked blue-text">- {% trans "Add" %}- </a>+ {% if attributes %}+ <a href="{% url 'dashboard:variant-add' product_pk=product.pk %}" class="btn-data-table btn-show-when-unchecked blue-text">+ {% trans "Add" %}+ </a>+ {% else %}+ <span class="deep-purple-text">{% trans "You need to add some attributes to product to be able to add more variants." %}</span>+ {% endif %}<button type="submit" class="btn-data-table btn-show-when-checked red-text" hidden>{% trans "Delete" %}</button></div><table class="bordered hoverable data-table"><thead><tr>- <th class="bulk-checkbox">- <input type="checkbox" id="select-all-variants" class="filled-in select-all switch-actions">- <label for="select-all-variants"></label>- </th>+ {% if attributes %}+ <th class="bulk-checkbox">+ <input type="checkbox" id="select-all-variants" class="filled-in select-all switch-actions">+ <label for="select-all-variants"></label>+ </th>+ {% endif %}<th>{% trans "SKU" %}</th>{% for name, value in variants.0.get_attributes_display.items %}<th>{{ name }}</th>{% endfor %}- <th>{% trans "Variant name" %}</th>+ <th class="wide">{% trans "Variant name" %}</th><th class="right-align">{% trans "Price" %}</th></tr></thead>@@ -142,10 +150,12 @@<tbody>{% for variant in variants %}<tr>- <td class="bulk-checkbox">- <input name="variant_id" type="checkbox" id="{{ variant.id }}" class="filled-in switch-actions">- <label for="{{ variant.id }}"></label>- </td>+ {% if attributes %}+ <td class="bulk-checkbox">+ <input name="variant_id" type="checkbox" id="{{ variant.id }}" class="filled-in switch-actions">+ <label for="{{ variant.id }}"></label>+ </td>+ {% endif %}<td><a class="light-blue-text text-lighten-1" title="{% trans "Edit variant" %}"href="{% url 'dashboard:variant-update' product_pk=product.pk variant_pk=variant.pk %}">{{ variant.sku }}@@ -164,7 +174,7 @@</form></div>- <div id="stock" class="card">+ <div id="stock" class="card tab-content"><form><div class="data-table-header"><a href="{% url 'dashboard:product-stock-add' product_pk=product.pk %}" class="btn-data-table btn-show-when-unchecked blue-text">@@ -174,69 +184,82 @@<button type="submit" class="btn-data-table btn-show-when-checked red-text" hidden>{% trans "Delete" %}</button></div><table class="bordered hoverable data-table">- <thead>- <tr>- <th class="bulk-checkbox">- <input type="checkbox" id="select-all-stock" class="filled-in select-all switch-actions">- <label for="select-all-stock"></label>- </th>- <th>{% trans "SKU" %}</th>- <th class="right-align">{% trans "Quantity" %}</th>- <th>{% trans "Location" %}</th>- </tr>- </thead>+ {% if stock_items %}+ <thead>+ <tr>+ <th class="bulk-checkbox">+ <input type="checkbox" id="select-all-stock" class="filled-in select-all switch-actions">+ <label for="select-all-stock"></label>+ </th>+ <th>{% trans "SKU" %}</th>+ <th class="right-align">{% trans "Quantity" %}</th>+ <th class="wide">{% trans "Location" %}</th>+ </tr>+ </thead>- <tbody>- {% for item in stock_items %}+ <tbody>+ {% for item in stock_items %}+ <tr>+ <td class="bulk-checkbox">+ <input name="variant_id" type="checkbox" id="{{ variant.id }}" class="filled-in switch-actions">+ <label for="{{ variant.id }}"></label>+ </td>+ <td><a class="light-blue-text text-lighten-1" title="{% trans "Edit variant" %}"+ href="{% url 'dashboard:product-stock-update' product_pk=product.pk stock_pk=item.pk %}">+ {{ item.variant.sku }}+ </a></td>+ <td class="right-align">{{ item.quantity }}</td>+ <td>{{ item.location }}</td>+ </tr>+ {% endfor %}+ </tbody>+ {% else %}+ <tbody><tr>- <td class="bulk-checkbox">- <input name="variant_id" type="checkbox" id="{{ variant.id }}" class="filled-in switch-actions">- <label for="{{ variant.id }}"></label>+ <td>+ <span class="deep-purple-text">{% trans "You have literally no stock." %}</span></td>- <td><a class="light-blue-text text-lighten-1" title="{% trans "Edit variant" %}"- href="{% url 'dashboard:product-stock-update' product_pk=product.pk stock_pk=item.pk %}">- {{ item.variant.sku }}- </a></td>- <td class="right-align">{{ item.quantity }}</td>- <td>{{ item.location }}</td></tr>- {% endfor %}- </tbody>+ </tbody>+ {% endif %}</table></form></div>- <div id="images">- <div class="row">- <div class="col l12">- <ul class="row product-gallery" id="product-gallery" data-post-url="{{ images_reorder_url }}">- {% for image in images %}- <li class="col s6 m3 card product-gallery-item" data-id="{{ image.pk }}">- <div class="card-content">- <img class="responsive-img" src="{{ image.image.crop.300x300 }}" alt="">- <span class="product-gallery-item-text">{{ image.alt|default:image.image.name }}</span>- <a class="product-gallery-item-create light-blue-text text-lighten-1" title="{% trans "Edit image" %}"- href="{% url 'dashboard:product-image-update' product_pk=product.pk img_pk=image.pk %}">- <i class="mdi-content-create"></i>- </a>- <a class="product-gallery-item-remove materialize-red-text text-lighten-2" title="{% trans "Delete image" %}"- href="{% url 'dashboard:product-image-delete' product_pk=product.pk img_pk=image.pk %}">- <i class="mdi-action-delete"></i>- </a>- </div>- </li>- {% endfor %}- </ul>+ <div id="images" class="tab-content">+ {% if images %}+ <div class="row">+ <div class="col l12">+ <ul class="row product-gallery" id="product-gallery" data-post-url="{{ images_reorder_url }}">+ {% for image in images %}+ <li class="col s6 m3 card product-gallery-item" data-id="{{ image.pk }}">+ <div class="card-content">+ <img class="responsive-img" src="{{ image.image.crop.300x300 }}" alt="">+ <span class="product-gallery-item-text">{{ image.alt|default:image.image.name }}</span>+ <a class="product-gallery-item-create light-blue-text text-lighten-1" title="{% trans "Edit image" %}"+ href="{% url 'dashboard:product-image-update' product_pk=product.pk img_pk=image.pk %}">+ <i class="mdi-content-create"></i>+ </a>+ <a class="product-gallery-item-remove materialize-red-text text-lighten-2" title="{% trans "Delete image" %}"+ href="{% url 'dashboard:product-image-delete' product_pk=product.pk img_pk=image.pk %}">+ <i class="mdi-action-delete"></i>+ </a>+ </div>+ </li>+ {% endfor %}+ </ul>+ </div></div>- </div>+ {% else %}+ <p class="deep-purple-text">{% trans "This product has no images yet." %}</p>+ {% endif %}+ </div>- <div class="row">- <div class="col s12 right-align">- <a href="{% url 'dashboard:product-image-add' product_pk=product.pk %}" class="btn">- <i class="mdi-content-add"></i> {% trans "Add new image" %}- </a>- </div>- </div>+ <div class="fixed-action-btn">+ <a class="btn-fab btn-fab-hidden btn-floating btn-large waves-effect waves-light teal" id="images-btn"+ href="{% url 'dashboard:product-image-add' product_pk=product.pk %}" title="{% trans "Add product" %}">+ <i class="mdi-content-add"></i>+ </a></div>{% endif %}diff --git a/saleor/dashboard/templates/dashboard/product/variant_form.html b/saleor/dashboard/templates/dashboard/product/variant_form.htmlindex c28a231140..eb280440a7 100644--- a/saleor/dashboard/templates/dashboard/product/variant_form.html+++ b/saleor/dashboard/templates/dashboard/product/variant_form.html@@ -25,17 +25,19 @@{% block content %}<form method="post" id="form-variant" enctype="multipart/form-data"><div class="row">- <div class="col l4 offset-l2">- <div class="row">- {% csrf_token %}- {% for attribute_field in attributes_form %}- {{ attribute_field|materializecss }}- {% endfor %}- <input type="hidden" name="success_url" value="{% url 'dashboard:product-update' pk=product.pk %}#variants">+ {% if attributes_form.fields %}+ <div class="col s12 m6 l4">+ <div class="row">+ {% csrf_token %}+ {% for attribute_field in attributes_form %}+ {{ attribute_field|materializecss }}+ {% endfor %}+ <input type="hidden" name="success_url" value="{% url 'dashboard:product-update' pk=product.pk %}#variants">+ </div></div>- </div>+ {% endif %}- <div class="col l4">+ <div class="col s12 m6 l4"><div class="row">{{ form.product }}{{ form.sku|materializecss }}@@ -47,7 +49,7 @@</div><div class="row">- <div class="col l8 offset-l2 right-align">+ <div class="col s12{% if attributes_form.fields %} l8{% else %} m4{% endif %} right-align">{% if variant.pk %}<button type="submit" class="btn">{% trans "Update" %}</button>{% else %}diff --git a/saleor/static/js_src/dashboard.js b/saleor/static/js_src/dashboard.jsindex f8196c174c..814b6ac088 100644--- a/saleor/static/js_src/dashboard.js+++ b/saleor/static/js_src/dashboard.js@@ -4,7 +4,11 @@ $('select[multiple]').addClass('browser-default').select2();$('.modal-trigger').leanModal();$('ul.tabs').find('.tab').on('click', function(e) {window.history.pushState(null, null, e.target.hash);+ var tabSelector = $(this).find('a').attr('href');+ $('.btn-fab').addClass('btn-fab-hidden');+ $(tabSelector+'-btn').removeClass('btn-fab-hidden');});+$('.tabs').find('a.active').parent().click();var el = document.getElementById('product-gallery');if (el) {var sortable = Sortable.create(el, {diff --git a/saleor/static/scss/_app.scss b/saleor/static/scss/_app.scssindex a039d1f399..bad871834b 100644--- a/saleor/static/scss/_app.scss+++ b/saleor/static/scss/_app.scss@@ -3,6 +3,7 @@ $icons-font-path: $roboto-font-path;$font-size-action-icon: 18px;$header-height: 60px;+$transition-duration: .2s;@import "materialize/sass/materialize";@import "select2/src/scss/core";@@ -72,10 +73,8 @@ $header-height: 60px;content: none;}- @each $module in (home, orders, store) {- .body-#{$module} &.nav-#{$module} {- @extend .active;- }+ .body-home &.nav-home {+ @extend .active;}@each $submodule in (products, attributes, categories, order-list, payments, customers) {@@ -146,7 +145,7 @@ $header-height: 60px;height: 52px;line-height: 52px;padding-left: 30px;- transition: background-color .2s;+ transition: background-color $transition-duration;&:hover, &:focus {background-color: #ddd;@@ -170,6 +169,12 @@ $header-height: 60px;float: none;}}++ > li {+ &:hover {+ background: none;+ }+ }}}@@ -240,6 +245,30 @@ table {text-transform: uppercase;}+.fixed-action-btn {+ padding: 0;+}++.btn-fab {+ transition: transform $transition-duration;++ i {+ &:before {+ transition: font-size $transition-duration;+ }+ }+}++.btn-fab.btn-fab-hidden {+ transform: scale(0, 0);++ i {+ &:before {+ font-size: 0;+ }+ }+}+@import "widget/breadcrumbs";@import "widget/category-list";@import "widget/data-table";diff --git a/saleor/static/scss/widget/_breadcrumbs.scss b/saleor/static/scss/widget/_breadcrumbs.scssindex c3c3f61549..685a85bdff 100644--- a/saleor/static/scss/widget/_breadcrumbs.scss+++ b/saleor/static/scss/widget/_breadcrumbs.scss@@ -33,7 +33,7 @@display: inline-block;font-size: $h5-fontsize;padding: 0;- transition: color .2s;+ transition: color $transition-duration;&:hover {color: white;diff --git a/saleor/static/scss/widget/_data-table.scss b/saleor/static/scss/widget/_data-table.scssindex 8c14575dad..9be90ae5cb 100644--- a/saleor/static/scss/widget/_data-table.scss+++ b/saleor/static/scss/widget/_data-table.scss@@ -45,6 +45,10 @@padding-left: 0;}}++ .wide {+ width: 99%;+ }}.data-table {