Add question whether building is domestic.

This commit is contained in:
Mateusz Konieczny 2023-02-02 12:58:44 +01:00
parent 5bde854045
commit ae0e0bb2b6
8 changed files with 52 additions and 0 deletions

View File

@ -292,6 +292,10 @@ export const buildingAttributesConfig = valueType<DataFieldConfig>()({ /* eslint
sqlCast: 'jsonb',
},
is_domestic: {
edit: true,
verify: true
},
likes_total: {
edit: false,
derivedEdit: true,

View File

@ -43,6 +43,24 @@ const CommunityView: React.FunctionComponent<CategoryViewProps> = (props) => {
<InfoBox>
Can you share your opinion on how well the building works?
</InfoBox>
<LogicalDataEntry
title={dataFields.is_domestic.title}
slug="is_domestic"
value={props.building.is_domestic}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
tooltip={dataFields.is_domestic.tooltip}
/>
<Verification
slug="is_domestic"
allow_verify={props.user !== undefined && props.building.is_domestic !== null && !props.edited}
onVerify={props.onVerify}
user_verified={props.user_verified.hasOwnProperty("is_domestic")}
user_verified_as={props.user_verified.is_domestic}
verified_count={props.building.verified.is_domestic}
/>
{props.building.is_domestic === false ?
<UserOpinionEntry
slug='community_like'
title={buildingUserFields.community_like.title}
@ -54,6 +72,7 @@ const CommunityView: React.FunctionComponent<CategoryViewProps> = (props) => {
copy={props.copy}
/>
: <></>}
<button className={`map-switcher-inline ${props.mapColourScale == "likes" ? "enabled-state" : "disabled-state"} btn btn-outline btn-outline-dark ${darkLightTheme}`} onClick={switchToLikesMapStyle}>
{'Click here to switch map key to this info'}
</button>

View File

@ -5,6 +5,7 @@ import { dataFields } from '../../config/data-fields-config';
import DataEntry from '../data-components/data-entry';
import { MultiDataEntry } from '../data-components/multi-data-entry/multi-data-entry';
import SelectDataEntry from '../data-components/select-data-entry';
import { LogicalDataEntry } from '../data-components/logical-data-entry/logical-data-entry';
import TextboxDataEntry from '../data-components/textbox-data-entry';
import withCopyEdit from '../data-container';
@ -21,6 +22,23 @@ const UseView: React.FunctionComponent<CategoryViewProps> = (props) => {
){
return (
<Fragment>
<LogicalDataEntry
title={dataFields.is_domestic.title}
slug="is_domestic"
value={props.building.is_domestic}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
tooltip={dataFields.is_domestic.tooltip}
/>
<Verification
slug="is_domestic"
allow_verify={props.user !== undefined && props.building.is_domestic !== null && !props.edited}
onVerify={props.onVerify}
user_verified={props.user_verified.hasOwnProperty("is_domestic")}
user_verified_as={props.user_verified.is_domestic}
verified_count={props.building.verified.is_domestic}
/>
<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}

View File

@ -563,6 +563,12 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
//tooltip: ,
},
is_domestic: {
category: Category.Team,
title: "Is the building a home/domestic building?",
tooltip: "",
example: false
},
likes_total: {
category: Category.Community,
title: "Total number of likes",

View File

@ -116,6 +116,8 @@ const LAYER_QUERIES = {
FROM
buildings
WHERE
is_domestic = FALSE
AND
likes_total > 0`,
community_local_significance_total: `
SELECT

View File

@ -54,6 +54,7 @@ COPY (SELECT
planning_in_apa_url,
planning_local_list_url,
planning_historic_area_assessment_url,
is_domestic,
likes_total
FROM buildings)
TO '/tmp/building_attributes.csv'

View File

@ -0,0 +1 @@
ALTER TABLE buildings DROP COLUMN IF EXISTS is_domestic;

View File

@ -0,0 +1 @@
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS is_domestic boolean null;