-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: multipleChoiceList first iteration
- Loading branch information
vvo
committed
Sep 2, 2015
1 parent
63b4b50
commit bc91bfb
Showing
8 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var React = require('react'); | ||
|
||
var Template = require('../Template/'); | ||
|
||
class MultipleChoiceList extends React.Component { | ||
render() { | ||
var facetValues = this.props.facetValues; | ||
var template = this.props.template; | ||
|
||
return ( | ||
<ul> | ||
{facetValues.map(function(facetValue) { | ||
return <Template key={facetValue.name} data={facetValue} template={template} />; | ||
})} | ||
</ul> | ||
); | ||
} | ||
} | ||
|
||
MultipleChoiceList.propTypes = { | ||
facetValues: React.PropTypes.array, | ||
template: React.PropTypes.oneOfType([ | ||
React.PropTypes.string, | ||
React.PropTypes.func | ||
]).isRequired, | ||
toggleRefine: React.PropTypes.fn | ||
}; | ||
|
||
module.exports = MultipleChoiceList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var React = require('react'); | ||
|
||
var utils = require('../../lib/widgetUtils.js'); | ||
var defaultTemplate = require('./template.html'); | ||
|
||
function multipleChoiceList({container = null, facetName = null, template = defaultTemplate}) { | ||
var MultipleChoiceList = require('../../components/MultipleChoiceList'); | ||
var containerNode = utils.getContainerNode(container); | ||
|
||
if (container === null || facetName === null) { | ||
throw new Error('Usage: multipleChoiceList({container, facetName[, template]})'); | ||
} | ||
|
||
return { | ||
getConfiguration: () => ({disjunctiveFacets: [facetName]}), | ||
render: function(results, state, helper) { | ||
React.render( | ||
<MultipleChoiceList | ||
facetValues={results.getFacetValues(facetName, {sortBy: ['name:asc']})} | ||
toggleRefine={helper.toggleRefine.bind(helper, facetName)} | ||
template={template} | ||
/>, | ||
containerNode | ||
); | ||
} | ||
}; | ||
} | ||
|
||
module.exports = multipleChoiceList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<label><input type="checkbox" value="{{name}}" {{#selected}}checked{{/selected}} />{{name}} <span>{{count}}</span></label> |