From fb10d9329ba98086c9428b2c2b8208420ef1c752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Daubensch=C3=BCtz?= Date: Tue, 4 Aug 2015 15:39:20 +0200 Subject: [PATCH] add labels for filter params --- .../piece_list_toolbar.js | 5 +++- .../piece_list_toolbar_filter_widget.js | 25 ++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js index 6f206c36..161cb929 100644 --- a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js +++ b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js @@ -45,7 +45,10 @@ let PieceListToolbar = React.createClass({ + filterParams={['acl_transfer', 'acl_consign', { + key: 'acl_editions', + label: 'create editions' + }]} /> diff --git a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar_filter_widget.js b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar_filter_widget.js index 3bd893c2..dc77469f 100644 --- a/js/components/ascribe_piece_list_toolbar/piece_list_toolbar_filter_widget.js +++ b/js/components/ascribe_piece_list_toolbar/piece_list_toolbar_filter_widget.js @@ -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: , + // label: + // } + // + filterParams: React.PropTypes.arrayOf(React.PropTypes.any).isRequired }, getInitialState() { @@ -94,14 +101,24 @@ let PieceListToolbarFilterWidgetFilter = React.createClass({ {getLangText('Show works that')}: {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 (
- - {getLangText('I can') + ' ' + getLangText(name)} + + {getLangText('I can') + ' ' + getLangText(label)}