Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix filter displaying in views other than product list
dominik-zeglenfa186450aee7
diff --git a/saleor/static/dashboard/js/components/product-filter.js b/saleor/static/dashboard/js/components/filters.jssimilarity index 83%rename from saleor/static/dashboard/js/components/product-filter.jsrename to saleor/static/dashboard/js/components/filters.jsindex f4900feaf1..31c73d9582 100644--- a/saleor/static/dashboard/js/components/product-filter.js+++ b/saleor/static/dashboard/js/components/filters.js@@ -2,26 +2,29 @@ import {screenSizes} from './misc';let prevWindowWidth = null;let initialized = false;+let $list = null;+const $filters = $('#filters');const moveFilters = () => {if (prevWindowWidth !== window.innerWidth) {const $collapsibleCard = $('.collapse');prevWindowWidth = window.innerWidth;if (window.innerWidth < screenSizes.md) {- $('#product-list').before($('#product-filters'));+ $list.before($filters);if (!initialized) {$collapsibleCard.addClass('collapsed');initialized = true;}} else {- $('#product-list').after($('#product-filters'));+ $list.after($filters);$collapsibleCard.removeClass('collapsed');}}};export default $(document).ready(() => {- if ($('.body-products-list').length) {+ $list = $filters.prev();+ if ($('.body-filters').length) {moveFilters();$(window).on('resize', moveFilters);}diff --git a/saleor/static/dashboard/js/dashboard.js b/saleor/static/dashboard/js/dashboard.jsindex 505d97be9f..1f24dbcfbd 100644--- a/saleor/static/dashboard/js/dashboard.js+++ b/saleor/static/dashboard/js/dashboard.js@@ -9,7 +9,7 @@ import './components/datepicker';import './components/modal';import './components/image-gallery';import './components/misc';-import './components/product-filter';+import './components/filters';import './components/side-menu';import './components/styleguide';import './components/tab';diff --git a/saleor/static/dashboard/scss/dashboard.scss b/saleor/static/dashboard/scss/dashboard.scssindex 4afa7afb64..c7a8629818 100644--- a/saleor/static/dashboard/scss/dashboard.scss+++ b/saleor/static/dashboard/scss/dashboard.scss@@ -22,6 +22,6 @@@import "components/tabs";@import "components/timeline";-@import "layouts/products";+@import "layouts/filters";@import "layouts/style-guide";@import "print";diff --git a/saleor/static/dashboard/scss/layouts/_products.scss b/saleor/static/dashboard/scss/layouts/_filters.scsssimilarity index 65%rename from saleor/static/dashboard/scss/layouts/_products.scssrename to saleor/static/dashboard/scss/layouts/_filters.scssindex ca559f4112..e54090beaf 100644--- a/saleor/static/dashboard/scss/layouts/_products.scss+++ b/saleor/static/dashboard/scss/layouts/_filters.scss@@ -1,5 +1,12 @@@media (min-width: $large-screen) {- .body-products-list {+ .body-filters {+ &.nav-toggled {+ .main {+ .container {+ margin: 40px 20px;+ }+ }+ }.main {.container {width: auto;diff --git a/templates/dashboard/customer/list.html b/templates/dashboard/customer/list.htmlindex 0163b8ae23..5dea5dad05 100644--- a/templates/dashboard/customer/list.html+++ b/templates/dashboard/customer/list.html@@ -9,7 +9,7 @@{% trans "Customers" context "Dashboard customers list" %} - {{ block.super }}{% endblock %}-{% block body_class %}body-customers{% endblock %}+{% block body_class %}body-customers body-filters{% endblock %}{% block menu_customers_class %}active{% endblock %}@@ -22,83 +22,88 @@{% endblock %}{% block content %}- {% include 'dashboard/includes/_filters.html' %}- {% if customers %}- <div class="card">- <div class="data-table-container">- <table class="bordered highlight responsive data-table">- <thead>- <tr>- <th>- <a href="{% get_sort_by_url_toggle 'email' %}">- {% trans "Email" context "Customers table header" %}- </a>- </th>- <th class="wide">- <a href="{% get_sort_by_url_toggle 'name' %}">- {% trans "Name" context "Customers table header" %}- </a>- </th>- <th>- <a href="{% get_sort_by_url_toggle 'location' %}">- {% trans "Location" context "Customers table header" %}- </a>- </th>- <th class="right-align">- <a href="{% get_sort_by_url_toggle 'num_orders' %}">- {% trans "Number of orders" context "Customers table header" %}- </a>- </th>- <th>- <a href="{% get_sort_by_url_toggle 'last_order' %}">- {% trans "Last order" context "Customers table header" %}- </a>- </th>- </tr>- </thead>- <tbody>- {% for customer in customers %}- <tr data-action-go="{% url "dashboard:customer-details" pk=customer.pk %}">- {% with customer.default_billing_address as default_address %}- <td>- {{ customer.email }}- </td>- {% if default_address %}- <td>- {{ default_address.first_name }} {{ default_address.last_name }}+ <div class="row">+ <div class="col s12 l9">+ {% if customers %}+ <div class="card">+ <div class="data-table-container">+ <table class="bordered highlight responsive data-table">+ <thead>+ <tr>+ <th>+ <a href="{% get_sort_by_url_toggle 'email' %}">+ {% trans "Email" context "Customers table header" %}+ </a>+ </th>+ <th class="wide">+ <a href="{% get_sort_by_url_toggle 'name' %}">+ {% trans "Name" context "Customers table header" %}+ </a>+ </th>+ <th>+ <a href="{% get_sort_by_url_toggle 'location' %}">+ {% trans "Location" context "Customers table header" %}+ </a>+ </th>+ <th class="right-align">+ <a href="{% get_sort_by_url_toggle 'num_orders' %}">+ {% trans "Number of orders" context "Customers table header" %}+ </a>+ </th>+ <th>+ <a href="{% get_sort_by_url_toggle 'last_order' %}">+ {% trans "Last order" context "Customers table header" %}+ </a>+ </th>+ </tr>+ </thead>+ <tbody>+ {% for customer in customers %}+ <tr data-action-go="{% url "dashboard:customer-details" pk=customer.pk %}">+ {% with customer.default_billing_address as default_address %}+ <td>+ {{ customer.email }}+ </td>+ {% if default_address %}+ <td>+ {{ default_address.first_name }} {{ default_address.last_name }}+ </td>+ <td>+ {{ default_address.city }}, {{ default_address.get_country_display }}+ </td>+ {% else %}+ <td colspan="2"></td>+ {% endif %}+ {% endwith %}+ <td class="right-align">+ {{ customer.num_orders }}</td>- <td>- {{ default_address.city }}, {{ default_address.get_country_display }}+ <td class="ignore-link">+ {% if customer.last_order %}+ <a href="{% url 'dashboard:order-details' order_pk=customer.last_order %}">+ {% blocktrans with last_order=customer.last_order trimmed context "Customers table last order data" %}+ #{{ last_order }}+ {% endblocktrans %}+ </a>+ {% endif %}</td>- {% else %}- <td>-</td>- <td>-</td>- {% endif %}- {% endwith %}- <td class="right-align">- {{ customer.num_orders }}- </td>- <td class="ignore-link">- {% if customer.last_order %}- <a href="{% url 'dashboard:order-details' order_pk=customer.last_order %}">- {% blocktrans with last_order=customer.last_order trimmed context "Customers table last order data" %}- #{{ last_order }}- {% endblocktrans %}- </a>- {% endif %}- </td>- </tr>- {% endfor %}- </tbody>- </table>- </div>+ </tr>+ {% endfor %}+ </tbody>+ </table>+ </div>+ </div>+ {% else %}+ <div class="card-content card-content--no-data not-found">+ <p class="grey-text">+ {% trans "No customers found." context "Empty customers table message" %}+ </p>+ </div>+ {% endif %}+ {% paginate customers %}</div>- {% else %}- <div class="card-content card-content--no-data not-found">- <p class="grey-text">- {% trans "No customers found." context "Empty customers table message" %}- </p>+ <div class="col s12 l3" id="filters">+ {% include 'dashboard/includes/_filters.html' %}</div>- {% endif %}- {% paginate customers %}+ </div>{% endblock %}diff --git a/templates/dashboard/discount/sale/list.html b/templates/dashboard/discount/sale/list.htmlindex d3680f159e..a92fb63aa7 100644--- a/templates/dashboard/discount/sale/list.html+++ b/templates/dashboard/discount/sale/list.html@@ -11,7 +11,7 @@{% trans "Sales" %} - {{ block.super }}{% endblock %}-{% block body_class %}body-sales{% endblock %}+{% block body_class %}body-sales body-filters{% endblock %}{% block menu_sales_class %}active{% endblock %}@@ -24,7 +24,6 @@{% block menu_discounts_class %} active{% endblock %}{% block content %}- {% include 'dashboard/includes/_filters.html' %}{% if perms.discount.edit_sale %}<div class="fixed-action-btn"><a href="{% url 'dashboard:sale-add' %}" class="btn-fab btn-floating btn-large waves-effect waves-light"@@ -33,46 +32,60 @@</a></div>{% endif %}- <div class="card">- <div class="data-table-container">- <table class="bordered highlight responsive data-table">- <thead>- <tr>- <th>- <a href="{% get_sort_by_url_toggle 'name' %}">- {% trans "Name" context "Sale (discount) table header" %}- </a>- </th>- <th>- <a href="{% get_sort_by_url_toggle 'value' %}">- {% trans "Discount" context "Sale (discount) table header" %}- </th>- </tr>- </thead>- <tbody>- {% if sales %}- {% for sale in sales %}- <tr data-action-go="{% if perms.discount.edit_sale %}{% url 'dashboard:sale-update' pk=sale.pk %}{% endif %}">- <td>- {{ sale }}- </td>+ <div class="row">+ <div class="col s12 l9">+ <div class="card">+ {% if perms.sale.edit_sale %}+ <div class="data-table-header-action">+ <a href="{% url 'dashboard:sale-add' %}" class="btn btn-data-table btn-flat" title="{% trans "Add sale" context "Sale (discount) list add button text" %}">+ {% trans "Add" context "Dashboard add action" %}+ </a>+ </div>+ {% endif %}+ <div class="data-table-container">+ <table class="bordered highlight responsive data-table">+ <thead>+ <tr>+ <th>+ <a href="{% get_sort_by_url_toggle 'name' %}">+ {% trans "Name" context "Sale (discount) table header" %}+ </a>+ </th>+ <th>+ <a href="{% get_sort_by_url_toggle 'value' %}">+ {% trans "Discount" context "Sale (discount) table header" %}+ </th>+ </tr>+ </thead>+ <tbody>+ {% if sales %}+ {% for sale in sales %}+ <tr data-action-go="{% if perms.sale.edit_sale %}{% url 'dashboard:sale-update' pk=sale.pk %}{% endif %}">+ <td>+ {{ sale }}+ </td>+ <td>+ {{ sale.value }}{{ sale.get_type_display }}+ </td>+ </tr>+ {% endfor %}+ {% else %}+ <tr><td>- {{ sale.value }}{{ sale.get_type_display }}+ <span>+ {% trans "No sales found" context "Empty sales table message" %}+ </span></td></tr>- {% endfor %}- {% else %}- <tr>- <td>- <span>- {% trans "No sales found" context "Empty sales table message" %}- </span>- </td>- </tr>- {% endif %}- </tbody>- </table>+ {% endif %}+ </tbody>+ </table>+ </div>+ </div>+ {% paginate sales %}+ </div>+ <div class="col s12 l3" id="filters">+ {% include 'dashboard/includes/_filters.html' %}</div></div>- {% paginate sales %}{% endblock %}diff --git a/templates/dashboard/discount/voucher/list.html b/templates/dashboard/discount/voucher/list.htmlindex 468911a2d2..b9554dc9f0 100644--- a/templates/dashboard/discount/voucher/list.html+++ b/templates/dashboard/discount/voucher/list.html@@ -10,7 +10,7 @@{% trans "Vouchers" context "Dashboard vouchers list" %} - {{ block.super }}{% endblock %}-{% block body_class %}body-vouchers{% endblock %}+{% block body_class %}body-vouchers body-filters{% endblock %}{% block menu_vouchers_class %}active{% endblock %}@@ -25,7 +25,6 @@{% block menu_discounts_class %} active{% endblock %}{% block content %}- {% include 'dashboard/includes/_filters.html' %}{% if perms.discount.edit_voucher %}<div class="fixed-action-btn"><a href="{% url 'dashboard:voucher-add' %}" class="btn-fab btn-floating btn-large waves-effect waves-light"@@ -34,97 +33,111 @@</a></div>{% endif %}- <div class="card">- <div class="data-table-container">- <table class="bordered highlight responsive data-table">- {% if vouchers %}- <thead>- <tr>- <th class="wide">- <a href="{% get_sort_by_url_toggle 'name' %}">- {% trans "Name" context "Voucher table header" %}- </a>- </th>- <th class="right-align">- <a href="{% get_sort_by_url_toggle 'discount_value' %}">- {% trans "Discount" context "Voucher table header" %}- </a>- </th>- <th>- <a href="{% get_sort_by_url_toggle 'apply_to' %}">- {% trans "Apply to" context "Voucher table header" %}- </a>- </th>- <th>- <a href="{% get_sort_by_url_toggle 'start_date' %}">- {% trans "Start date" context "Voucher table header" %}- </a>- </th>- <th>- <a href="{% get_sort_by_url_toggle 'end_date' %}">- {% trans "End date" context "Voucher table header" %}- </a>- </th>- <th class="right-align">- <a href="{% get_sort_by_url_toggle 'used' %}">- {% trans "Used" context "Voucher table header" %}- </a>- </th>- <th class="right-align">- <a href="{% get_sort_by_url_toggle 'limit' %}">- {% trans "Limit" context "Voucher table header" %}- </a>- </th>- </tr>- </thead>- {% for voucher in vouchers %}- <tbody>- <tr data-action-go="{% if perms.discount.edit_voucher %}{% url 'dashboard:voucher-update' pk=voucher.pk %}{% endif %}">- <td>- {{ voucher }}- </td>- <td class="right-align">- {{ voucher.discount_value }} <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>- </tbody>- {% endfor %}- {% else %}- <tbody>- <tr>- <td>- <span>- {% trans "No vouchers found" context "Empty vouchers table message" %}- </span>- </td>- </tr>- </tbody>- {% endif %}- </table>+ <div class="row">+ <div class="col s12 l9">+ <div class="card">+ {% if perms.voucher.edit_voucher %}+ <div class="data-table-header-action">+ <a href="{% url 'dashboard:voucher-add' %}" class="btn btn-data-table btn-flat" title="{% trans "Add voucher" context "Voucher list add button text" %}">+ {% trans "Add" context "Dashboard add action" %}+ </a>+ </div>+ {% endif %}+ <div class="data-table-container">+ <table class="bordered highlight responsive data-table">+ {% if vouchers %}+ <thead>+ <tr>+ <th class="wide">+ <a href="{% get_sort_by_url_toggle 'name' %}">+ {% trans "Name" context "Voucher table header" %}+ </a>+ </th>+ <th class="right-align">+ <a href="{% get_sort_by_url_toggle 'discount_value' %}">+ {% trans "Discount" context "Voucher table header" %}+ </a>+ </th>+ <th>+ <a href="{% get_sort_by_url_toggle 'apply_to' %}">+ {% trans "Apply to" context "Voucher table header" %}+ </a>+ </th>+ <th>+ <a href="{% get_sort_by_url_toggle 'start_date' %}">+ {% trans "Start date" context "Voucher table header" %}+ </a>+ </th>+ <th>+ <a href="{% get_sort_by_url_toggle 'end_date' %}">+ {% trans "End date" context "Voucher table header" %}+ </a>+ </th>+ <th class="right-align">+ <a href="{% get_sort_by_url_toggle 'used' %}">+ {% trans "Used" context "Voucher table header" %}+ </a>+ </th>+ <th class="right-align">+ <a href="{% get_sort_by_url_toggle 'limit' %}">+ {% trans "Limit" context "Voucher table header" %}+ </a>+ </th>+ </tr>+ </thead>+ {% for voucher in vouchers %}+ <tbody>+ <tr data-action-go="{% if perms.voucher.edit_voucher %}{% url 'dashboard:voucher-update' pk=voucher.pk %}{% endif %}">+ <td>+ {{ voucher }}+ </td>+ <td class="right-align">+ {{ voucher.discount_value }} <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>+ </tbody>+ {% endfor %}+ {% else %}+ <tbody>+ <tr>+ <td>+ <span>+ {% trans "No vouchers found" context "Empty vouchers table message" %}+ </span>+ </td>+ </tr>+ </tbody>+ {% endif %}+ </table>+ </div>+ </div>+ {% paginate vouchers %}+ </div>+ <div class="col s12 l3" id="filters">+ {% include 'dashboard/includes/_filters.html' %}</div></div>- {% paginate vouchers %}{% endblock %}diff --git a/templates/dashboard/order/list.html b/templates/dashboard/order/list.htmlindex 6e0e5d862b..de2a0ca36e 100644--- a/templates/dashboard/order/list.html+++ b/templates/dashboard/order/list.html@@ -6,7 +6,7 @@{% block title %}{% trans "Orders" context "Dashboard orders list" %} - {{ block.super }}{% endblock %}-{% block body_class %}body-orders{% endblock %}+{% block body_class %}body-orders body-filters{% endblock %}{% block menu_orders_class %}active{% endblock %}@@ -17,9 +17,9 @@{% endblock %}{% block content %}- {% include "dashboard/includes/_filters.html" %}- {% if orders %}- {% if orders %}+ <div class="row">+ <div class="col s12 l9">+ {% if orders %}<div class="card">{% include "dashboard/includes/_orders_table.html" with orders=orders %}</div>@@ -33,11 +33,9 @@</p></div>{% endif %}- {% else %}- <div class="not-found">- <p class="grey-text">- {% trans "No orders." context "Empty order list message" %}- </p></div>- {% endif %}+ <div class="col s12 l3" id="filters">+ {% include "dashboard/includes/_filters.html" %}+ </div>+ </div>{% endblock %}diff --git a/templates/dashboard/product/list.html b/templates/dashboard/product/list.htmlindex 564acf54cd..057e6eb768 100644--- a/templates/dashboard/product/list.html+++ b/templates/dashboard/product/list.html@@ -11,7 +11,7 @@{% trans "Products" context "Dashboard products list" %} - {{ block.super }}{% endblock %}-{% block body_class %}body-products-list{% endblock %}+{% block body_class %}body-products-list body-filters{% endblock %}{% block menu_products_class %}active{% endblock %}@@ -137,7 +137,7 @@</div>{% endif %}</div>- <div class="col s12 l3" id="product-filters">+ <div class="col s12 l3" id="filters">{% add_filters filter %}</div></div>diff --git a/templates/dashboard/staff/list.html b/templates/dashboard/staff/list.htmlindex f39693d709..343638c2bb 100644--- a/templates/dashboard/staff/list.html+++ b/templates/dashboard/staff/list.html@@ -10,7 +10,7 @@{% trans "Staff" context "Dashboard staff members list" %} - {{ block.super }}{% endblock %}-{% block body_class %}body-customers{% endblock %}+{% block body_class %}body-customers body-filters{% endblock %}{% block menu_staff_class %}active{% endblock %}@@ -35,62 +35,66 @@{% endblock %}{% block content %}- {% include 'dashboard/includes/_filters.html' %}- {% if staff %}- <div class="card">- <div class="data-table-container">- <table class="bordered highlight responsive data-table">- <thead>- <tr>- <th>- <a href="{% get_sort_by_url_toggle 'email' %}">- {% trans "Email" context "Staff members table header" %}- </a>- </th>- <th class="wide">- <a href="{% get_sort_by_url_toggle 'name' %}">- {% trans "Name" context "Staff members table header" %}- </a>- </th>- <th>- <a href="{% get_sort_by_url_toggle 'location' %}">- {% trans "Location" context "Staff members table header" %}- </a>- </th>- </tr>- </thead>- <tbody>- {% for user in staff %}- <tr data-action-go="{% if perms.userprofile.edit_staff %}{% url "dashboard:staff-details" pk=user.pk %}{% endif %}">- {% with user.default_billing_address as default_address %}- <td>- {{ user.email }}- </td>- {% if default_address %}- <td>- {{ default_address.first_name }} {{ default_address.last_name }}- </td>- <td>- {{ default_address.city }}, {{ default_address.get_country_display }}- </td>- {% else %}- <td colspan="2">-</td>- {% endif %}- {% endwith %}- </tr>- {% endfor %}- </tbody>- </table>- </div>+ <div class="row">+ <div class="col s12 l9">+ {% if staff %}+ <div class="card">+ <div class="data-table-container">+ <table class="bordered highlight responsive data-table">+ <thead>+ <tr>+ <th>+ <a href="{% get_sort_by_url_toggle 'email' %}">+ {% trans "Email" context "Staff members table header" %}+ </a>+ </th>+ <th class="wide">+ <a href="{% get_sort_by_url_toggle 'name' %}">+ {% trans "Name" context "Staff members table header" %}+ </a>+ </th>+ <th>+ <a href="{% get_sort_by_url_toggle 'location' %}">+ {% trans "Location" context "Staff members table header" %}+ </a>+ </th>+ </tr>+ </thead>+ <tbody>+ {% for user in staff %}+ <tr data-action-go="{% url "dashboard:staff-details" pk=user.pk %}">+ {% with user.default_billing_address as default_address %}+ <td>+ {{ user.email }}+ </td>+ {% if default_address %}+ <td>+ {{ default_address.first_name }} {{ default_address.last_name }}+ </td>+ <td>+ {{ default_address.city }}, {{ default_address.get_country_display }}+ </td>+ {% else %}+ <td colspan="2"></td>+ {% endif %}+ {% endwith %}+ </tr>+ {% endfor %}+ </tbody>+ </table>+ </div>+ </div>+ {% else %}+ <div class="card-content card-content--no-data not-found">+ <p class="grey-text">+ {% trans "No customers found." context "Empty customers table message" %}+ </p>+ </div>+ {% endif %}+ {% paginate staff %}</div>- {% else %}- <div class="card-content card-content--no-data not-found">- <p class="grey-text">- {% trans "No customers found." context "Empty customers table message" %}- </p>+ <div class="col s12 l3" id="filters">+ {% include 'dashboard/includes/_filters.html' %}</div>- {% endif %}-- {% paginate staff %}-+ </div>{% endblock %}