Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Change bulk action select to table navigation bar
dominik-zeglen7cd30d95bf85
diff --git a/saleor/static/dashboard/js/components/bulk-actions.js b/saleor/static/dashboard/js/components/bulk-actions.jsindex 4d662a442e..c598849de8 100644--- a/saleor/static/dashboard/js/components/bulk-actions.js+++ b/saleor/static/dashboard/js/components/bulk-actions.js@@ -1,17 +1,19 @@-function updateCounterSelected () {+function updateHeader () {const count = $('.select-item:checked').length;const $counterTextNode = $('.data-table-header-action-selected-items');+ const $header = $('.data-table-header-alternative');const counterText = ngettext('item selected', 'items selected', count);if (!count) {- $counterTextNode.addClass('hide');+ $header.addClass('single').removeClass('bulk');} else {$counterTextNode.html(`${count} ${counterText}`);- $counterTextNode.removeClass('hide');+ $header.addClass('bulk').removeClass('single');}}$(document).ready((e) => {+ updateHeader();$('.select-all').on('change', function () {let $items = $(this).parents('form').find('.switch-actions');if (this.checked) {@@ -19,11 +21,9 @@ $(document).ready((e) => {} else {$items.prop('checked', false);}- updateCounterSelected();- });- $('.select-item').on('change', function () {- updateCounterSelected();+ updateHeader();});+ $('.select-item').on('change', updateHeader);$('.switch-actions').on('change', function () {let $btnChecked = $(this).parents('form').find('.btn-show-when-checked');let $btnUnchecked = $(this).parents('form').find('.btn-show-when-unchecked');@@ -35,4 +35,9 @@ $(document).ready((e) => {$btnChecked.hide();}});+ $('.bulk-actions a').on('click', (e) => {+ const a = $(e.currentTarget);+ $('#bulk-action').val(a.attr('data-action'));+ $('#bulk-actions-form').submit();+ });});diff --git a/saleor/static/dashboard/scss/components/_data-table.scss b/saleor/static/dashboard/scss/components/_data-table.scssindex 67fb0ebb84..70f280e36e 100644--- a/saleor/static/dashboard/scss/components/_data-table.scss+++ b/saleor/static/dashboard/scss/components/_data-table.scss@@ -19,6 +19,37 @@padding: 14px 8px;}+ &-header-alternative {+ box-shadow: none;+ border-bottom: 1px #d0d0d0 solid;+ transition: $transition-duration;+ max-height: 0;+ overflow: hidden;+ .show-single, .show-bulk {+ display: none;+ }+ &.bulk {+ background: #fff;+ color: $off-black;+ max-height: 100px;+ .show-bulk {+ display: block;+ }+ th, a {+ color: color('teal', 'base');+ }+ }+ &.single {+ background: #fff;+ .show-single {+ display: block;+ }+ th, a {+ color: color('teal', 'base');+ }+ }+ }+&-header {align-items: center;display: flex;diff --git a/templates/dashboard/product/list.html b/templates/dashboard/product/list.htmlindex 16437f48ae..23eef7ef51 100644--- a/templates/dashboard/product/list.html+++ b/templates/dashboard/product/list.html@@ -47,21 +47,26 @@<div class="col s12">{% if products %}<div class="card">- <form method="POST" action="{% url "dashboard:product-bulk-update" %}" novalidate>- {% csrf_token %}- <div class="data-table-header-action">- <div class="row mb-0">- <div class="col s12">- {{ bulk_action_form.action|materializecss:"inline s4" }}- <input type="submit" class="btn-flat bulk-submit" value="{% trans "Apply" context "Dashboard form submit input" %}" />- </div>+ <form method="POST"+ action="{% url "dashboard:product-bulk-update" %}"+ novalidate+ id="bulk-actions-form">+ {% csrf_token %}+ <input name="action" type="hidden" id="bulk-action" />+ <nav class="data-table-header-alternative single">+ <div class="bulk-info show-bulk">+ <div class="data-table-header-action-selected-items col inline"></div></div>- <div class="row">- <div class="col s12">- <div class="data-table-header-action-selected-items col inline"></div>- </div>+ <div class="bulk-actions show-bulk nav-wrapper">+ <ul class="right">+ {% for action, label in bulk_action_form.action.field.widget.choices %}+ <li>+ <a href="" data-action="{{ action }}">{{ label }}</a>+ </li>+ {% endfor %}+ </ul></div>- </div>+ </nav><div class="data-table-container"><table class="bordered highlight responsive data-table"><thead>