2019-08-23 12:35:17 -04:00
|
|
|
import React, { Component, Fragment } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
import NumericDataEntry from './numeric-data-entry';
|
2019-10-24 07:16:23 -04:00
|
|
|
import { dataFields } from '../../data_fields';
|
2019-08-23 12:35:17 -04:00
|
|
|
|
|
|
|
class YearDataEntry extends Component<any, any> { // TODO: add proper types
|
|
|
|
static propTypes = { // TODO: generate propTypes from TS
|
|
|
|
year: PropTypes.number,
|
|
|
|
upper: PropTypes.number,
|
|
|
|
lower: PropTypes.number,
|
|
|
|
mode: PropTypes.string,
|
|
|
|
onChange: PropTypes.func,
|
|
|
|
copy: PropTypes.shape({
|
|
|
|
copying: PropTypes.bool,
|
|
|
|
copyingKey: PropTypes.func,
|
|
|
|
toggleCopyAttribute: PropTypes.func
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
year: props.year,
|
|
|
|
upper: props.upper,
|
|
|
|
lower: props.lower,
|
|
|
|
decade: Math.floor(props.year / 10) * 10,
|
|
|
|
century: Math.floor(props.year / 100) * 100
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO add dropdown for decade, century
|
|
|
|
// TODO roll in first/last year estimate
|
|
|
|
// TODO handle changes internally, reporting out date_year, date_upper, date_lower
|
|
|
|
render() {
|
|
|
|
const props = this.props;
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<NumericDataEntry
|
2019-10-24 07:16:23 -04:00
|
|
|
title={dataFields.date_year.title}
|
2019-08-23 12:35:17 -04:00
|
|
|
slug="date_year"
|
|
|
|
value={props.year}
|
|
|
|
mode={props.mode}
|
|
|
|
copy={props.copy}
|
|
|
|
onChange={props.onChange}
|
|
|
|
// "type": "year_estimator"
|
|
|
|
/>
|
|
|
|
<NumericDataEntry
|
2019-10-24 07:16:23 -04:00
|
|
|
title={dataFields.date_upper.title}
|
2019-08-23 12:35:17 -04:00
|
|
|
slug="date_upper"
|
|
|
|
value={props.upper}
|
|
|
|
mode={props.mode}
|
|
|
|
copy={props.copy}
|
|
|
|
onChange={props.onChange}
|
|
|
|
step={1}
|
2019-10-24 07:16:23 -04:00
|
|
|
tooltip={dataFields.date_upper.tooltip}
|
2019-08-23 12:35:17 -04:00
|
|
|
/>
|
|
|
|
<NumericDataEntry
|
2019-10-24 07:16:23 -04:00
|
|
|
title={dataFields.date_lower.title}
|
2019-08-23 12:35:17 -04:00
|
|
|
slug="date_lower"
|
|
|
|
value={props.lower}
|
|
|
|
mode={props.mode}
|
|
|
|
copy={props.copy}
|
|
|
|
onChange={props.onChange}
|
|
|
|
step={1}
|
2019-10-24 07:16:23 -04:00
|
|
|
tooltip={dataFields.date_lower.tooltip}
|
2019-08-23 12:35:17 -04:00
|
|
|
/>
|
|
|
|
</Fragment>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default YearDataEntry;
|