import React from 'react'; import { Grid, Row, Col } from 'react-bootstrap'; import PopupControl from './popup-control'; import Fa from './fa'; import './year-picker.less'; /** * React component for selecting an year */ export default class YearPicker extends React.Component { constructor(props) { super(props); this.prevClick = this.prevClick.bind(this); this.nextClick = this.nextClick.bind(this); this.selectYear = this.selectYear.bind(this); this.state = { page: 0 }; } componentWillReceiveProps(newProps) { if (newProps.value !== this.props.value) { this.setState({ page: 0 }); } } prevClick(evt) { this.setState({ page: this.state.page - 1 }); evt.preventDefault(); } nextClick(evt) { this.setState({ page: this.state.page + 1 }); evt.preventDefault(); } selectYear(year) { return () => { if (this.props.onChange) { this.props.onChange(year); } }; } renderPopup() { // get the year const props = this.props; let year = props.value ? props.value : (new Date()).getFullYear(); year = (Math.floor(year / 20) * 20); year -= this.state.page * 20; const addRow = y => (