2019-08-14 17:23:12 -04:00
import React , { Fragment } from 'react' ;
2019-08-14 14:33:26 -04:00
2019-12-03 13:17:04 -05:00
import InfoBox from '../../components/info-box' ;
2021-02-22 01:59:24 -05:00
import { dataFields } from '../../config/data-fields-config' ;
2019-12-03 13:17:04 -05:00
import DataEntry from '../data-components/data-entry' ;
2021-03-15 15:32:10 -04:00
import { MultiDataEntry } from '../data-components/multi-data-entry/multi-data-entry' ;
2022-04-29 06:09:25 -04:00
import SelectDataEntry from '../data-components/select-data-entry' ;
import TextboxDataEntry from '../data-components/textbox-data-entry' ;
2019-08-14 16:54:00 -04:00
import withCopyEdit from '../data-container' ;
2019-11-07 02:39:26 -05:00
2019-10-18 10:06:50 -04:00
import { CategoryViewProps } from './category-view-props' ;
2020-08-04 12:16:57 -04:00
import Verification from '../data-components/verification' ;
2019-08-14 14:33:26 -04:00
/ * *
* Use view / edit section
* /
2022-05-12 11:30:55 -04:00
const UseView : React.FunctionComponent < CategoryViewProps > = ( props ) = > {
if ( props . building . current_landuse_source == "Expert/personal knowledge of building" ||
props . building . current_landuse_source == "Online streetview image" ||
props . building . current_landuse_source == null
) {
return (
< Fragment >
< InfoBox msg = "93% of properties in UK are dwellings so we have set this as the default colour. Can you help us colour-in all non-residential and mixed use buildings, and verify residential buildings too?" > < / InfoBox >
< MultiDataEntry
title = { dataFields . current_landuse_group . title }
slug = "current_landuse_group"
value = { props . building . current_landuse_group }
mode = { props . mode }
copy = { props . copy }
onChange = { props . onChange }
confirmOnEnter = { true }
tooltip = { dataFields . current_landuse_group . tooltip }
placeholder = "Type new land use group here"
copyable = { true }
autofill = { true }
showAllOptionsOnEmpty = { true }
/ >
< Verification
slug = "current_landuse_group"
allow_verify = { props . user !== undefined && props . building . current_landuse_group !== null && ! props . edited }
onVerify = { props . onVerify }
user_verified = { props . user_verified . hasOwnProperty ( "current_landuse_group" ) }
user_verified_as = { props . user_verified . current_landuse_group && props . user_verified . current_landuse_group . join ( ", " ) }
verified_count = { props . building . verified . current_landuse_group }
/ >
{
props . mode != 'view' &&
< InfoBox msg = "Land use order, shown below, is automatically derived from the land use groups" > < / InfoBox >
}
< DataEntry
title = { dataFields . current_landuse_order . title }
tooltip = { dataFields . current_landuse_order . tooltip }
slug = "current_landuse_order"
value = { props . building . current_landuse_order }
mode = { props . mode }
disabled = { true }
copy = { props . copy }
onChange = { props . onChange }
/ >
< SelectDataEntry
title = { dataFields . current_landuse_source . title }
slug = "current_landuse_source"
value = { props . building . current_landuse_source }
mode = { props . mode }
copy = { props . copy }
onChange = { props . onChange }
tooltip = { dataFields . current_landuse_source . tooltip }
2022-06-01 05:05:53 -04:00
placeholder = { dataFields . current_landuse_source . example }
2022-05-12 11:30:55 -04:00
options = { dataFields . current_landuse_source . items }
/ >
2022-05-19 06:18:17 -04:00
< Verification
slug = "current_landuse_source"
allow_verify = { props . user !== undefined && props . building . current_landuse_source !== null && ! props . edited }
onVerify = { props . onVerify }
user_verified = { props . user_verified . hasOwnProperty ( "current_landuse_source" ) }
2022-05-19 06:32:31 -04:00
user_verified_as = { props . user_verified . current_landuse_source }
2022-05-19 06:18:17 -04:00
verified_count = { props . building . verified . current_landuse_source }
/ >
2022-05-12 11:30:55 -04:00
< / Fragment >
) ;
} ;
return (
< Fragment >
< InfoBox msg = "93% of properties in UK are dwellings so we have set this as the default colour. Can you help us colour-in all non-residential and mixed use buildings, and verify residential buildings too?" > < / InfoBox >
< MultiDataEntry
title = { dataFields . current_landuse_group . title }
slug = "current_landuse_group"
value = { props . building . current_landuse_group }
mode = { props . mode }
copy = { props . copy }
onChange = { props . onChange }
confirmOnEnter = { true }
tooltip = { dataFields . current_landuse_group . tooltip }
placeholder = "Type new land use group here"
copyable = { true }
autofill = { true }
showAllOptionsOnEmpty = { true }
2020-08-04 12:16:57 -04:00
/ >
2022-05-12 11:30:55 -04:00
< Verification
slug = "current_landuse_group"
allow_verify = { props . user !== undefined && props . building . current_landuse_group !== null && ! props . edited }
onVerify = { props . onVerify }
user_verified = { props . user_verified . hasOwnProperty ( "current_landuse_group" ) }
user_verified_as = { props . user_verified . current_landuse_group && props . user_verified . current_landuse_group . join ( ", " ) }
verified_count = { props . building . verified . current_landuse_group }
/ >
{
props . mode != 'view' &&
< InfoBox msg = "Land use order, shown below, is automatically derived from the land use groups" > < / InfoBox >
}
< DataEntry
title = { dataFields . current_landuse_order . title }
tooltip = { dataFields . current_landuse_order . tooltip }
slug = "current_landuse_order"
value = { props . building . current_landuse_order }
mode = { props . mode }
disabled = { true }
copy = { props . copy }
onChange = { props . onChange }
2022-04-29 05:57:37 -04:00
/ >
2022-05-12 11:30:55 -04:00
< SelectDataEntry
title = { dataFields . current_landuse_source . title }
slug = "current_landuse_source"
value = { props . building . current_landuse_source }
mode = { props . mode }
copy = { props . copy }
onChange = { props . onChange }
tooltip = { dataFields . current_landuse_source . tooltip }
2022-06-01 05:05:53 -04:00
placeholder = { dataFields . current_landuse_source . example }
2022-05-12 11:30:55 -04:00
options = { dataFields . current_landuse_source . items }
/ >
2022-05-19 06:34:56 -04:00
< Verification
slug = "current_landuse_source"
allow_verify = { props . user !== undefined && props . building . current_landuse_source !== null && ! props . edited }
onVerify = { props . onVerify }
user_verified = { props . user_verified . hasOwnProperty ( "current_landuse_source" ) }
user_verified_as = { props . user_verified . current_landuse_source }
verified_count = { props . building . verified . current_landuse_source }
/ >
2022-05-12 11:30:55 -04:00
< MultiDataEntry
title = { dataFields . current_landuse_link . title }
slug = "current_landuse_link"
value = { props . building . current_landuse_link }
mode = { props . mode }
copy = { props . copy }
onChange = { props . onChange }
tooltip = { dataFields . current_landuse_link . tooltip }
placeholder = "https://..."
editableEntries = { true }
/ >
2022-05-19 06:37:06 -04:00
< Verification
slug = "current_landuse_link"
allow_verify = { props . user !== undefined && props . building . current_landuse_link !== null && ! props . edited }
onVerify = { props . onVerify }
user_verified = { props . user_verified . hasOwnProperty ( "current_landuse_link" ) }
user_verified_as = { props . user_verified . current_landuse_link }
verified_count = { props . building . verified . current_landuse_link }
/ >
2022-05-12 11:30:55 -04:00
< / Fragment >
) ;
} ;
2019-08-14 14:33:26 -04:00
const UseContainer = withCopyEdit ( UseView ) ;
export default UseContainer ;