2019-08-23 09:09:23 -04:00
|
|
|
import React, { Fragment } from 'react';
|
2019-08-14 14:33:26 -04:00
|
|
|
|
2021-02-22 01:59:24 -05:00
|
|
|
import { dataFields } from '../../config/data-fields-config';
|
2021-03-15 15:32:10 -04:00
|
|
|
import { MultiDataEntry } from '../data-components/multi-data-entry/multi-data-entry';
|
2019-08-23 12:35:17 -04:00
|
|
|
import NumericDataEntry from '../data-components/numeric-data-entry';
|
|
|
|
import SelectDataEntry from '../data-components/select-data-entry';
|
|
|
|
import TextboxDataEntry from '../data-components/textbox-data-entry';
|
2020-08-04 10:54:49 -04:00
|
|
|
import Verification from '../data-components/verification';
|
2019-08-23 12:35:17 -04:00
|
|
|
import YearDataEntry from '../data-components/year-data-entry';
|
2019-11-07 02:39:26 -05:00
|
|
|
import withCopyEdit from '../data-container';
|
|
|
|
|
2019-10-18 10:06:50 -04:00
|
|
|
import { CategoryViewProps } from './category-view-props';
|
2019-08-14 14:33:26 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Age view/edit section
|
|
|
|
*/
|
2019-11-28 07:22:10 -05:00
|
|
|
const AgeView: React.FunctionComponent<CategoryViewProps> = (props) => {
|
|
|
|
const currentYear = new Date().getFullYear();
|
2022-05-12 11:13:06 -04:00
|
|
|
if (props.building.date_source == "Expert knowledge of building" ||
|
|
|
|
props.building.date_source == "Expert estimate from image" ||
|
2022-05-12 11:17:57 -04:00
|
|
|
props.building.date_source == null
|
2022-05-12 11:13:06 -04:00
|
|
|
){
|
2022-05-12 10:48:19 -04:00
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<YearDataEntry
|
|
|
|
year={props.building.date_year}
|
|
|
|
upper={props.building.date_upper}
|
|
|
|
lower={props.building.date_lower}
|
|
|
|
mode={props.mode}
|
|
|
|
copy={props.copy}
|
|
|
|
onChange={props.onChange}
|
2022-05-19 05:40:12 -04:00
|
|
|
|
2022-05-19 05:20:18 -04:00
|
|
|
allow_verify={props.user !== undefined && props.building.date_year !== null && !props.edited}
|
|
|
|
onVerify={props.onVerify}
|
|
|
|
user_verified={props.user_verified.hasOwnProperty("date_year")}
|
|
|
|
user_verified_as={props.user_verified.date_year}
|
|
|
|
verified_count={props.building.verified.date_year}
|
2022-05-19 06:01:26 -04:00
|
|
|
|
|
|
|
allow_verify_upper={props.user !== undefined && props.building.date_upper !== null && !props.edited}
|
|
|
|
onVerify_upper={props.onVerify}
|
|
|
|
user_verified_upper={props.user_verified.hasOwnProperty("date_upper")}
|
|
|
|
user_verified_as_upper={props.user_verified.date_upper}
|
|
|
|
verified_count_upper={props.building.verified.date_upper}
|
|
|
|
|
|
|
|
allow_verify_lower={props.user !== undefined && props.building.date_lower !== null && !props.edited}
|
|
|
|
onVerify_lower={props.onVerify}
|
|
|
|
user_verified_lower={props.user_verified.hasOwnProperty("date_lower")}
|
|
|
|
user_verified_as_lower={props.user_verified.date_lower}
|
|
|
|
verified_count_lower={props.building.verified.date_lower}
|
2022-05-19 05:35:13 -04:00
|
|
|
/>
|
2022-05-12 10:48:19 -04:00
|
|
|
<NumericDataEntry
|
|
|
|
title={dataFields.facade_year.title}
|
|
|
|
slug="facade_year"
|
|
|
|
value={props.building.facade_year}
|
|
|
|
mode={props.mode}
|
|
|
|
copy={props.copy}
|
|
|
|
onChange={props.onChange}
|
|
|
|
step={1}
|
|
|
|
min={1}
|
|
|
|
max={currentYear}
|
|
|
|
tooltip={dataFields.facade_year.tooltip}
|
|
|
|
/>
|
|
|
|
<Verification
|
|
|
|
slug="facade_year"
|
|
|
|
allow_verify={props.user !== undefined && props.building.facade_year !== null && !props.edited}
|
|
|
|
onVerify={props.onVerify}
|
|
|
|
user_verified={props.user_verified.hasOwnProperty("facade_year")}
|
|
|
|
user_verified_as={props.user_verified.facade_year}
|
|
|
|
verified_count={props.building.verified.facade_year}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<SelectDataEntry
|
|
|
|
title={dataFields.date_source.title}
|
|
|
|
slug="date_source"
|
|
|
|
value={props.building.date_source}
|
|
|
|
mode={props.mode}
|
|
|
|
copy={props.copy}
|
|
|
|
onChange={props.onChange}
|
|
|
|
tooltip={dataFields.date_source.tooltip}
|
2022-05-12 11:36:14 -04:00
|
|
|
placeholder={dataFields.date_source.example}
|
2022-05-12 10:48:19 -04:00
|
|
|
options={dataFields.date_source.items}
|
|
|
|
/>
|
2022-05-13 10:24:13 -04:00
|
|
|
<Verification
|
|
|
|
slug="date_source"
|
|
|
|
allow_verify={props.user !== undefined && props.building.date_source !== null && !props.edited}
|
|
|
|
onVerify={props.onVerify}
|
|
|
|
user_verified={props.user_verified.hasOwnProperty("date_source")}
|
|
|
|
user_verified_as={props.user_verified.date_source}
|
|
|
|
verified_count={props.building.verified.date_source}
|
|
|
|
/>
|
2022-05-12 10:48:19 -04:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
};
|
2019-11-28 07:22:10 -05:00
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<YearDataEntry
|
|
|
|
year={props.building.date_year}
|
|
|
|
upper={props.building.date_upper}
|
|
|
|
lower={props.building.date_lower}
|
|
|
|
mode={props.mode}
|
|
|
|
copy={props.copy}
|
|
|
|
onChange={props.onChange}
|
2022-05-19 05:40:12 -04:00
|
|
|
|
2022-05-19 05:20:18 -04:00
|
|
|
allow_verify={props.user !== undefined && props.building.date_year !== null && !props.edited}
|
|
|
|
onVerify={props.onVerify}
|
|
|
|
user_verified={props.user_verified.hasOwnProperty("date_year")}
|
|
|
|
user_verified_as={props.user_verified.date_year}
|
|
|
|
verified_count={props.building.verified.date_year}
|
2022-05-19 06:00:22 -04:00
|
|
|
|
|
|
|
allow_verify_upper={props.user !== undefined && props.building.date_upper !== null && !props.edited}
|
|
|
|
onVerify_upper={props.onVerify}
|
|
|
|
user_verified_upper={props.user_verified.hasOwnProperty("date_upper")}
|
|
|
|
user_verified_as_upper={props.user_verified.date_upper}
|
|
|
|
verified_count_upper={props.building.verified.date_upper}
|
|
|
|
|
|
|
|
allow_verify_lower={props.user !== undefined && props.building.date_lower !== null && !props.edited}
|
|
|
|
onVerify_lower={props.onVerify}
|
|
|
|
user_verified_lower={props.user_verified.hasOwnProperty("date_lower")}
|
|
|
|
user_verified_as_lower={props.user_verified.date_lower}
|
|
|
|
verified_count_lower={props.building.verified.date_lower}
|
2022-05-19 05:35:13 -04:00
|
|
|
/>
|
2019-11-28 07:22:10 -05:00
|
|
|
<NumericDataEntry
|
|
|
|
title={dataFields.facade_year.title}
|
|
|
|
slug="facade_year"
|
|
|
|
value={props.building.facade_year}
|
|
|
|
mode={props.mode}
|
|
|
|
copy={props.copy}
|
|
|
|
onChange={props.onChange}
|
|
|
|
step={1}
|
|
|
|
min={1}
|
|
|
|
max={currentYear}
|
|
|
|
tooltip={dataFields.facade_year.tooltip}
|
|
|
|
/>
|
2020-08-04 10:54:49 -04:00
|
|
|
<Verification
|
|
|
|
slug="facade_year"
|
2020-08-04 14:15:37 -04:00
|
|
|
allow_verify={props.user !== undefined && props.building.facade_year !== null && !props.edited}
|
2020-08-04 10:54:49 -04:00
|
|
|
onVerify={props.onVerify}
|
|
|
|
user_verified={props.user_verified.hasOwnProperty("facade_year")}
|
|
|
|
user_verified_as={props.user_verified.facade_year}
|
|
|
|
verified_count={props.building.verified.facade_year}
|
|
|
|
/>
|
|
|
|
|
2019-11-28 07:22:10 -05:00
|
|
|
<SelectDataEntry
|
|
|
|
title={dataFields.date_source.title}
|
|
|
|
slug="date_source"
|
|
|
|
value={props.building.date_source}
|
|
|
|
mode={props.mode}
|
|
|
|
copy={props.copy}
|
|
|
|
onChange={props.onChange}
|
|
|
|
tooltip={dataFields.date_source.tooltip}
|
2022-05-12 10:17:00 -04:00
|
|
|
options={dataFields.date_source.items}
|
2022-05-12 11:34:16 -04:00
|
|
|
placeholder={dataFields.date_source.example}
|
2019-11-28 07:22:10 -05:00
|
|
|
/>
|
2022-05-13 10:24:13 -04:00
|
|
|
<Verification
|
|
|
|
slug="date_source"
|
|
|
|
allow_verify={props.user !== undefined && props.building.date_source !== null && !props.edited}
|
|
|
|
onVerify={props.onVerify}
|
|
|
|
user_verified={props.user_verified.hasOwnProperty("date_source")}
|
|
|
|
user_verified_as={props.user_verified.date_source}
|
|
|
|
verified_count={props.building.verified.date_source}
|
|
|
|
/>
|
2019-11-28 07:22:10 -05:00
|
|
|
<MultiDataEntry
|
|
|
|
title={dataFields.date_link.title}
|
|
|
|
slug="date_link"
|
|
|
|
value={props.building.date_link}
|
|
|
|
mode={props.mode}
|
|
|
|
copy={props.copy}
|
|
|
|
onChange={props.onChange}
|
|
|
|
tooltip={dataFields.date_link.tooltip}
|
|
|
|
placeholder="https://..."
|
2020-03-19 14:17:56 -04:00
|
|
|
editableEntries={true}
|
2019-11-28 07:22:10 -05:00
|
|
|
/>
|
2022-05-26 09:50:04 -04:00
|
|
|
<Verification
|
|
|
|
slug="date_link"
|
|
|
|
allow_verify={props.user !== undefined && props.building.date_link !== null && !props.edited}
|
|
|
|
onVerify={props.onVerify}
|
|
|
|
user_verified={props.user_verified.hasOwnProperty("date_link")}
|
|
|
|
user_verified_as={props.user_verified.date_link}
|
|
|
|
verified_count={props.building.verified.date_link}
|
|
|
|
/>
|
2019-11-28 07:22:10 -05:00
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
};
|
2019-08-14 14:33:26 -04:00
|
|
|
const AgeContainer = withCopyEdit(AgeView);
|
|
|
|
|
|
|
|
export default AgeContainer;
|