56 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-04-11 17:35:40 +02:00
/**
*
* LimitSelect
*
*/
import React from 'react';
import PropTypes from 'prop-types';
2017-09-18 18:06:43 +02:00
import { FormattedMessage } from 'react-intl';
import { map } from 'lodash';
import styles from './styles.scss';
2017-06-28 22:01:42 +02:00
2017-05-11 10:54:44 +02:00
class LimitSelect extends React.Component {
2017-04-11 18:30:57 +02:00
componentWillMount() {
const id = _.uniqueId();
this.setState({ id });
}
2017-04-11 18:37:09 +02:00
/**
* Return the list of default values to populate the select options
*
* @returns {number[]}
*/
2017-04-11 17:35:40 +02:00
getOptionsValues() {
2017-04-11 18:37:09 +02:00
return [10, 20, 50, 100];
2017-04-11 17:35:40 +02:00
}
render() {
2017-09-18 18:06:43 +02:00
return (
<form className="form-inline">
<div className={styles.selectWrapper}>
<select
onChange={this.props.handleChange}
className={`form-control ${styles.select}`}
id={this.state.id}
value={this.props.limit}
>
{map(this.getOptionsValues(), (optionValue, key) => <option value={optionValue} key={key}>{optionValue}</option>)}
</select>
</div>
<label className={styles.label} htmlFor={this.state.id}>
<FormattedMessage id="content-manager.components.LimitSelect.itemsPerPage" />
</label>
</form>
);
2017-04-11 17:35:40 +02:00
}
}
2017-04-11 19:20:33 +02:00
LimitSelect.propTypes = {
2017-09-18 18:06:43 +02:00
handleChange: PropTypes.func.isRequired,
limit: PropTypes.number.isRequired,
2017-04-11 19:20:33 +02:00
};
2017-04-11 17:35:40 +02:00
export default LimitSelect;