Skip to content

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

Changes names to sortBy

Krzysztof Białogłowicze9967a2439c1
diff --git a/saleor/static/js/components/CategoryPage.js b/saleor/static/js/components/CategoryPage.js
index d6263de92f..f60a29a1a4 100644
--- a/saleor/static/js/components/CategoryPage.js
+++ b/saleor/static/js/components/CategoryPage.js
@@ -59,9 +59,9 @@ class CategoryPage extends Component {
});
}
- orderBy = (event) => {
+ sortBy = (event) => {
this.props.relay.setVariables({
- orderBy: event.target.className
+ sortBy: event.target.className
});
}
@@ -88,7 +88,7 @@ class CategoryPage extends Component {
}
persistStateInUrl() {
- const { attributesFilter, count, maxPrice, minPrice, orderBy } = this.props.relay.variables;
+ const { attributesFilter, count, maxPrice, minPrice, sortBy } = this.props.relay.variables;
let urlParams = {};
if (minPrice) {
urlParams['minPrice'] = minPrice;
@@ -99,8 +99,8 @@ class CategoryPage extends Component {
if (count > PAGINATE_BY) {
urlParams['count'] = count;
}
- if (orderBy) {
- urlParams['orderBy'] = orderBy;
+ if (sortBy) {
+ urlParams['sortBy'] = sortBy;
}
attributesFilter.forEach(filter => {
const [ attributeName, valueSlug ] = filter.split(':');
@@ -152,7 +152,7 @@ class CategoryPage extends Component {
<ProductList
onLoadMore={this.incrementProductsCount}
products={category.products}
- orderBy={this.orderBy}
+ sortBy={this.sortBy}
/>
</div>
</div>
@@ -164,11 +164,11 @@ class CategoryPage extends Component {
export default Relay.createContainer(CategoryPage, {
initialVariables: {
- attributesFilter: getAttributesFromQueryString(['count', 'minPrice', 'maxPrice', 'orderBy']),
+ attributesFilter: getAttributesFromQueryString(['count', 'minPrice', 'maxPrice', 'sortBy']),
count: floatOrNull(getVarFromQueryString('count', PAGINATE_BY)),
minPrice: floatOrNull(getVarFromQueryString('minPrice')),
maxPrice: floatOrNull(getVarFromQueryString('maxPrice')),
- orderBy: getVarFromQueryString('orderBy')
+ sortBy: getVarFromQueryString('sortBy')
},
fragments: {
category: () => Relay.QL`
@@ -196,7 +196,7 @@ export default Relay.createContainer(CategoryPage, {
slug
}
}
- products (first: $count, attributes: $attributesFilter, priceGte: $minPrice, priceLte: $maxPrice, orderBy: $orderBy) {
+ products (first: $count, attributes: $attributesFilter, priceGte: $minPrice, priceLte: $maxPrice, orderBy: $sortBy) {
${ProductList.getFragment('products')}
}
}
diff --git a/saleor/static/js/components/ProductList.js b/saleor/static/js/components/ProductList.js
index 9f708b7f83..c64f3ad7f6 100644
--- a/saleor/static/js/components/ProductList.js
+++ b/saleor/static/js/components/ProductList.js
@@ -8,12 +8,12 @@ class ProductList extends Component {
static propTypes = {
onLoadMore: PropTypes.func.isRequired,
- orderBy: PropTypes.func,
+ sortBy: PropTypes.func,
products: PropTypes.object
};
onLoadMore = () => this.props.onLoadMore();
- orderBy = (event) => this.props.orderBy(event);
+ sortBy = (event) => this.props.sortBy(event);
render() {
const { edges, pageInfo: { hasNextPage } } = this.props.products;
@@ -29,13 +29,13 @@ class ProductList extends Component {
<div className="row">
<div className="col-md-6">Name:</div>
<div className="col-md-6">
- <span className="name" onClick={this.orderBy}>ascending</span>
+ <span className="name" onClick={this.sortBy}>ascending</span>
</div>
</div>
<div className="row">
<div className="col-md-6"></div>
<div className="col-md-6">
- <span className="-name" onClick={this.orderBy}>descending</span>
+ <span className="-name" onClick={this.sortBy}>descending</span>
</div>
</div>
</li>
@@ -43,13 +43,13 @@ class ProductList extends Component {
<div className="row">
<div className="col-md-6">Price:</div>
<div className="col-md-6">
- <span className="price" onClick={this.orderBy}>ascending</span>
+ <span className="price" onClick={this.sortBy}>ascending</span>
</div>
</div>
<div className="row">
<div className="col-md-6"></div>
<div className="col-md-6">
- <span className="-price" onClick={this.orderBy}>descending</span>
+ <span className="-price" onClick={this.sortBy}>descending</span>
</div>
</div>
</li>