Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Fix losing sorting status

dominik-zeglen0324afdb1563
diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.js
index 65846be2aa..2b7906d34b 100644
--- a/saleor/static/js/storefront.js
+++ b/saleor/static/js/storefront.js
@@ -16,7 +16,7 @@ import ProductSchema from './components/variantPicker/ProductSchema';
let csrftoken = $.cookie('csrftoken');
-function csrfSafeMethod (method) {
+function csrfSafeMethod(method) {
return /^(GET|HEAD|OPTIONS|TRACE)$/.test(method);
}
@@ -54,8 +54,8 @@ $(document).ready((e) => {
if (windowWidth < 767) {
$mobileNav.append('<ul class="nav navbar-nav navbar__menu__login"></ul>');
$('.navbar__login a').appendTo('.navbar__menu__login')
- .wrap('<li class="nav-item login-item"></li>')
- .addClass('nav-link');
+ .wrap('<li class="nav-item login-item"></li>')
+ .addClass('nav-link');
}
$toogleIcon.click((e) => {
@@ -106,7 +106,7 @@ if ($initialValue) {
// Smart address form
-$(function() {
+$(function () {
const $i18nAddresses = $('.i18n-address');
$i18nAddresses.each(function () {
const $form = $(this).closest('form');
@@ -125,7 +125,7 @@ $(document).ready((e) => {
$('.sort-by button').on('click', (e) => {
const t = $(e.currentTarget).parent();
const l = t.find('.sort-list');
- if(l.hasClass('d-none')) {
+ if (l.hasClass('d-none')) {
l.removeClass('d-none');
t.find('.click-area').removeClass('d-none');
} else {
@@ -144,7 +144,7 @@ $(document).ready((e) => {
$(document).ready((e) => {
$('.filters-menu').on('click', (e) => {
const t = $('.filters-menu__body');
- if(t.hasClass('d-none')) {
+ if (t.hasClass('d-none')) {
t.removeClass('d-none');
} else {
t.addClass('d-none');
@@ -155,15 +155,15 @@ $(document).ready((e) => {
// Input Passwords
let $inputPassword = $('input[type=password]');
-$("<img class='passIcon' src="+passwordIvisible+" />").insertAfter($inputPassword);
+$("<img class='passIcon' src=" + passwordIvisible + " />").insertAfter($inputPassword);
$inputPassword.parent().addClass('relative');
$('.passIcon').on('click', (e) => {
let $input = $(e.target).parent().find('input');
if ($input.attr('type') == 'password') {
- $input.attr('type','text');
+ $input.attr('type', 'text');
$(e.target).attr('src', passwordVisible);
} else {
- $input.attr('type','password');
+ $input.attr('type', 'password');
$(e.target).attr('src', passwordIvisible);
}
});
@@ -286,7 +286,7 @@ if (variantPickerContainer) {
// Product Schema
const productSchemaContainer = document.getElementById('product-schema-component');
if (productSchemaContainer) {
- let productSchema = JSON.parse(document.getElementById('product-schema-component').children[0].text)
+ let productSchema = JSON.parse(document.getElementById('product-schema-component').children[0].text);
ReactDOM.render(
<ProductSchema
variantStore={variantPickerStore}
@@ -303,20 +303,19 @@ let $deleteAdressIcons = $('.icons');
let $deleteAdressIcon = $('.delete-icon');
let $deleteAddress = $('.address-delete');
- $deleteAdressIcon.on('click', (e) => {
+$deleteAdressIcon.on('click', (e) => {
if ($deleteAddress.hasClass('none')) {
$deleteAddress.removeClass('none');
$deleteAdressIcons.addClass('none');
} else {
$deleteAddress.addClass('none');
}
- });
+});
- $deleteAddress.find('.cancel').on('click', (e) => {
+$deleteAddress.find('.cancel').on('click', (e) => {
$deleteAddress.addClass('none');
$deleteAdressIcons.removeClass('none');
- });
-
+});
// Cart quantity form
@@ -326,7 +325,7 @@ let $total = $('.cart-subtotal');
let $cartBadge = $('.navbar__brand__cart .badge');
let $removeProductSucces = $('.remove-product-alert');
let $closeMsg = $('.close-msg');
-$cartLine.each(function() {
+$cartLine.each(function () {
let $quantityInput = $(this).find('#id_quantity');
let cartFormUrl = $(this).find('.form-cart').attr('action');
let $qunatityError = $(this).find('.cart__line__quantity-error');
@@ -341,7 +340,7 @@ $cartLine.each(function() {
success: (response) => {
if (newQuantity == 0) {
if (response.cart.numLines == 0) {
- $.cookie('alert', 'true', { path: '/cart' });
+ $.cookie('alert', 'true', {path: '/cart'});
location.reload();
} else {
$removeProductSucces.removeClass('hidden-xs-up');
@@ -373,7 +372,7 @@ $cartLine.each(function() {
$cartDropdown.load(summaryLink);
$removeProductSucces.removeClass('hidden-xs-up');
} else {
- $.cookie('alert', 'true', { path: '/cart' });
+ $.cookie('alert', 'true', {path: '/cart'});
location.reload();
}
deliveryAjax();
@@ -384,7 +383,7 @@ $cartLine.each(function() {
// StyleGuide fixed menu
-$(document).ready(function() {
+$(document).ready(function () {
let styleGuideMenu = $('.styleguide__nav');
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
@@ -392,12 +391,12 @@ $(document).ready(function() {
} else {
styleGuideMenu.removeClass("fixed");
}
- })
+ });
});
if ($.cookie('alert') === 'true') {
$removeProductSucces.removeClass('hidden-xs-up');
- $.cookie('alert', 'false', { path: '/cart' });
+ $.cookie('alert', 'false', {path: '/cart'});
}
$closeMsg.on('click', (e) => {
@@ -405,7 +404,7 @@ $closeMsg.on('click', (e) => {
});
-$('.toggle-filter').each(function() {
+$('.toggle-filter').each(function () {
let icon = $(this).find('.collapse-filters-icon');
let ele = $(this).find('.filter-form-field');
@@ -421,4 +420,4 @@ $('.toggle-filter').each(function() {
icon.find('img').attr('src', filterArrowUp);
}
});
-})
+});
diff --git a/templates/category/index.html b/templates/category/index.html
index 869403a4f5..d324525b15 100644
--- a/templates/category/index.html
+++ b/templates/category/index.html
@@ -171,6 +171,7 @@
<input id="price_0" name="price_0" type="number" min="0" class="form-control"
placeholder="from"><span>-</span><input id="price_1" name="price_1" type="number" min="0"
class="form-control" placeholder="to">
+ <input type="hidden" name="sort_by" value="{{ request.GET.sort_by }}">
<button class="btn primary" type="submit">Update</button>
</div>
</div>