1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-28 00:28:00 +02: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 className="pull-right">
<PieceListToolbarFilterWidget
filterParams={['acl_transfer', 'acl_consign']} />
filterParams={['acl_transfer', 'acl_consign', {
key: 'acl_editions',
label: 'create editions'
}]} />
</span>
</div>
</div>

View File

@ -12,7 +12,14 @@ import { getLangText } from '../../utils/lang_utils.js';
let PieceListToolbarFilterWidgetFilter = React.createClass({
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() {
@ -94,14 +101,24 @@ let PieceListToolbarFilterWidgetFilter = React.createClass({
<em>{getLangText('Show works that')}:</em>
</li>
{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 (
<MenuItem
key={i}
onClick={this.filterBy(param)}
style={{'textAlign': 'center'}}>
<div className="checkbox-line">
<span onClick={this.filterBy(param)}>
{getLangText('I can') + ' ' + getLangText(name)}
<span>
{getLangText('I can') + ' ' + getLangText(label)}
<input
readOnly
type="checkbox"