Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Improve attributes
Paweł Kowalewskiae4e570a74e7
diff --git a/saleor/dashboard/templates/dashboard/product/attributes/form.html b/saleor/dashboard/templates/dashboard/product/attributes/form.htmlindex d0d0b6e20f..0c2c07c641 100644--- a/saleor/dashboard/templates/dashboard/product/attributes/form.html+++ b/saleor/dashboard/templates/dashboard/product/attributes/form.html@@ -5,15 +5,26 @@{% block title %}{% if attribute.pk %}{{ attribute }}{% else %}{% trans 'Add new attribute' %}{% endif %} - {% trans "Attributes" %} - {{ block.super }}{% endblock %}-{% block body_class %}body-store body-attributes{% endblock %}+{% block body_class %}body-attributes{% endblock %}-{% block custom_css %}- <style>- [type=checkbox]:not(:checked), [type=checkbox]:checked {- position: initial;- visibility: visible;- }- </style>+{% block header_menu %}+ {% url "dashboard:product-attributes" as url %}+ {% include "dashboard/includes/_back-link.html" with url=url %}+{% endblock %}++{% block header_extra %}+ {% if attribute.pk %}+ <a class="dropdown-button" href="#" data-activates="attribute-delete" data-constrainwidth="false">+ <i class="mdi-navigation-more-vert"></i>+ </a>+ <ul id="attribute-delete" class="dropdown-content">+ <li>+ <a class="modal-trigger" href="#modal-attribute-delete">+ {% trans "Remove attribute" %}+ </a>+ </li>+ </ul>+ {% endif %}{% endblock %}{% block breadcrumbs %}@@ -26,56 +37,74 @@{% block menu_catalogue_class %} active{% endblock %}{% block content %}- <form method="post" enctype="multipart/form-data">+ <form method="post" enctype="multipart/form-data" id="form-attributes"><div class="row">- <div class="col l8 offset-l2">+ <div class="col l8"><div class="row">{% csrf_token %}{{ form|materializecss }}</div>- <div class="row">- <legend>Attribute values</legend>- {{ formset.management_form }}- {{ formset.non_form_errors.as_ul }}- <table id="formset" class="form">- {% for form in formset.forms %}- {% if forloop.first %}- <thead>- <tr>- {% for field in form.visible_fields %}- <th>{{ field.label|capfirst }}</th>- {% endfor %}- </tr>- </thead>- {% endif %}- <tr class="{% cycle row1,row2 %}">++ <h5>{% trans "Attribute values" %}</h5>+ {{ formset.management_form }}+ {{ formset.non_form_errors.as_ul }}+ <table id="formset" class="highlight">+ {% for form in formset.forms %}+ {% if forloop.first %}+ <thead>+ <tr>{% for field in form.visible_fields %}- <td>- {% if forloop.first %}- {% for hidden in form.hidden_fields %}- {{ hidden }}- {% endfor %}- {% endif %}- {{ field.errors.as_ul }}- {{ field|materializecss }}- </td>+ <th>{{ field.label|capfirst }}</th>{% endfor %}</tr>- {% endfor %}- </table>- </div>+ </thead>+ {% endif %}+ <tr>+ {% for field in form.visible_fields %}+ <td{% if forloop.last %} class="center-align"{% endif %}>+ {% if forloop.first %}+ {% for hidden in form.hidden_fields %}+ {{ hidden }}+ {% endfor %}+ {% endif %}+ {{ field.errors.as_ul }}+ {{ field }}+ </td>+ {% endfor %}+ </tr>+ {% endfor %}+ </table></div></div><div class="row">- <div class="col l8 offset-l2 right-align">- <a href="{% url 'dashboard:product-attributes' %}" class="btn-flat"><i class="mdi-content-clear"></i> {% trans "Cancel" %}</a>+ <div class="col l8 right-align">{% if attribute.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></form>-{% endblock %}\ No newline at end of file++ {% if attribute.pk %}+ <div id="modal-attribute-delete" class="modal">+ <form action="{% url "dashboard:product-attribute-delete" pk=attribute.pk %}" method="post">+ {% csrf_token %}+ <div class="modal-content">+ <h5>{% trans "Are you sure?" %}</h5>++ <p>+ {% blocktrans %}You are about to delete an attribute <strong>{{ attribute }}</strong>.{% endblocktrans %}+ </p>+ </div>++ <div class="modal-footer">+ <button type="submit" class="modal-action btn-flat blue-text">{% trans "Delete" %}</button>+ <a href="#!" class="modal-action modal-close btn-flat blue-text">{% trans "Cancel" %}</a>+ </div>+ </form>+ </div>+ {% endif %}+{% endblock %}diff --git a/saleor/dashboard/templates/dashboard/product/attributes/list.html b/saleor/dashboard/templates/dashboard/product/attributes/list.htmlindex 03a52a768e..b643893cff 100644--- a/saleor/dashboard/templates/dashboard/product/attributes/list.html+++ b/saleor/dashboard/templates/dashboard/product/attributes/list.html@@ -4,7 +4,16 @@{% block title %}{% trans "Attributes" %} - {{ block.super }}{% endblock %}-{% block body_class %}body-store body-attributes{% endblock %}+{% block body_class %}body-attributes{% endblock %}++{% block header_extra %}+ <div class="fixed-action-btn">+ <a class="btn-fab btn-floating btn-large waves-effect waves-light teal modal-trigger"+ href="{% url 'dashboard:product-attribute-add' %}" title="{% trans "Add attribute" %}">+ <i class="mdi-content-add"></i>+ </a>+ </div>+{% endblock %}{% block breadcrumbs %}<ul class="breadcrumbs">@@ -17,22 +26,13 @@{% block content %}<div class="row"><div class="col s12">- <ul class="collection attributes-list">+ <ul class="collection attribute-list">{% for attribute in attributes %}- <li class="collection-item">+ <li class="collection-item attribute-list-item"><a href="{% url 'dashboard:product-attribute-update' pk=attribute.pk %}">{{ attribute.display }}</a>- <a href="{% url 'dashboard:product-attribute-delete' pk=attribute.pk %}" title="{% trans "Delete attribute" %}"- class="secondary-content materialize-red-text text-lighten-2 product-list-item-delete"><i class="mdi-action-delete"></i></a></li>{% endfor %}</ul></div></div>- <div class="row">- <div class="col s12 right-align">- <a href="{% url 'dashboard:product-attribute-add' %}" class="btn">- <i class="mdi-content-add"></i> {% trans "Add attribute" %}- </a>- </div>- </div>{% endblock %}diff --git a/saleor/dashboard/templates/dashboard/product/list.html b/saleor/dashboard/templates/dashboard/product/list.htmlindex 898862dfab..050db1e11e 100644--- a/saleor/dashboard/templates/dashboard/product/list.html+++ b/saleor/dashboard/templates/dashboard/product/list.html@@ -28,7 +28,6 @@</button></form>{% endif %}-</div>{% endblock %}diff --git a/saleor/dashboard/templates/dashboard/product/product_form.html b/saleor/dashboard/templates/dashboard/product/product_form.htmlindex 2ce62ad677..3bf6eaf949 100644--- a/saleor/dashboard/templates/dashboard/product/product_form.html+++ b/saleor/dashboard/templates/dashboard/product/product_form.html@@ -7,7 +7,7 @@{% block title %}{% if product.pk %}{{ product }}{% else %}{% trans 'Add new product' %}{% endif %} - {% trans "Products" %} - {{ block.super }}{% endblock %}-{% block body_class %}body-store body-products{% endblock %}+{% block body_class %}body-products{% endblock %}{% block header_menu %}{% url "dashboard:product-list" as url %}diff --git a/saleor/static/scss/_app.scss b/saleor/static/scss/_app.scssindex fc36232a7c..b372c5d4bc 100644--- a/saleor/static/scss/_app.scss+++ b/saleor/static/scss/_app.scss@@ -283,6 +283,7 @@ table {}}+@import "widget/attribute-list";@import "widget/breadcrumbs";@import "widget/card";@import "widget/category-list";diff --git a/saleor/static/scss/widget/_form.scss b/saleor/static/scss/widget/_form.scssindex 3de61ac80a..cdabdbd170 100644--- a/saleor/static/scss/widget/_form.scss+++ b/saleor/static/scss/widget/_form.scss@@ -65,6 +65,13 @@}}+ &#form-attributes {+ [type=checkbox]:not(:checked), [type=checkbox]:checked {+ position: initial;+ visibility: visible;+ }+ }+.versatileimagefield {margin-bottom: $gutter-width/2;