Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix publish/unpublish switch
dominik-zeglenc1d4c1be054f
diff --git a/saleor/static/dashboard/js/components/bulk-actions.js b/saleor/static/dashboard/js/components/bulk-actions.jsindex ee28f14627..9e3c09b448 100644--- a/saleor/static/dashboard/js/components/bulk-actions.js+++ b/saleor/static/dashboard/js/components/bulk-actions.js@@ -9,7 +9,12 @@ function updateCounterSelected () {counterText = pgettext('bulk action select label multiple', 'items selected');}- $counterTextNode.html(count ? `${count} ${counterText}` : '');+ $counterTextNode.html(count ? `${count} ${counterText}` : counterText);+ if (!count) {+ $counterTextNode.addClass('hide');+ } else {+ $counterTextNode.removeClass('hide');+ }}$(document).ready((e) => {diff --git a/saleor/static/dashboard/js/components/misc.js b/saleor/static/dashboard/js/components/misc.jsindex 103de4a5e1..91098a1c97 100644--- a/saleor/static/dashboard/js/components/misc.js+++ b/saleor/static/dashboard/js/components/misc.js@@ -1,6 +1,6 @@import SVGInjector from 'svg-injector-2';-import {initSelects} from './utils';+import { initSelects } from './utils';export default $(document).ready((e) => {new SVGInjector().inject(document.querySelectorAll('svg[data-src]'));@@ -18,4 +18,22 @@ export default $(document).ready((e) => {let target = $(this).parent();window.location.href = target.data('action-go');});++ $('#product-is-published').on('click', (e) => {+ const input = $(e.currentTarget).find('input')[0];+ if (e.target === input) {+ const url = $(e.currentTarget).attr('data-url');+ fetch(url, {+ credentials: 'same-origin'+ }).then((r) => {+ return r.json();+ }).then((r) => {+ const label = r.is_published ?+ pgettext('Product field', 'Published') :+ pgettext('Product field', 'Draft');+ $(e.currentTarget).find('.label').text(label);+ });+ }+ return 1;+ });});diff --git a/templates/dashboard/product/detail.html b/templates/dashboard/product/detail.htmlindex 98e566ea72..abdf53dc52 100644--- a/templates/dashboard/product/detail.html+++ b/templates/dashboard/product/detail.html@@ -154,7 +154,7 @@<div class="col s12"><div class="card"><div class="card-content">- <div class="switch" data-url="{% url 'dashboard:product-publish' product.pk %}">+ <div class="switch" id="product-is-published" data-url="{% url 'dashboard:product-publish' product.pk %}"><label><input type="checkbox" {% if product.is_published %} checked {% endif %}><span class="lever"></span>