Merge pull request #523 from mz8i/fix/lat-lon-errors

Fix/lat lon errors
This commit is contained in:
Maciej Ziarkowski 2019-11-28 13:41:30 +01:00 committed by GitHub
commit 572de62944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 99 additions and 70 deletions

View File

@ -27,10 +27,10 @@ const NumericDataEntry: React.FunctionComponent<NumericDataEntryProps> = (props)
type="number" type="number"
id={props.slug} id={props.slug}
name={props.slug} name={props.slug}
value={props.value || ''} value={props.value == undefined ? '' : props.value}
step={props.step || 1} step={props.step == undefined ? 1 : props.step}
max={props.max} max={props.max}
min={props.min || 0} min={props.min}
disabled={props.mode === 'view' || props.disabled} disabled={props.mode === 'view' || props.disabled}
placeholder={props.placeholder} placeholder={props.placeholder}
onChange={e => onChange={e =>

View File

@ -30,6 +30,8 @@ class YearDataEntry extends Component<YearDataEntryProps, any> {
// TODO handle changes internally, reporting out date_year, date_upper, date_lower // TODO handle changes internally, reporting out date_year, date_upper, date_lower
render() { render() {
const props = this.props; const props = this.props;
const currentYear = new Date().getFullYear();
return ( return (
<Fragment> <Fragment>
<NumericDataEntry <NumericDataEntry
@ -39,6 +41,8 @@ class YearDataEntry extends Component<YearDataEntryProps, any> {
mode={props.mode} mode={props.mode}
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
min={1}
max={currentYear}
// "type": "year_estimator" // "type": "year_estimator"
/> />
<NumericDataEntry <NumericDataEntry
@ -49,6 +53,8 @@ class YearDataEntry extends Component<YearDataEntryProps, any> {
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
step={1} step={1}
min={1}
max={currentYear}
tooltip={dataFields.date_upper.tooltip} tooltip={dataFields.date_upper.tooltip}
/> />
<NumericDataEntry <NumericDataEntry
@ -59,6 +65,8 @@ class YearDataEntry extends Component<YearDataEntryProps, any> {
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
step={1} step={1}
min={1}
max={currentYear}
tooltip={dataFields.date_lower.tooltip} tooltip={dataFields.date_lower.tooltip}
/> />
</Fragment> </Fragment>

View File

@ -13,69 +13,75 @@ import { CategoryViewProps } from './category-view-props';
/** /**
* Age view/edit section * Age view/edit section
*/ */
const AgeView: React.FunctionComponent<CategoryViewProps> = (props) => ( const AgeView: React.FunctionComponent<CategoryViewProps> = (props) => {
<Fragment> const currentYear = new Date().getFullYear();
<YearDataEntry
year={props.building.date_year} return (
upper={props.building.date_upper} <Fragment>
lower={props.building.date_lower} <YearDataEntry
mode={props.mode} year={props.building.date_year}
copy={props.copy} upper={props.building.date_upper}
onChange={props.onChange} lower={props.building.date_lower}
/> mode={props.mode}
<NumericDataEntry copy={props.copy}
title={dataFields.facade_year.title} onChange={props.onChange}
slug="facade_year" />
value={props.building.facade_year} <NumericDataEntry
mode={props.mode} title={dataFields.facade_year.title}
copy={props.copy} slug="facade_year"
onChange={props.onChange} value={props.building.facade_year}
step={1} mode={props.mode}
tooltip={dataFields.facade_year.tooltip} copy={props.copy}
/> onChange={props.onChange}
<SelectDataEntry step={1}
title={dataFields.date_source.title} min={1}
slug="date_source" max={currentYear}
value={props.building.date_source} tooltip={dataFields.facade_year.tooltip}
mode={props.mode} />
copy={props.copy} <SelectDataEntry
onChange={props.onChange} title={dataFields.date_source.title}
tooltip={dataFields.date_source.tooltip} slug="date_source"
placeholder="" value={props.building.date_source}
options={[ mode={props.mode}
"Survey of London", copy={props.copy}
"Pevsner Guides", onChange={props.onChange}
"Local history publication", tooltip={dataFields.date_source.tooltip}
"National Heritage List for England", placeholder=""
"Historical map", options={[
"Archive research", "Survey of London",
"Expert knowledge of building", "Pevsner Guides",
"Other book", "Local history publication",
"Other website", "National Heritage List for England",
"Other" "Historical map",
]} "Archive research",
/> "Expert knowledge of building",
<TextboxDataEntry "Other book",
title={dataFields.date_source_detail.title} "Other website",
slug="date_source_detail" "Other"
value={props.building.date_source_detail} ]}
mode={props.mode} />
copy={props.copy} <TextboxDataEntry
onChange={props.onChange} title={dataFields.date_source_detail.title}
tooltip={dataFields.date_source_detail.tooltip} slug="date_source_detail"
/> value={props.building.date_source_detail}
<MultiDataEntry mode={props.mode}
title={dataFields.date_link.title} copy={props.copy}
slug="date_link" onChange={props.onChange}
value={props.building.date_link} tooltip={dataFields.date_source_detail.tooltip}
mode={props.mode} />
copy={props.copy} <MultiDataEntry
onChange={props.onChange} title={dataFields.date_link.title}
tooltip={dataFields.date_link.tooltip} slug="date_link"
placeholder="https://..." value={props.building.date_link}
/> mode={props.mode}
</Fragment> copy={props.copy}
); onChange={props.onChange}
tooltip={dataFields.date_link.tooltip}
placeholder="https://..."
/>
</Fragment>
);
};
const AgeContainer = withCopyEdit(AgeView); const AgeContainer = withCopyEdit(AgeView);
export default AgeContainer; export default AgeContainer;

View File

@ -31,6 +31,7 @@ const LocationView: React.FunctionComponent<CategoryViewProps> = (props) => (
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
step={1} step={1}
min={1}
/> />
<DataEntry <DataEntry
title={dataFields.location_street.title} title={dataFields.location_street.title}
@ -99,8 +100,10 @@ const LocationView: React.FunctionComponent<CategoryViewProps> = (props) => (
value={props.building.location_latitude} value={props.building.location_latitude}
mode={props.mode} mode={props.mode}
copy={props.copy} copy={props.copy}
step={0.0001} step={0.00001}
placeholder="51" min={-90}
max={90}
placeholder="Latitude, e.g. 51.5467"
onChange={props.onChange} onChange={props.onChange}
/> />
<NumericDataEntry <NumericDataEntry
@ -109,8 +112,10 @@ const LocationView: React.FunctionComponent<CategoryViewProps> = (props) => (
value={props.building.location_longitude} value={props.building.location_longitude}
mode={props.mode} mode={props.mode}
copy={props.copy} copy={props.copy}
step={0.0001} step={0.00001}
placeholder="0" min={-180}
max={180}
placeholder="Longitude, e.g. -0.0586"
onChange={props.onChange} onChange={props.onChange}
/> />
</Fragment> </Fragment>

View File

@ -24,6 +24,7 @@ const SizeView: React.FunctionComponent<CategoryViewProps> = (props) => (
tooltip={dataFields.size_storeys_core.tooltip} tooltip={dataFields.size_storeys_core.tooltip}
onChange={props.onChange} onChange={props.onChange}
step={1} step={1}
min={0}
/> />
<NumericDataEntry <NumericDataEntry
title={dataFields.size_storeys_attic.title} title={dataFields.size_storeys_attic.title}
@ -34,6 +35,7 @@ const SizeView: React.FunctionComponent<CategoryViewProps> = (props) => (
tooltip={dataFields.size_storeys_attic.tooltip} tooltip={dataFields.size_storeys_attic.tooltip}
onChange={props.onChange} onChange={props.onChange}
step={1} step={1}
min={0}
/> />
<NumericDataEntry <NumericDataEntry
title={dataFields.size_storeys_basement.title} title={dataFields.size_storeys_basement.title}
@ -44,6 +46,7 @@ const SizeView: React.FunctionComponent<CategoryViewProps> = (props) => (
tooltip={dataFields.size_storeys_basement.tooltip} tooltip={dataFields.size_storeys_basement.tooltip}
onChange={props.onChange} onChange={props.onChange}
step={1} step={1}
min={0}
/> />
</DataEntryGroup> </DataEntryGroup>
<DataEntryGroup name="Height"> <DataEntryGroup name="Height">
@ -55,6 +58,7 @@ const SizeView: React.FunctionComponent<CategoryViewProps> = (props) => (
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
step={0.1} step={0.1}
min={0}
/> />
<NumericDataEntry <NumericDataEntry
title={dataFields.size_height_eaves.title} title={dataFields.size_height_eaves.title}
@ -65,6 +69,7 @@ const SizeView: React.FunctionComponent<CategoryViewProps> = (props) => (
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
step={0.1} step={0.1}
min={0}
/> />
</DataEntryGroup> </DataEntryGroup>
<DataEntryGroup name="Floor area"> <DataEntryGroup name="Floor area">
@ -76,6 +81,7 @@ const SizeView: React.FunctionComponent<CategoryViewProps> = (props) => (
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
step={0.1} step={0.1}
min={0}
/> />
<NumericDataEntry <NumericDataEntry
title={dataFields.size_floor_area_total.title} title={dataFields.size_floor_area_total.title}
@ -85,6 +91,7 @@ const SizeView: React.FunctionComponent<CategoryViewProps> = (props) => (
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
step={0.1} step={0.1}
min={0}
/> />
</DataEntryGroup> </DataEntryGroup>
<NumericDataEntry <NumericDataEntry
@ -95,6 +102,7 @@ const SizeView: React.FunctionComponent<CategoryViewProps> = (props) => (
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
step={0.1} step={0.1}
min={0}
/> />
<NumericDataEntry <NumericDataEntry
title={dataFields.size_plot_area_total.title} title={dataFields.size_plot_area_total.title}
@ -104,6 +112,7 @@ const SizeView: React.FunctionComponent<CategoryViewProps> = (props) => (
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
step={0.1} step={0.1}
min={0}
disabled={true} disabled={true}
/> />
<NumericDataEntry <NumericDataEntry
@ -114,6 +123,7 @@ const SizeView: React.FunctionComponent<CategoryViewProps> = (props) => (
copy={props.copy} copy={props.copy}
onChange={props.onChange} onChange={props.onChange}
step={0.1} step={0.1}
min={0}
disabled={true} disabled={true}
/> />
<SelectDataEntry <SelectDataEntry