Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add images to tabs on mobile
Paweł Kowalewski29e5ebc21b0d
diff --git a/saleor/core/templates/materializecssform/field.html b/saleor/core/templates/materializecssform/field.htmlindex 9799fa01ec..b0a4f3a2fa 100644--- a/saleor/core/templates/materializecssform/field.html+++ b/saleor/core/templates/materializecssform/field.html@@ -26,7 +26,7 @@<div class="col {{ classes.label }}">{% if field.auto_id %}- <label class="control-label {{ classes.label }}{% if field.field.required %} required{% endif %}">{{ field.label }}</label>+ <label class="control-label {{ classes.label }}{% if not field.field.required %} optional{% endif %}">{{ field.label }}</label>{% endif %}{% for choice in field %}<p>@@ -107,7 +107,7 @@<div class="input-field col {{ classes.label }}"><textarea id="{{ field.auto_id }}" class="materialize-textarea" name="{{field.name}}">{% if field.value %}{{ field.value }}{% endif %}</textarea>{% if field.auto_id %}- <label class="active {{ classes.label }}{% if field.field.required %} required{% endif %}" for="{{ field.auto_id }}">{{ field.label }}</label>+ <label class="active {{ classes.label }}{% if not field.field.required %} optional{% endif %}" for="{{ field.auto_id }}">{{ field.label }}</label>{% endif %}{% for error in field.errors %}@@ -146,7 +146,7 @@<div class="price-wrapper">{{ field }}{% if field.auto_id %}- <label class="active{% if field.field.required %} required{% endif %}" for="{{ field.auto_id }}">{{ field.label }}</label>+ <label class="active{% if not field.field.required %} optional{% endif %}" for="{{ field.auto_id }}">{{ field.label }}</label>{% endif %}</div>diff --git a/saleor/dashboard/templates/dashboard/product/product_form.html b/saleor/dashboard/templates/dashboard/product/product_form.htmlindex 70a4dd26e9..e8bfa15333 100644--- a/saleor/dashboard/templates/dashboard/product/product_form.html+++ b/saleor/dashboard/templates/dashboard/product/product_form.html@@ -52,10 +52,30 @@<div class="row"><div class="col s12"><ul class="tabs">- <li class="tab col s3"><a class="active" href="#details">{% trans "Details" %}</a></li>- <li class="tab col s3"><a href="#variants">{% trans "Variants" %}</a></li>- <li class="tab col s3"><a href="#stock">{% trans "Stock" %}</a></li>- <li class="tab col s3"><a href="#images">{% trans "Images" %}</a></li>+ <li class="tab col s3">+ <a href="#details" class="active">+ <span>{% trans "Details" %}</span>+ <i class="mdi-action-description"></i>+ </a>+ </li>+ <li class="tab col s3">+ <a href="#variants">+ <span>{% trans "Variants" %}</span>+ <i class="mdi-image-style"></i>+ </a>+ </li>+ <li class="tab col s3">+ <a href="#stock">+ <span>{% trans "Stock" %}</span>+ <i class="mdi-action-store"></i>+ </a>+ </li>+ <li class="tab col s3">+ <a href="#images">+ <span>{% trans "Images" %}</span>+ <i class="mdi-image-collections"></i>+ </a>+ </li></ul></div></div>@@ -107,14 +127,14 @@<thead><tr><th class="bulk-checkbox">- <input type="checkbox" id="select-all" class="filled-in switch-actions">- <label for="select-all"></label>+ <input type="checkbox" id="select-all-variants" class="filled-in select-all switch-actions">+ <label for="select-all-variants"></label></th><th>{% trans "SKU" %}</th>{% for name, value in variants.0.get_attributes_display.items %}<th>{{ name }}</th>{% endfor %}- <th>{% trans "Name" %}</th>+ <th>{% trans "Variant name" %}</th><th class="right-align">{% trans "Price" %}</th></tr></thead>@@ -144,6 +164,54 @@</form></div>+ <div id="stock" class="card">+ <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">+ {% trans "Add" %}+ </a>++ <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>+ <th class="right-align">{% trans "Price" %}</th>+ </tr>+ </thead>++ <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>+ <td class="right-align">+ {% if item.cost_price %}+ {% gross item.cost_price %}+ {% endif %}+ </td>+ </tr>+ {% endfor %}+ </tbody>+ </table>+ </form>+ </div>+<div id="images"><div class="row"><div class="col l12">@@ -176,37 +244,6 @@</div></div></div>-- <div id="stock">- <div class="row">- <div class="col l12">- <ul class="collection">- {% for item in stock_items %}- <li class="collection-item">- <span>SKU: {{ item.variant.sku }}, quantity: {{ item.quantity }}, location: {{ item.location }}</span>- <a class="light-blue-text text-lighten-1" title="{% trans "Edit stock" %}"- href="{% url 'dashboard:product-stock-update' product_pk=product.pk stock_pk=item.pk %}">- <i class="mdi-content-create"></i>- </a>- <a class="materialize-red-text text-lighten-2" title="{% trans "Delete stock" %}"- href="{% url 'dashboard:product-stock-delete' product_pk=product.pk stock_pk=item.pk %}">- <i class="mdi-action-delete"></i>- </a>- </li>- {% empty %}- <span>{% trans "No stock items" %}</span>- {% endfor %}- </ul>- </div>- </div>- <div class="row">- <div class="col s12 right-align">- <a href="{% url 'dashboard:product-stock-add' product_pk=product.pk %}" class="btn">- <i class="mdi-content-add"></i> {% trans "Add stock" %}- </a>- </div>- </div>- </div>{% endif %}{% endblock %}diff --git a/saleor/dashboard/templates/dashboard/product/stock_form.html b/saleor/dashboard/templates/dashboard/product/stock_form.htmlindex e2226a3060..3ef2f20e9d 100644--- a/saleor/dashboard/templates/dashboard/product/stock_form.html+++ b/saleor/dashboard/templates/dashboard/product/stock_form.html@@ -9,11 +9,16 @@{% block page_title %}{{ title }}{% endblock %}+{% block header_menu %}+ {% url "dashboard:product-update" pk=product.pk as url %}+ {% include "dashboard/includes/_back-link.html" with url=url hash="#stock" %}+{% endblock %}+{% block breadcrumbs %}<ul class="breadcrumbs breadcrumbs--with-menu"><li><a href="{% url "dashboard:products" %}">{% trans "Products" %}</a></li>- <li><a href="{% url "dashboard:product-update" pk=product.pk %}"><i class="mdi-navigation-chevron-right"></i>{{ product }}</a></li>- <li><i class="mdi-navigation-chevron-right"></i> {{ title }}</li>+ <li><a href="{% url "dashboard:product-update" pk=product.pk %}#stock">{{ product }}</a></li>+ <li>{{ title }}</li></ul>{% endblock %}@@ -31,11 +36,10 @@<div class="row"><div class="col l8 offset-l2 right-align">- <a href="{% url 'dashboard:product-update' pk=product.pk %}#stock" class="btn-flat"><i class="mdi-content-clear"></i> {% trans "Cancel" %}</a>{% if stock.pk %}- <button type="submit" class="btn"><i class="mdi-content-save"></i> {% trans "Update" %}</button>+ <button type="submit" class="btn">{% trans "Update" %}</button>{% else %}- <button type="submit" class="btn"><i class="mdi-content-create"></i> {% trans "Create" %}</button>+ <button type="submit" class="btn">{% trans "Create" %}</button>{% endif %}</div></div>diff --git a/saleor/dashboard/templates/dashboard/product/variant_form.html b/saleor/dashboard/templates/dashboard/product/variant_form.htmlindex 8745e1b19e..12b605de78 100644--- a/saleor/dashboard/templates/dashboard/product/variant_form.html+++ b/saleor/dashboard/templates/dashboard/product/variant_form.html@@ -28,6 +28,10 @@<div class="col l4 offset-l2"><div class="row">{% csrf_token %}+ {{ form.attribute_fields.0.choices }}+{# {% for attribute_field in form.attribute_fields %}#}+{# {{ attribute_field|materializecss }}#}+{# {% endfor %}#}<input type="hidden" name="success_url" value="{% url 'dashboard:product-update' pk=product.pk %}#variants"></div></div>@@ -52,4 +56,4 @@</div></div></form>-{% endblock %}\ No newline at end of file+{% endblock %}diff --git a/saleor/static/js_src/dashboard.js b/saleor/static/js_src/dashboard.jsindex 4fcb918b1b..f8196c174c 100644--- a/saleor/static/js_src/dashboard.js+++ b/saleor/static/js_src/dashboard.js@@ -30,11 +30,12 @@ if (el) {}});}-$('#select-all').on('change', function() {+$('.select-all').on('change', function() {+ var $items = $(this).parents('form').find('.switch-actions');if (this.checked) {- $('.switch-actions').prop('checked', true);+ $items.prop('checked', true);} else {- $('.switch-actions').prop('checked', false);+ $items.prop('checked', false);}});$('.switch-actions').on('change', function() {diff --git a/saleor/static/scss/_app.scss b/saleor/static/scss/_app.scssindex 5b2f29e449..7171fc05f2 100644--- a/saleor/static/scss/_app.scss+++ b/saleor/static/scss/_app.scss@@ -214,4 +214,5 @@ table {@import "widget/product-gallery";@import "widget/product-list";@import "widget/select2";+@import "widget/tabs";@import "widget/toast";diff --git a/saleor/static/scss/widget/_form.scss b/saleor/static/scss/widget/_form.scssindex b6c3f35467..99191d9a21 100644--- a/saleor/static/scss/widget/_form.scss+++ b/saleor/static/scss/widget/_form.scss@@ -10,7 +10,7 @@label {@extend .active;- &:not(.required) {+ &.optional {&:before {content: "(optional)";float: right;diff --git a/saleor/static/scss/widget/_tabs.scss b/saleor/static/scss/widget/_tabs.scssnew file mode 100644index 0000000000..a291a5e5ba--- /dev/null+++ b/saleor/static/scss/widget/_tabs.scss@@ -0,0 +1,25 @@+@mixin tabs {+ li {+ a {+ span {+ display: none;++ @media (min-width: $small-screen-up) {+ display: inline;+ }+ }++ i {+ font-size: 24px;++ @media (min-width: $small-screen-up) {+ display: none;+ }+ }+ }+ }+}++.tabs {+ @include tabs;+}