From 8e3557cf2e86f7620d376db01b5c2473d3c00c76 Mon Sep 17 00:00:00 2001 From: Edin Dazdarevic Date: Sun, 29 Mar 2015 16:34:42 +0200 Subject: [PATCH] minor refactoring of filters --- .../components/browsing/appliedFiltersList.js | 21 ++++++++++++ .../app/components/browsing/byCategory.js | 33 +++++-------------- .../browsing/filterCriteriaSelector.js | 28 ++++++++++++++++ 3 files changed, 57 insertions(+), 25 deletions(-) create mode 100644 front-ui/app/components/browsing/appliedFiltersList.js create mode 100644 front-ui/app/components/browsing/filterCriteriaSelector.js diff --git a/front-ui/app/components/browsing/appliedFiltersList.js b/front-ui/app/components/browsing/appliedFiltersList.js new file mode 100644 index 0000000..8639327 --- /dev/null +++ b/front-ui/app/components/browsing/appliedFiltersList.js @@ -0,0 +1,21 @@ +var React = require('react'), + Router = require('react-router'); + +var AppliedFiltersList = React.createClass({ + render : function() { + var self = this; + return (
+ + {this.props.filters.map(function(acf) { + return ( + {acf.name} : {acf.value} + + ) + })} + +
) + + } +}); + +module.exports = AppliedFiltersList; diff --git a/front-ui/app/components/browsing/byCategory.js b/front-ui/app/components/browsing/byCategory.js index fa5541a..92b7148 100644 --- a/front-ui/app/components/browsing/byCategory.js +++ b/front-ui/app/components/browsing/byCategory.js @@ -13,8 +13,11 @@ var React = require('react'), LinkBanner = require('../linkBanner/linkBanner'), Globals = require('../../globals'); +var FilterCriteriaSelector = require('./filterCriteriaSelector'); +var AppliedFiltersList = require('./appliedFiltersList'); + var ByCategory = React.createClass({ - mixins: [Router.State], + mixins: [Router.State], getInitialState: function() { var category = new Category(); var items = new ItemCollection(); @@ -50,11 +53,6 @@ var ByCategory = React.createClass({ }, render: function() { var self = this; - - - - - return (
@@ -66,19 +64,8 @@ var ByCategory = React.createClass({ })} - {this.state.category.get('filter_criterias').map(function(fc) { - return (
- -
{fc.title}
-
    - {fc.filter_criteria_values.map(function(fcv) { - return (
  • - {fcv.filter_text} -
  • ) - })} -
-
) - })} + +
@@ -88,12 +75,8 @@ var ByCategory = React.createClass({

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} - - ) - })} + +
diff --git a/front-ui/app/components/browsing/filterCriteriaSelector.js b/front-ui/app/components/browsing/filterCriteriaSelector.js new file mode 100644 index 0000000..9c2e185 --- /dev/null +++ b/front-ui/app/components/browsing/filterCriteriaSelector.js @@ -0,0 +1,28 @@ +var React = require('react'), + Router = require('react-router'); + +var FilterCriteriaSelector = React.createClass({ + render : function() { + var self = this; + return (
+ + {this.props.filterCriterias.map(function(fc) { + return (
+ +
{fc.title}
+
    + {fc.filter_criteria_values.map(function(fcv) { + return (
  • + {fcv.filter_text} +
  • ) + })} +
+
) + })} + +
) + + } +}); + +module.exports = FilterCriteriaSelector;