Skip to content

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

Use proper empty states for data tables

weronka6f38c41b3f6f
diff --git a/templates/dashboard/discount/sale_list.html b/templates/dashboard/discount/sale_list.html
index 11f2560cd5..2eba0247d0 100644
--- a/templates/dashboard/discount/sale_list.html
+++ b/templates/dashboard/discount/sale_list.html
@@ -18,7 +18,6 @@
{% block menu_discounts_class %} active{% endblock %}
{% block content %}
- {% if sales %}
<div class="card">
<div class="data-table-header-action">
<a href="{% url 'dashboard:sale-add' %}" class="btn-data-table btn-flat" title="{% trans "Add sale" context "Sale (discount) list add button text" %}">
@@ -34,22 +33,25 @@
</tr>
</thead>
<tbody>
- {% for sale in sales %}
- <tr data-action-go="{% url 'dashboard:sale-update' pk=sale.pk %}">
- <td>{{ sale }}</td>
- <td>{{ sale.value }}{{ sale.get_type_display }}</td>
- </tr>
- {% endfor %}
+ {% if sales %}
+ {% for sale in sales %}
+ <tr data-action-go="{% url 'dashboard:sale-update' pk=sale.pk %}">
+ <td>{{ sale }}</td>
+ <td>{{ sale.value }}{{ sale.get_type_display }}</td>
+ </tr>
+ {% endfor %}
+ {% else %}
+ <tr>
+ <td>
+ <span>
+ {% trans "No sales found" context "Empty sales table message" %}
+ </span>
+ </td>
+ </tr>
+ {% endif %}
</tbody>
</table>
</div>
</div>
-
{% include "dashboard/includes/_pagination.html" %}
- {% else %}
- <div class="not-found">
- <p class="grey-text">{% trans "No sales found." context "Empty sale (discount) table message" %}</p>
- <a href="{% url 'dashboard:sale-add' %}" class="btn btn-flat primary" title="{% trans "Add sale" context "Sale (discount) list add button text" %}">{% trans "Add new sale" context "Empty sale (discount) table add button" %}</a>
- </div>
- {% endif %}
{% endblock %}
diff --git a/templates/dashboard/discount/voucher_list.html b/templates/dashboard/discount/voucher_list.html
index 5488d23a6b..96fdd66279 100644
--- a/templates/dashboard/discount/voucher_list.html
+++ b/templates/dashboard/discount/voucher_list.html
@@ -18,7 +18,6 @@
{% block menu_discounts_class %} active{% endblock %}
{% block content %}
- {% if vouchers %}
<div class="card">
<div class="data-table-header-action">
<a href="{% url 'dashboard:voucher-add' %}" class="btn-data-table btn-flat" title="{% trans "Add voucher" context "Voucher list add button text" %}">
@@ -27,53 +26,58 @@
</div>
<div class="data-table-container">
<table class="bordered highlight responsive data-table">
- <thead>
- <tr>
- <th class="wide">{% trans "Name" context "Voucher table header" %}</th>
- <th class="right-align">{% trans "Discount" context "Voucher table header" %}</th>
- <th>{% trans "Apply to" context "Voucher table header" %}</th>
- <th>{% trans "Start date" context "Voucher table header" %}</th>
- <th>{% trans "End date" context "Voucher table header" %}</th>
- <th class="right-align">{% trans "Used" context "Voucher table header" %}</th>
- <th class="right-align">{% trans "Limit" context "Voucher table header" %}</th>
- </tr>
- </thead>
- <tbody>
- {% for voucher in vouchers %}
- <tr data-action-go="{% url 'dashboard:voucher-update' pk=voucher.pk %}">
- <td>{{ voucher }}</td>
- <td class="right-align">
- {{ voucher.discount_value }}&nbsp;<span class="currency">{{ voucher.get_discount_value_type_display }}</span>
- </td>
- <td>{{ voucher.get_apply_to_display|default_if_none:"-" }}</td>
- <td>{{ voucher.start_date }}</td>
- <td>{{ voucher.end_date|default_if_none:"-" }}</td>
- <td class="right-align">
- {% if voucher.usage_limit or voucher.usage_limit == 0 %}
- {{ voucher.used }}/{{ voucher.usage_limit }}
- {% else %}
- {{ voucher.used }}
- {% endif %}
- </td>
- <td class="right-align">
- {% if voucher.limit %}
- {% gross voucher.limit html=True %}
- {% else %}
- -
- {% endif %}
- </td>
- </tr>
- {% endfor %}
- </tbody>
+ {% if vouchers %}
+ <thead>
+ <tr>
+ <th class="wide">{% trans "Name" context "Voucher table header" %}</th>
+ <th class="right-align">{% trans "Discount" context "Voucher table header" %}</th>
+ <th>{% trans "Apply to" context "Voucher table header" %}</th>
+ <th>{% trans "Start date" context "Voucher table header" %}</th>
+ <th>{% trans "End date" context "Voucher table header" %}</th>
+ <th class="right-align">{% trans "Used" context "Voucher table header" %}</th>
+ <th class="right-align">{% trans "Limit" context "Voucher table header" %}</th>
+ </tr>
+ </thead>
+ {% for voucher in vouchers %}
+ <tbody>
+ <tr data-action-go="{% url 'dashboard:voucher-update' pk=voucher.pk %}">
+ <td>{{ voucher }}</td>
+ <td class="right-align">
+ {{ voucher.discount_value }}&nbsp;<span class="currency">{{ voucher.get_discount_value_type_display }}</span>
+ </td>
+ <td>{{ voucher.get_apply_to_display|default_if_none:"-" }}</td>
+ <td>{{ voucher.start_date }}</td>
+ <td>{{ voucher.end_date|default_if_none:"-" }}</td>
+ <td class="right-align">
+ {% if voucher.usage_limit or voucher.usage_limit == 0 %}
+ {{ voucher.used }}/{{ voucher.usage_limit }}
+ {% else %}
+ {{ voucher.used }}
+ {% endif %}
+ </td>
+ <td class="right-align">
+ {% if voucher.limit %}
+ {% gross voucher.limit html=True %}
+ {% else %}
+ -
+ {% endif %}
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ {% else %}
+ <tbody>
+ <tr>
+ <td>
+ <span>
+ {% trans "No vouchers found" context "Empty vouchers table message" %}
+ </span>
+ </td>
+ </tr>
+ </tbody>
+ {% endif %}
</table>
</div>
</div>
-
{% include "dashboard/includes/_pagination.html" %}
- {% else %}
- <div class="not-found">
- <p class="grey-text">{% trans "No vouchers found." context "Empty voucher table message" %}</p>
- <a href="{% url 'dashboard:voucher-add' %}" class="btn btn-flat primary" title="{% trans "Add new voucher" context "Voucher list add button text" %}">{% trans "Add new voucher" context "Empty voucher table add button" %}</a>
- </div>
- {% endif %}
{% endblock %}
diff --git a/templates/dashboard/shipping/method_list.html b/templates/dashboard/shipping/method_list.html
index cc9c0519c0..4dad3d388e 100644
--- a/templates/dashboard/shipping/method_list.html
+++ b/templates/dashboard/shipping/method_list.html
@@ -16,7 +16,6 @@
{% endblock %}
{% block content %}
- {% if shipping_methods %}
<div class="row">
<div class="col s12">
<div class="card">
@@ -27,41 +26,46 @@
</div>
<div class="data-table-container">
<table class="bordered highlight responsive data-table">
- <thead>
- <tr>
- <th>{% trans "Name" context "Shipping methods table header" %}</th>
- <th>{% trans "Price range" context "Shipping methods table header" %}</th>
- <th class="wide">{% trans "Countries" context "Shipping methods table header" %}</th>
- </tr>
- </thead>
- <tbody>
- {% for method in shipping_methods %}
- <tr data-action-go="{% url 'dashboard:shipping-method-detail' pk=method.pk %}">
- <td>{{ method }}</td>
+ {% if shipping_methods %}
+ <thead>
+ <tr>
+ <th>{% trans "Name" context "Shipping methods table header" %}</th>
+ <th>{% trans "Price range" context "Shipping methods table header" %}</th>
+ <th class="wide">{% trans "Countries" context "Shipping methods table header" %}</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for method in shipping_methods %}
+ <tr data-action-go="{% url 'dashboard:shipping-method-detail' pk=method.pk %}">
+ <td>{{ method }}</td>
+ <td>
+ {% if not method.price_range %}
+ -
+ {% elif method.price_range.min_price == method.price_range.max_price %}
+ {% gross method.price_range.min_price html=True %}
+ {% else %}
+ {% gross method.price_range.min_price html=True %}&ndash;{% gross method.price_range.max_price html=True %}
+ {% endif %}
+ </td>
+ <td>{{ method.countries|join:", " }}</td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ {% else %}
+ <tbody>
+ <tr>
<td>
- {% if not method.price_range %}
- -
- {% elif method.price_range.min_price == method.price_range.max_price %}
- {% gross method.price_range.min_price html=True %}
- {% else %}
- {% gross method.price_range.min_price html=True %}&ndash;{% gross method.price_range.max_price html=True %}
- {% endif %}
+ <span>
+ {% trans "No Shipping methods found" context "Empty Shipping methods table message" %}
+ </span>
</td>
- <td>{{ method.countries|join:", " }}</td>
</tr>
- {% endfor %}
- </tbody>
+ </tbody>
+ {% endif %}
</table>
</div>
</div>
</div>
</div>
{% include "dashboard/includes/_pagination.html" %}
- {% else %}
- <div class="not-found">
- <p class="grey-text">{% trans "No shipping methods found." context "Empty Shipping methods table" %}</p>
- <a href="{% url 'dashboard:shipping-method-add' %}" class="btn btn-flat primary" title="{% trans "Add method" context "Shipping method list add button text" %}">{% trans "Add new shipping method" context "Empty shipping methods table add button" %}</a>
- </div>
- {% endif %}
-
{% endblock %}