From 439e415c6e45ef5c7119574e470ecaa69398e154 Mon Sep 17 00:00:00 2001 From: Mike Simpson Date: Wed, 31 May 2023 21:05:02 +0100 Subject: [PATCH] Changes for #1165 --- app/src/api/config/dataFields.ts | 116 ++++ .../building/data-containers/community.tsx | 11 +- .../building/data-containers/land-use.tsx | 4 +- .../building/data-containers/location.tsx | 511 +++++++++--------- .../building/data-containers/resilience.tsx | 91 ++-- .../building/data-containers/size.tsx | 227 +++++--- .../data-containers/street-context.tsx | 358 ++++++++++-- .../building/data-containers/team.tsx | 2 +- app/src/frontend/building/sidebar.css | 5 + app/src/frontend/config/categories-config.ts | 1 - app/src/frontend/config/data-fields-config.ts | 251 ++++++++- migrations/040.ui_revamp_sources.down.sql | 29 + migrations/040.ui_revamp_sources.up.sql | 31 +- 13 files changed, 1175 insertions(+), 462 deletions(-) diff --git a/app/src/api/config/dataFields.ts b/app/src/api/config/dataFields.ts index 0583c2ab..031aa840 100644 --- a/app/src/api/config/dataFields.ts +++ b/app/src/api/config/dataFields.ts @@ -214,6 +214,42 @@ export const buildingAttributesConfig = valueType()({ /* eslint edit: true, verify: true, }, + size_far_ratio: { + edit: true, + verify: true, + }, + size_far_ratio_source_type: { + edit: true, + verify: true, + }, + size_far_ratio_source_links: { + edit: true, + verify: true, + }, + size_plot_area_total: { + edit: true, + verify: true, + }, + size_plot_area_total_source_type: { + edit: true, + verify: true, + }, + size_plot_area_total_source_links: { + edit: true, + verify: true, + }, + size_parcel_geometry: { + edit: true, + verify: true, + }, + size_parcel_geometry_source_type: { + edit: true, + verify: true, + }, + size_parcel_geometry_source_links: { + edit: true, + verify: true, + }, construction_core_material: { edit: true, verify: true, @@ -533,6 +569,86 @@ export const buildingAttributesConfig = valueType()({ /* eslint disaster_end_date : { edit: true, verify: true + }, + context_front_garden : { + edit: true, + verify: true + }, + context_back_garden : { + edit: true, + verify: true + }, + context_flats_garden : { + edit: true, + verify: true + }, + context_garden_source_type : { + edit: true, + verify: true + }, + context_garden_source_links : { + edit: true, + verify: true + }, + context_street_width : { + edit: true, + verify: true + }, + context_street_width_source_type : { + edit: true, + verify: true + }, + context_street_width_source_links : { + edit: true, + verify: true + }, + context_pavement_width : { + edit: true, + verify: true + }, + context_pavement_width_source_type : { + edit: true, + verify: true + }, + context_pavement_width_source_links : { + edit: true, + verify: true + }, + context_street_geometry : { + edit: true, + verify: true + }, + context_street_geometry_source_type : { + edit: true, + verify: true + }, + context_street_geometry_source_links : { + edit: true, + verify: true + }, + context_green_space_distance : { + edit: true, + verify: true + }, + context_green_space_distance_source_type : { + edit: true, + verify: true + }, + context_green_space_distance_source_links : { + edit: true, + verify: true + }, + context_tree_distance : { + edit: true, + verify: true + }, + context_tree_distance_source_type : { + edit: true, + verify: true + }, + ccontext_tree_distance_source_links : { + edit: true, + verify: true } }); diff --git a/app/src/frontend/building/data-containers/community.tsx b/app/src/frontend/building/data-containers/community.tsx index 6277905a..45aee4d2 100644 --- a/app/src/frontend/building/data-containers/community.tsx +++ b/app/src/frontend/building/data-containers/community.tsx @@ -43,7 +43,7 @@ const CommunityView: React.FunctionComponent = (props) => {
- Note: We are not currently collecting data on domestic/privately owned properties, only on public buildings. + Note: We are currently only collecting data on non-residential buildings.
@@ -201,14 +201,7 @@ const CommunityView: React.FunctionComponent = (props) => { slug='community_public_ownership' title={dataFields.community_public_ownership.title} value={props.building.community_public_ownership} - options={[ - 'Government-owned', - 'Charity-owned', - 'Community-owned/cooperative', - 'Owned by other non-profit body', - 'Not in public/community ownership', - ]} - + options={dataFields.community_public_ownership.items} onChange={props.onChange} mode={props.mode} copy={props.copy} diff --git a/app/src/frontend/building/data-containers/land-use.tsx b/app/src/frontend/building/data-containers/land-use.tsx index e8e8b1be..6a15a978 100644 --- a/app/src/frontend/building/data-containers/land-use.tsx +++ b/app/src/frontend/building/data-containers/land-use.tsx @@ -25,10 +25,10 @@ const UseView: React.FunctionComponent = (props) => { const { darkLightTheme } = useDisplayPreferences(); return ( - +
- 93% of properties in UK are residential dwellings so we have set 'residential' as the default value. Can you help us identify non-residential and mixed use buildings (and verify residential buildings too)? + The vast majority of properties are residential (93% in the UK), so we have set 'residential' as the default value. Can you help us identify non-residential and mixed use buildings (and verify residential buildings too)?
-

Date of disaster

+
= (props) => { maxDate={new Date()} />
+ + = (props) => { slug='disaster_assessment_method' title={dataFields.disaster_assessment_method.title} value={props.building.disaster_assessment_method} - options={[ - 'Citizen/Passerby by eye', - 'Government assessor', - 'Specialist emergency group/charity', - 'Other', - ]} + options={dataFields.disaster_assessment_method.items} tooltip={dataFields.disaster_assessment_method.tooltip} onChange={props.onChange} mode={props.mode} copy={props.copy} /> - - + {(props.building.disaster_assessment_method == dataFields.disaster_assessment_method.items[0] || + props.building.disaster_assessment_method == dataFields.disaster_assessment_method.items[1] || + props.building.disaster_assessment_method == null) ? <> : + <> + + + }
diff --git a/app/src/frontend/building/data-containers/size.tsx b/app/src/frontend/building/data-containers/size.tsx index 76151a57..02ab7344 100644 --- a/app/src/frontend/building/data-containers/size.tsx +++ b/app/src/frontend/building/data-containers/size.tsx @@ -262,93 +262,6 @@ const SizeView: React.FunctionComponent = (props) => ( } - - - -
- - - -
- - - -
- - - -
= (props) => ( /> } +
+ + + + {(props.building.size_plot_area_total_source_type == commonSourceTypes[0] || + props.building.size_plot_area_total_source_type == commonSourceTypes[1] || + props.building.size_far_ratio_source_type == null) ? <> : + <> + + } +
+ + + + {(props.building.size_far_ratio_source_type == commonSourceTypes[0] || + props.building.size_far_ratio_source_type == commonSourceTypes[1] || + props.building.size_far_ratio_source_type == null) ? <> : + <> + + } +
+ + + + {(props.building.size_parcel_geometry_source_type == commonSourceTypes[0] || + props.building.size_parcel_geometry_source_type == commonSourceTypes[1] || + props.building.size_parcel_geometry_source_type == null) ? <> : + <> + + }
); diff --git a/app/src/frontend/building/data-containers/street-context.tsx b/app/src/frontend/building/data-containers/street-context.tsx index bb92c118..f0e85c38 100644 --- a/app/src/frontend/building/data-containers/street-context.tsx +++ b/app/src/frontend/building/data-containers/street-context.tsx @@ -1,6 +1,6 @@ import React, { Fragment } from 'react'; import InfoBox from '../../components/info-box'; -import { dataFields } from '../../config/data-fields-config'; +import { commonSourceTypes, dataFields } from '../../config/data-fields-config'; import DataEntry from '../data-components/data-entry'; import NumericDataEntry from '../data-components/numeric-data-entry'; @@ -8,59 +8,339 @@ import withCopyEdit from '../data-container'; import { CategoryViewProps } from './category-view-props'; import { DataEntryGroup } from '../data-components/data-entry-group'; +import { MultiDataEntry } from '../data-components/multi-data-entry/multi-data-entry'; +import SelectDataEntry from '../data-components/select-data-entry'; +import Verification from '../data-components/verification'; /** * Streetscape view/edit section */ const StreetscapeView: React.FunctionComponent = (props) => ( - - - + + + + + + + +
+ + {(props.building.context_garden_source_type == commonSourceTypes[0] || + props.building.context_garden_source_type == commonSourceTypes[1] || + props.building.context_garden_source_type == null) ? <> : + <> + + + }
- - + - : + <> + + } +
+ + + + {(props.building.context_pavement_width_source_type == commonSourceTypes[0] || + props.building.context_pavement_width_source_type == commonSourceTypes[1] || + props.building.context_pavement_width_source_type == null) ? <> : + <> + + } +
+ + + + {(props.building.context_street_geometry_source_type == commonSourceTypes[0] || + props.building.context_street_geometry_source_type == commonSourceTypes[1] || + props.building.context_street_geometry_source_type == null) ? <> : + <> + + }
- - + + {(props.building.context_green_space_distance_source_type == commonSourceTypes[0] || + props.building.context_green_space_distance_source_type == commonSourceTypes[1] || + props.building.context_green_space_distance_source_type == null) ? <> : + <> + + } +
+ + + + {(props.building.context_tree_distance_source_type == commonSourceTypes[0] || + props.building.context_tree_distance_source_type == commonSourceTypes[1] || + props.building.context_tree_distance_source_type == null) ? <> : + <> + + }
); diff --git a/app/src/frontend/building/data-containers/team.tsx b/app/src/frontend/building/data-containers/team.tsx index 73c7bb09..0f15c2cf 100644 --- a/app/src/frontend/building/data-containers/team.tsx +++ b/app/src/frontend/building/data-containers/team.tsx @@ -21,7 +21,7 @@ const TeamView: React.FunctionComponent = (props) => { const currentBuildingConstructionYear = building.date_year || undefined; return (
- +
(For security reasons, we currently only collect the names of well-known public buildings.)", + tooltip: "Link to a website with the name of the building.

(For security reasons, we currently only collect the names of non-residential buildings).", example: "https://en.wikipedia.org/wiki/Palace_of_Westminster", }, location_number: { @@ -165,13 +168,13 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ }, location_town: { category: Category.Location, - title: "Town/city", + title: "Town/City", example: "London", //tooltip: , }, location_postcode: { category: Category.Location, - title: ccconfig.postcode, + title: "Area code/"+ccconfig.postcode, example: "W1W 6TR", //tooltip: , }, @@ -503,13 +506,58 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ category: Category.StreetContext, title: "Total area of plot (m²)", example: 123.02, - //tooltip: , + tooltip: "Total area of plot (m²)", + }, + size_plot_area_total_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source of plot area data", + example: "", + items: commonSourceTypes + }, + size_plot_area_total_source_links: { + category: Category.Team, + title: "Source links", + tooltip: "URL(s) for plot area data source(s)", + example: ["", "", ""], }, size_far_ratio: { category: Category.StreetContext, title: "FAR ratio (percentage of plot covered by building)", - example: 0.1, - //tooltip: , + example: 1.0, + tooltip: "boobs", + }, + size_far_ratio_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source of FAR ratio data", + example: "", + items: commonSourceTypes + }, + size_far_ratio_source_links: { + category: Category.Team, + title: "Source links", + tooltip: "URL(s) for FAR ratio data source(s)", + example: ["", "", ""], + }, + size_parcel_geometry: { + category: Category.StreetContext, + title: "Land parcel geometry link", + example: "https://", + tooltip: "INSPIRE Polygons", + }, + size_parcel_geometry_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source of parcel geometry data", + example: "", + items: commonSourceTypes + }, + size_parcel_geometry_source_links: { + category: Category.Team, + title: "Source links", + tooltip: "URL(s) for parcel geometry data source(s)", + example: ["", "", ""], }, construction_core_material: { @@ -784,13 +832,20 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ // title: "When was this building used for community activities?" // }, - community_public_ownership: { category: Category.Community, title: "Is the building in public/community ownership?", - example: "Not in public/community ownership" + example: "Privately owned (non-corporate)", + items: [ + 'State-owned', + 'Charity-owned', + 'Community-owned', + 'Owned by other non-profit body', + 'Privately owned (non-corporate)', + 'Privately owned (corporate)', + 'Other' + ] }, - community_public_ownership_sources: { category: Category.Community, title: "Community ownership source link", @@ -991,19 +1046,38 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ category: Category.Resilience, title: "Disaster type", tooltip: "What type of disaster management do you wish to collect data for?", - example: "Flood" + example: "Flood", + items: [ + 'Flood', + 'Earthquake', + 'Hurricane', + 'Fire', + 'Extreme heat', + 'Political/war damage', + 'Other human (blast damage/spills etc.)', + 'Other' + ] }, disaster_severity: { category: Category.Resilience, title: "How severe do you assess the damage to be?", tooltip: "Best estimate for the severity of damage to the building", - example: "Building destroyed" + example: "Building destroyed", + items: [ + 'Building destroyed', + 'Very severe', + 'Severe', + 'Moderate', + 'Minimal', + 'No damage visible', + ] }, disaster_assessment_method: { category: Category.Resilience, - title: "Method of assessment", + title: "Source Type", tooltip: "Please add a Best estimate for the severity of damage to the building", - example: "Citizen/Passerby by eye" + example: "Citizen/Passerby by eye", + items: commonSourceTypes }, disaster_source_link: { category: Category.Resilience, @@ -1021,6 +1095,145 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ title: "What was the end date of the disaster? (if applicable)", example: "03/04/2023" }, + + context_front_garden: { + category: Category.StreetContext, + title: "Does the building have a front garden?", + tooltip: "Is the front garden mainly green/planted?", + example: "", + items: [ + "Yes", + "No" + ] + }, + context_back_garden: { + category: Category.StreetContext, + title: "Does the building have a back garden?", + tooltip: "Is the back garden mainly green/planted?", + example: "", + items: [ + "Yes", + "No" + ] + }, + context_flats_garden: { + category: Category.StreetContext, + title: "Is the building flats with a dedicated green space?", + tooltip: "If the building is a block of flats, does it have a dedicated garden area/green space?", + example: "", + items: [ + "Yes", + "No" + ] + }, + context_garden_source_type: { + category: Category.StreetContext, + title: "Source type", + tooltip: "Source type for garden data", + example: "", + items: commonSourceTypes + }, + context_garden_source_links: { + category: Category.StreetContext, + title: "Source link(s)", + tooltip: "Source link(s) for garden data source(s)", + example: ["", "", ""], + }, + context_street_width: { + category: Category.Team, + title: "Street width (m)", + tooltip: "Width of the street in metres.", + example: 10 + }, + context_street_width_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source type for street width data", + example: "", + items: commonSourceTypes + }, + context_street_width_source_links: { + category: Category.Team, + title: "Source link(s)", + tooltip: "Source link(s) for street width data", + example: ["", "", ""], + }, + context_pavement_width: { + category: Category.Team, + title: "Pavement width (m)", + tooltip: "Width of the pavement in metres.", + example: 10 + }, + context_pavement_width_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source type for pavement width data", + example: "", + items: commonSourceTypes + }, + context_pavement_width_source_links: { + category: Category.Team, + title: "Source link(s)", + tooltip: "Source link(s) for pavement width data", + example: ["", "", ""], + }, + context_green_space_distance: { + category: Category.Team, + title: "Distance to nearest green space (m)", + tooltip: "Approximate distance from the front door of the building to the nearest public green space.", + example: 10 + }, + context_green_space_distance_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source type for green space data", + example: "", + items: commonSourceTypes + }, + context_green_space_distance_source_links: { + category: Category.Team, + title: "Source link(s)", + tooltip: "Source link(s) for green space data", + example: ["", "", ""], + }, + context_tree_distance: { + category: Category.Team, + title: "Distance to nearest tree (m)", + tooltip: "Approximate distance from the front door of the building to the nearest tree.", + example: 10 + }, + context_tree_distance_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source type for tree data", + example: "", + items: commonSourceTypes + }, + context_tree_distance_source_links: { + category: Category.Team, + title: "Source link(s)", + tooltip: "Source link(s) for tree data", + example: ["", "", ""], + }, + context_street_geometry: { + category: Category.Team, + title: "Street network geometry link", + tooltip: "Link to a website with the name of the building..", + example: "https://en.wikipedia.org/", + }, + context_street_geometry_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source type for tree data", + example: "", + items: commonSourceTypes + }, + context_street_geometry_source_links: { + category: Category.Team, + title: "Source link(s)", + tooltip: "Source link(s) for tree data", + example: ["", "", ""], + }, }; export const allFieldsConfig = { ...dataFields, ...buildingUserFields }; \ No newline at end of file diff --git a/migrations/040.ui_revamp_sources.down.sql b/migrations/040.ui_revamp_sources.down.sql index 9af8c0f0..75c07ebe 100644 --- a/migrations/040.ui_revamp_sources.down.sql +++ b/migrations/040.ui_revamp_sources.down.sql @@ -19,3 +19,32 @@ ALTER TABLE buildings DROP COLUMN IF EXISTS designers_source_type; ALTER TABLE buildings DROP COLUMN IF EXISTS builder_source_type; ALTER TABLE buildings DROP COLUMN IF EXISTS extension_source_type; ALTER TABLE buildings DROP COLUMN IF EXISTS extension_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_far_ratio; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_far_ratio_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_far_ratio_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_plot_area_total; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_plot_area_total_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_plot_area_total_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_parcel_geometry; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_parcel_geometry_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_parcel_geometry_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_front_garden; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_back_garden; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_flats_garden; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_garden_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_garden_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_street_width; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_street_width_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_street_width_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_pavement_width; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_pavement_width_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_pavement_width_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_green_space_distance; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_green_space_distance_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_green_space_distance_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_tree_distance; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_tree_distance_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_tree_distance_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_street_geometry; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_street_geometry_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS context_street_geometry_source_links; \ No newline at end of file diff --git a/migrations/040.ui_revamp_sources.up.sql b/migrations/040.ui_revamp_sources.up.sql index b73dc463..f27fdb1a 100644 --- a/migrations/040.ui_revamp_sources.up.sql +++ b/migrations/040.ui_revamp_sources.up.sql @@ -20,4 +20,33 @@ ALTER TABLE buildings ADD COLUMN IF NOT EXISTS landowner_source_type text; ALTER TABLE buildings ADD COLUMN IF NOT EXISTS designers_source_type text; ALTER TABLE buildings ADD COLUMN IF NOT EXISTS builder_source_type text; ALTER TABLE buildings ADD COLUMN IF NOT EXISTS extension_source_type text; -ALTER TABLE buildings ADD COLUMN IF NOT EXISTS extension_source_links text[]; \ No newline at end of file +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS extension_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_far_ratio text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_far_ratio_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_far_ratio_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_plot_area_total text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_plot_area_total_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_plot_area_total_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_parcel_geometry text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_parcel_geometry_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_parcel_geometry_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_front_garden text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_back_garden text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_flats_garden text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_garden_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_garden_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_street_width text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_street_width_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_street_width_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_pavement_width text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_pavement_width_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_pavement_width_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_green_space_distance text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_green_space_distance_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_green_space_distance_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_tree_distance text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_tree_distance_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_tree_distance_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_street_geometry text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_street_geometry_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS context_street_geometry_source_links text[]; \ No newline at end of file