diff --git a/front-ui/app/components/browsing/byCategory.js b/front-ui/app/components/browsing/byCategory.js index 2125f05..d6e646c 100644 --- a/front-ui/app/components/browsing/byCategory.js +++ b/front-ui/app/components/browsing/byCategory.js @@ -9,27 +9,28 @@ var React = require('react'), ItemStore = require('../../stores/itemStore'), NavigationStore = require('../../stores/navigationStore'), ItemList = require('../items/itemList'), - NavigationActions = require('../../actions/navigationActions'); + NavigationActions = require('../../actions/navigationActions'), + Globals = require('../../globals'); var ByCategory = React.createClass({ mixins: [Router.State], - getInitialState: function() { - var category = new Category(); - var items = new ItemCollection(); - return { - category: category, - items: items, - filter :{}, - pagination: {} - }; - }, + getInitialState: function() { + var category = new Category(); + var items = new ItemCollection(); + return { + category: category, + items: items, + filter :{}, + pagination: {} + }; + }, filter: {}, onFCClick: function(fc, fcv) { var q = {}; q[fc.field_name] = fcv.filter_value; var section = new Section(this.state.category.get('section')); var category = this.state.category; - + this.filter[fc.field_name] = fcv.filter_value; NavigationActions.goToCategory(category, section, this.filter, 0, this.state.pagination.limit); }, @@ -48,48 +49,48 @@ var ByCategory = React.createClass({ }, render: function() { var self = this; - - return ( -
-
-
{this.state.category.get('name')}
-
Podkategorije
- - {this.state.category.get('filter_criterias').map(function(fc) { - return (
- -
{fc.title}
-
    - {fc.filter_criteria_values.map(function(fcv) { - return (
  • - {fcv.filter_text} -
  • ) - })} -
-
) - })} -
+ return ( +
+
+
{this.state.category.get('name')}
+
Podkategorije
+
    + {(this.state.category.get('sub_categories') || []).map(function(sc) { + return (
  • {sc.name}
  • ) + })} +
+ + {this.state.category.get('filter_criterias').map(function(fc) { + return (
+ +
{fc.title}
+
    + {fc.filter_criteria_values.map(function(fcv) { + return (
  • + {fcv.filter_text} +
  • ) + })} +
+
) + })} +
- +

Kategorija - {this.state.category.get('name')}

Number of items in this category: {this.state.items.length} -
- {this.appliedCategoryFiltersArray().map(function(acf) { - return ( - {acf.name} : {acf.value} - - ) - })} -
+
+ {this.appliedCategoryFiltersArray().map(function(acf) { + return ( + {acf.name} : {acf.value} - -
total count is : {this.state.items.totalCount}
+
) + })} +
+ + +
total count is : {this.state.items.totalCount}
@@ -104,14 +105,13 @@ var ByCategory = React.createClass({ } return filters; }, - componentWillReceiveProps: function() { + update: function() { var categoryId = this.getParams().id; this.filter = this.getQuery(); var offset = this.filter.offset || 0; - var limit = this.filter.limit || 30; + var limit = this.filter.limit || Globals.DefaultPageSize; - this.setState({ filter: this.filter, pagination: { @@ -122,23 +122,11 @@ var ByCategory = React.createClass({ ItemActions.loadByCategory(categoryId, offset, limit, this.filter); CategoryActions.loadCategoryDetails(categoryId); }, + componentWillReceiveProps: function() { + this.update(); + }, componentDidMount: function() { - var categoryId = this.getParams().id; - - this.filter = this.getQuery(); - - var offset = this.filter.offset || 0; - var limit = this.filter.limit || 30; - this.setState({ - filter: this.filter, - pagination: { - offset: offset, - limit: limit - } - }); - - ItemActions.loadByCategory(categoryId, offset, limit, this.getQuery()); - CategoryActions.loadCategoryDetails(categoryId); + this.update(); ItemStore.addChangeListener(this._onChange); CategoryStore.addChangeListener(this._onChange); diff --git a/front-ui/app/globals.js b/front-ui/app/globals.js index 0f18552..ba7875e 100644 --- a/front-ui/app/globals.js +++ b/front-ui/app/globals.js @@ -1,5 +1,6 @@ module.exports = { ApiUrl: 'http://localhost:4567', + DefaultPageSize: 18, FormatCurrency: function(amount_s) { var amount = parseFloat(amount_s); return ( amount.toFixed(2) + " KM" )