Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add switch to publish product
Krzysztof Białogłowicz73acb67fcc38
diff --git a/saleor/static/dashboard/js/dashboard.js b/saleor/static/dashboard/js/dashboard.jsindex 17e2678726..98c46acd5c 100644--- a/saleor/static/dashboard/js/dashboard.js+++ b/saleor/static/dashboard/js/dashboard.js@@ -271,7 +271,22 @@ $(document).ready(() => {}});-//Print button$('.btn-print').click((e) => {window.print();});++// Publish product switch+$(document).ready(() => {+ let $publishUrl = $('.switch').data('url');+ let $publishSwitch = $('.switch').find('[type=checkbox]');+ $publishSwitch.on('change', function (e) {+ $.ajax({+ url: $publishUrl,+ method: 'get',+ success: function (response) {+ location.reload();+ }+ });+ e.preventDefault();+ });+});diff --git a/saleor/static/dashboard/scss/components/_form.scss b/saleor/static/dashboard/scss/components/_form.scssindex 5c1f671af1..571cc87cf1 100644--- a/saleor/static/dashboard/scss/components/_form.scss+++ b/saleor/static/dashboard/scss/components/_form.scss@@ -118,9 +118,10 @@.switch {padding-bottom: 20px;- span {- font-size: 1.2rem;- color: $off-black;+ position: relative;+ .label {+ position: absolute;+ top: 3px;}}diff --git a/templates/dashboard/product/product_detail.html b/templates/dashboard/product/product_detail.htmlindex 9f1d0ab5f3..1c3843f5d1 100644--- a/templates/dashboard/product/product_detail.html+++ b/templates/dashboard/product/product_detail.html@@ -121,16 +121,20 @@<div class="col s12"><div class="card"><div class="card-content">- <div class="switch">+ <div class="switch" data-url="{% url 'dashboard:product-publish' product.pk %}"><label>- <input type="checkbox">+ <input type="checkbox" {% if product.is_published %} checked {% endif %}><span class="lever"></span>- <span>Published</span>+ <span class="label">+ {% if product.is_published %}+ {% trans "Published" context "Product field" %}+ {% else %}+ {% trans "Draft" context "Product field" %}+ {% endif %}+ </span></label></div>- <div class="status">- <h5 class="label label-success">{{ product.get_availibility_status }}</h5>- </div>+ <h5 class="label label-success">{{ product.get_availibility_status }}</h5></div></div></div>