Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Refactor misc code to ES6 style
dominik-zeglenb4ad3f683ec2
diff --git a/saleor/static/dashboard/js/components/misc.js b/saleor/static/dashboard/js/components/misc.jsindex a353d4caf8..9626901ede 100644--- a/saleor/static/dashboard/js/components/misc.js+++ b/saleor/static/dashboard/js/components/misc.js@@ -2,46 +2,54 @@ import SVGInjector from 'svg-injector-2';import { initSelects } from './utils';-export default $(document).ready((e) => {- new SVGInjector().inject(document.querySelectorAll('svg[data-src]'));-- initSelects();- $('.modal').modal();-- // Print button- $('.btn-print').click((e) => {- window.print();- });-- // Clickable rows in dashboard tables- $(document).on('click', 'tr[data-action-go]>td:not(.ignore-link)', function () {- let target = $(this).parent();- window.location.href = target.data('action-go');- });-- $('#product-is-published').on('click', (e) => {- const form = $(e.currentTarget).closest('#toggle-publish-form');- const input = form.find('#toggle-publish-switch')[0];- if (e.target === input) {- const url = form.attr('action');- fetch(url, {- method: 'POST',- credentials: 'same-origin',- headers: {- 'X-CSRFToken': $('[name=csrfmiddlewaretoken]').val()- }- }).then((r) => {- return r.json();- }).then((r) => {- window.location.reload();- });- }- return 1;- });-});--export const screenSizes = {+const screenSizes = {sm: 600,md: 992,lg: 1200};++// -----++// SVG Injector+new SVGInjector().inject(document.querySelectorAll('svg[data-src]'));++// Custom select inputs+initSelects();++// Materialize modals+$('.modal').modal();++// Print button+$('.btn-print').click((e) => {+ window.print();+});++// Clickable rows in dashboard tables+$(document).on('click', 'tr[data-action-go]>td:not(.ignore-link)', (e) => {+ const $targetElement = $(e.currentTarget).parent();+ window.location.href = $targetElement.data('action-go');+});++// Publish / unpublish lever in product detail view+$('#product-is-published').on('click', (e) => {+ const form = $(e.currentTarget).closest('#toggle-publish-form');+ const input = form.find('#toggle-publish-switch')[0];+ if (e.target === input) {+ const url = form.attr('action');+ fetch(url, {+ method: 'POST',+ credentials: 'same-origin',+ headers: {+ 'X-CSRFToken': $('[name=csrfmiddlewaretoken]').val()+ }+ }).then(() => {+ window.location.reload();+ }).catch(() => {+ window.location.reload();+ })+ }+});++export {+ screenSizes+};