1
0
mirror of https://github.com/ascribe/onion.git synced 2024-06-30 21:52:08 +02:00
onion/js/components/ascribe_piece_list_toolbar/piece_list_toolbar.js

66 lines
2.4 KiB
JavaScript
Raw Normal View History

'use strict';
2015-06-02 10:10:09 +02:00
import React from 'react';
2015-08-04 10:06:02 +02:00
import PieceListToolbarFilterWidget from './piece_list_toolbar_filter_widget';
2015-06-02 10:10:09 +02:00
import Input from 'react-bootstrap/lib/Input';
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
2015-07-03 19:08:56 +02:00
import { getLangText } from '../../utils/lang_utils';
2015-06-02 11:40:55 +02:00
2015-06-02 10:10:09 +02:00
let PieceListToolbar = React.createClass({
propTypes: {
2015-06-16 09:27:04 +02:00
className: React.PropTypes.string,
2015-07-14 21:13:15 +02:00
searchFor: React.PropTypes.func,
2015-08-06 13:15:52 +02:00
filterBy: React.PropTypes.object,
applyFilterBy: React.PropTypes.func,
2015-07-14 21:13:15 +02:00
children: React.PropTypes.oneOfType([
React.PropTypes.arrayOf(React.PropTypes.element),
React.PropTypes.element
])
},
2015-06-02 10:10:09 +02:00
searchFor() {
let searchTerm = this.refs.search.getInputDOMNode().value;
2015-06-16 09:27:04 +02:00
this.props.searchFor(searchTerm);
2015-06-02 10:10:09 +02:00
},
render() {
2015-07-01 19:05:47 +02:00
let searchIcon = <Glyphicon glyph='search' className="filter-glyph"/>;
2015-06-02 10:10:09 +02:00
return (
<div className={this.props.className}>
<div className="row">
2015-07-07 10:28:39 +02:00
<div className="col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2">
2015-06-02 10:10:09 +02:00
<div className="row">
2015-07-14 21:13:15 +02:00
<span className="pull-left">
{this.props.children}
</span>
2015-07-07 10:28:39 +02:00
<span className="pull-right search-bar">
<Input
type='text'
ref="search"
2015-07-03 19:08:56 +02:00
placeholder={getLangText('Search%s', '...')}
2015-07-07 10:28:39 +02:00
onChange={this.searchFor}
addonAfter={searchIcon} />
</span>
2015-08-04 10:06:02 +02:00
<span className="pull-right">
<PieceListToolbarFilterWidget
2015-08-04 15:39:20 +02:00
filterParams={['acl_transfer', 'acl_consign', {
2015-08-05 16:02:48 +02:00
key: 'acl_create_editions',
2015-08-04 15:39:20 +02:00
label: 'create editions'
2015-08-06 13:15:52 +02:00
}]}
filterBy={this.props.filterBy}
applyFilterBy={this.props.applyFilterBy}/>
2015-08-04 10:06:02 +02:00
</span>
2015-06-02 10:10:09 +02:00
</div>
</div>
</div>
</div>
);
}
});
2015-07-03 19:08:56 +02:00
export default PieceListToolbar;