'use strict'; import React from 'react'; import DropdownButton from 'react-bootstrap/lib/DropdownButton'; import { getLangText } from '../../utils/lang_utils.js'; let PieceListToolbarOrderWidget = React.createClass({ propTypes: { // An array of either strings (which represent acl enums) or objects of the form // // { // key: , // label: // } orderParams: React.PropTypes.arrayOf(React.PropTypes.any).isRequired, orderBy: React.PropTypes.string, applyOrderBy: React.PropTypes.func }, generateOrderByStatement(param) { let orderBy = this.props.orderBy; return orderBy; }, /** * We need overloading here to find the correct parameter of the label * the user is clicking on. */ orderBy(orderBy) { return () => { this.props.applyOrderBy(orderBy); }; }, isOrderActive() { // We're hiding the star in that complicated matter so that, // the surrounding button is not resized up on appearance if (this.props.orderBy && this.props.orderBy.length) { return { visibility: 'visible'}; } else { return { visibility: 'hidden' }; } }, render() { let orderIcon = ( · ); if (this.props.orderParams && this.props.orderParams.length) { return (
  • {getLangText('Sort by')}:
  • {this.props.orderParams.map((param) => { return (
  • {getLangText(param.replace('_', ' '))} -1} />
  • ); })}
    ); } else { return null; } } }); export default PieceListToolbarOrderWidget;