1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

add labels for filter params

This commit is contained in:
Tim Daubenschütz 2015-08-04 15:39:20 +02:00
parent fc0bccbff3
commit fb10d9329b
2 changed files with 25 additions and 5 deletions

View File

@ -45,7 +45,10 @@ let PieceListToolbar = React.createClass({
</span> </span>
<span className="pull-right"> <span className="pull-right">
<PieceListToolbarFilterWidget <PieceListToolbarFilterWidget
filterParams={['acl_transfer', 'acl_consign']} /> filterParams={['acl_transfer', 'acl_consign', {
key: 'acl_editions',
label: 'create editions'
}]} />
</span> </span>
</div> </div>
</div> </div>

View File

@ -12,7 +12,14 @@ import { getLangText } from '../../utils/lang_utils.js';
let PieceListToolbarFilterWidgetFilter = React.createClass({ let PieceListToolbarFilterWidgetFilter = React.createClass({
propTypes: { propTypes: {
filterParams: React.PropTypes.arrayOf(React.PropTypes.string).isRequired // An array of either strings (which represent acl enums) or objects of the form
//
// {
// key: <acl enum>,
// label: <a human readable string>
// }
//
filterParams: React.PropTypes.arrayOf(React.PropTypes.any).isRequired
}, },
getInitialState() { getInitialState() {
@ -94,14 +101,24 @@ let PieceListToolbarFilterWidgetFilter = React.createClass({
<em>{getLangText('Show works that')}:</em> <em>{getLangText('Show works that')}:</em>
</li> </li>
{this.props.filterParams.map((param, i) => { {this.props.filterParams.map((param, i) => {
let name = param.split('_')[1]; let label;
if(typeof param !== 'string') {
label = param.label;
param = param.key;
} else {
param = param;
label = param.split('_')[1];
}
return ( return (
<MenuItem <MenuItem
key={i} key={i}
onClick={this.filterBy(param)}
style={{'textAlign': 'center'}}> style={{'textAlign': 'center'}}>
<div className="checkbox-line"> <div className="checkbox-line">
<span onClick={this.filterBy(param)}> <span>
{getLangText('I can') + ' ' + getLangText(name)} {getLangText('I can') + ' ' + getLangText(label)}
<input <input
readOnly readOnly
type="checkbox" type="checkbox"