From 19c906fcc5a31d6a90315956305424c5792441db Mon Sep 17 00:00:00 2001 From: Mike Simpson Date: Tue, 23 May 2023 21:27:45 +0100 Subject: [PATCH] Size / Age & History Sources Adding source link(s) field to activated data sources in the Size category and the Age & History category --- app/src/api/config/dataFields.ts | 48 +++++ .../building/data-containers/age-history.tsx | 60 +++--- .../building/data-containers/size.tsx | 194 ++++++++++++------ app/src/frontend/config/data-fields-config.ts | 75 ++++++- maintenance/extract_data/README.md | 14 +- .../extract_data/export_attributes.sql | 10 + migrations/040.ui_revamp_sources.down.sql | 12 +- migrations/040.ui_revamp_sources.up.sql | 14 +- 8 files changed, 333 insertions(+), 94 deletions(-) diff --git a/app/src/api/config/dataFields.ts b/app/src/api/config/dataFields.ts index a1917f0f..2b9b563e 100644 --- a/app/src/api/config/dataFields.ts +++ b/app/src/api/config/dataFields.ts @@ -154,10 +154,38 @@ export const buildingAttributesConfig = valueType()({ /* eslint edit: true, verify: true, }, + size_storeys_source_type: { + edit: true, + verify: true, + }, + size_storeys_source_links: { + edit: true, + verify: true, + }, size_height_apex: { edit: true, verify: true, }, + size_height_apex_source_type: { + edit: true, + verify: true, + }, + size_height_apex_source_links: { + edit: true, + verify: true, + }, + size_height_eaves: { + edit: true, + verify: true, + }, + size_height_eaves_source_type: { + edit: true, + verify: true, + }, + size_height_eaves_source_links: { + edit: true, + verify: true, + }, size_floor_area_ground: { edit: true, verify: true, @@ -166,10 +194,26 @@ export const buildingAttributesConfig = valueType()({ /* eslint edit: true, verify: true, }, + size_floor_area_source_type: { + edit: true, + verify: true, + }, + size_floor_area_source_links: { + edit: true, + verify: true, + }, size_width_frontage: { edit: true, verify: true, }, + size_width_frontage_source_type: { + edit: true, + verify: true, + }, + size_width_frontage_source_links: { + edit: true, + verify: true, + }, construction_core_material: { edit: true, verify: true, @@ -326,6 +370,10 @@ export const buildingAttributesConfig = valueType()({ /* eslint edit: true, verify: true }, + survival_source_links: { + edit: true, + verify: true + }, likes_total: { edit: false, derivedEdit: true, diff --git a/app/src/frontend/building/data-containers/age-history.tsx b/app/src/frontend/building/data-containers/age-history.tsx index 57182d5c..93420d73 100644 --- a/app/src/frontend/building/data-containers/age-history.tsx +++ b/app/src/frontend/building/data-containers/age-history.tsx @@ -106,14 +106,6 @@ const AgeView: React.FunctionComponent = (props) => { placeholder={dataFields.date_source.example} options={dataFields.date_source.items} /> -
This section is under development. @@ -258,6 +250,23 @@ const AgeView: React.FunctionComponent = (props) => { placeholder={dataFields.survival_source.example} options={dataFields.survival_source.items} /> + {(props.building.survival_source == dataFields.survival_source_links[0] || + props.building.survival_source == dataFields.survival_source_links[1] || + props.building.survival_source == null) ? <> : + <> + + } ); @@ -322,14 +331,6 @@ const AgeView: React.FunctionComponent = (props) => { options={dataFields.date_source.items} placeholder={dataFields.date_source.example} /> - = (props) => { editableEntries={true} isUrl={true} /> -
This section is under development. @@ -535,7 +528,24 @@ const AgeView: React.FunctionComponent = (props) => { tooltip={dataFields.survival_source.tooltip} placeholder={dataFields.survival_source.example} options={dataFields.survival_source.items} - /> + /> + {(props.building.survival_source == dataFields.survival_source.items[0] || + props.building.survival_source == dataFields.survival_source.items[1] || + props.building.survival_source == null) ? <> : + <> + + } ); diff --git a/app/src/frontend/building/data-containers/size.tsx b/app/src/frontend/building/data-containers/size.tsx index a4e428be..4e7f99c4 100644 --- a/app/src/frontend/building/data-containers/size.tsx +++ b/app/src/frontend/building/data-containers/size.tsx @@ -1,6 +1,6 @@ import React, { Fragment } from 'react'; -import { dataFields } from '../../config/data-fields-config'; +import { commonSourceTypes, dataFields } from '../../config/data-fields-config'; import DataEntry from '../data-components/data-entry'; import { DataEntryGroup } from '../data-components/data-entry-group'; import NumericDataEntry from '../data-components/numeric-data-entry'; @@ -10,6 +10,7 @@ import withCopyEdit from '../data-container'; import { CategoryViewProps } from './category-view-props'; import InfoBox from '../../components/info-box'; +import { MultiDataEntry } from '../data-components/multi-data-entry/multi-data-entry'; /** * Size view/edit section @@ -74,20 +75,33 @@ const SizeView: React.FunctionComponent = (props) => ( user_verified_as={props.user_verified.size_storeys_basement} verified_count={props.building.verified.size_storeys_basement} /> - - + {(props.building.size_storeys_source_type == commonSourceTypes[0] || + props.building.size_storeys_source_type == commonSourceTypes[1] || + props.building.size_storeys_source_type == null) ? <> : + <> + + } = (props) => ( user_verified_as={props.user_verified.size_height_apex} verified_count={props.building.verified.size_height_apex} /> - - + {(props.building.size_height_apex_source_type == commonSourceTypes[0] || + props.building.size_height_apex_source_type == commonSourceTypes[1] || + props.building.size_height_apex_source_type == null) ? <> : + <> + + }
= (props) => ( step={0.1} min={0} /> - - + {(props.building.size_height_eaves_source_type == commonSourceTypes[0] || + props.building.size_height_eaves_source_type == commonSourceTypes[1] || + props.building.size_height_eaves_source_type == null) ? <> : + <> + + }
= (props) => ( user_verified_as={props.user_verified.size_floor_area_total} verified_count={props.building.verified.size_floor_area_total} /> - + + {(props.building.size_floor_area_source_type == commonSourceTypes[0] || + props.building.size_floor_area_source_type == commonSourceTypes[1] || + props.building.size_floor_area_source_type == null) ? <> : + <> + + } = (props) => ( user_verified_as={props.user_verified.size_width_frontage} verified_count={props.building.verified.size_width_frontage} /> - - + {(props.building.size_width_frontage_source_type == commonSourceTypes[0] || + props.building.size_width_frontage_source_type == commonSourceTypes[1] || + props.building.size_width_frontage_source_type == null) ? <> : + <> + + } ); diff --git a/app/src/frontend/config/data-fields-config.ts b/app/src/frontend/config/data-fields-config.ts index 4227b274..62bd018b 100644 --- a/app/src/frontend/config/data-fields-config.ts +++ b/app/src/frontend/config/data-fields-config.ts @@ -373,7 +373,7 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ }, date_link: { category: Category.Age, - title: "Text and Image Links", + title: "Source link(s)", tooltip: "URL for age and date reference", example: ["", "", ""], }, @@ -396,18 +396,57 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ tooltip: "How many floors below pavement level?", example: 1, }, + size_storeys_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source of building floors data", + example: "", + items: commonSourceTypes + }, + size_storeys_source_links: { + category: Category.Team, + title: "Source links", + tooltip: "URL(s) for building floors data source(s)", + example: ["", "", ""], + }, size_height_apex: { category: Category.Size, title: "Height to apex (m)", example: 100.5, tooltip: "i.e. the highest part of the roof.", }, + size_height_apex_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source of building height (apex) data", + example: "", + items: commonSourceTypes + }, + size_height_apex_source_links: { + category: Category.Team, + title: "Source links", + tooltip: "URL(s) for building height (apex) source(s)", + example: ["", "", ""], + }, size_height_eaves: { category: Category.Size, title: "Height to eaves (m)", example: 20.33, tooltip: "i.e. to where the top of the wall meets the roof", }, + size_height_eaves_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source of building height (eaves) data", + example: "", + items: commonSourceTypes + }, + size_height_eaves_source_links: { + category: Category.Team, + title: "Source links", + tooltip: "URL(s) for building height (eaves) source(s)", + example: ["", "", ""], + }, size_floor_area_ground: { category: Category.Size, title: "Ground floor area (m²)", @@ -420,12 +459,38 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ example: 2001.7, //tooltip: , }, + size_floor_area_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source of floor area data", + example: "", + items: commonSourceTypes + }, + size_floor_area_source_links: { + category: Category.Team, + title: "Source links", + tooltip: "URL(s) for floor area data source(s)", + example: ["", "", ""], + }, size_width_frontage: { category: Category.Size, title: "Frontage width (m)", example: 12.2, //tooltip: , }, + size_width_frontage_source_type: { + category: Category.Team, + title: "Source type", + tooltip: "Source of building frontage data", + example: "", + items: commonSourceTypes + }, + size_width_frontage_source_links: { + category: Category.Team, + title: "Source links", + tooltip: "URL(s) for building frontage source(s)", + example: ["", "", ""], + }, size_configuration: { category: Category.Size, @@ -514,7 +579,7 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ survival_source: { category: Category.Age, - title: "Source of survival information", + title: "Source type", tooltip: "Source for the survival status", items: [ "Matched by comparing maps", @@ -525,10 +590,10 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ example: "", }, - survival_link: { + survival_source_links: { category: Category.Age, - title: "Please add any additional text or image links providing historical information on this building", - tooltip: "URL for age and date reference", + title: "Source link(s)", + tooltip: "Links to sources of survival/historical information on this building", example: ["", "", ""], }, diff --git a/maintenance/extract_data/README.md b/maintenance/extract_data/README.md index c2e4100e..30845792 100644 --- a/maintenance/extract_data/README.md +++ b/maintenance/extract_data/README.md @@ -63,9 +63,18 @@ This is the main table, containing almost all data collected by Colouring London - `size_storeys_attic`: number of attic storeys - `size_storeys_core`: number of core storeys - `size_storeys_basement`: number of basement storeys +- `size_storeys_source_type`: source type for number of storeys +- `size_storeys_source_links`: source links for number of storeys - `size_height_apex`: height in metres to the building apex +- `size_height_apex_source_type`: source of apex height data +- `size_height_apex_source_links`: links to apex height data +- `size_height_eaves`: height in metres to the building eaves +- `size_height_eaves_source_type`: source of eaves height data +- `size_height_eaves_source_links`: links to eaves height data - `size_floor_area_ground`: ground floor floor area in square metres - `size_floor_area_total`: total floor area in square metres +- `size_floor_area_source_type`: source of floor area data +- `size_floor_area_source_links`: link(s) to floor area data - `size_width_frontage`: width of frontage in metres - `construction_core_material`: main structural material - `construction_secondary_materials`: other structural materials @@ -91,7 +100,10 @@ This is the main table, containing almost all data collected by Colouring London - `likes_total`: number of times the building has been liked by Colouring London users - `is_domestic`: is the building domestic/non-domestic/mixed - `is_domestic_source`: domestic data source type, - -`is_domestic_links`: domestic data source links, +- `is_domestic_links`: domestic data source links, +- `survival_status`: survival status compared to historical maps, +- `survival_source`: source of survival data, +- `survival_links`: link(s) to survival data source, ## Building UPRNs diff --git a/maintenance/extract_data/export_attributes.sql b/maintenance/extract_data/export_attributes.sql index 370b2f8e..6b0825b5 100644 --- a/maintenance/extract_data/export_attributes.sql +++ b/maintenance/extract_data/export_attributes.sql @@ -31,9 +31,18 @@ COPY (SELECT size_storeys_attic, size_storeys_core, size_storeys_basement, + size_storeys_source_type, + size_storeys_source_links, size_height_apex, + size_height_apex_source_type, + size_height_apex_source_links, + size_height_eaves, + size_height_eaves_source_type, + size_height_eaves_source_links, size_floor_area_ground, size_floor_area_total, + size_floor_area_source_type, + size_floor_area_source_links, size_width_frontage, sust_breeam_rating, sust_dec, @@ -63,6 +72,7 @@ COPY (SELECT likes_total, survival_status, survival_source, + survival_source_links, disaster_type, disaster_severity, disaster_assessment_method, diff --git a/migrations/040.ui_revamp_sources.down.sql b/migrations/040.ui_revamp_sources.down.sql index 6fa76932..3b3d4a6e 100644 --- a/migrations/040.ui_revamp_sources.down.sql +++ b/migrations/040.ui_revamp_sources.down.sql @@ -3,4 +3,14 @@ ALTER TABLE buildings DROP COLUMN IF EXISTS location_address_links; ALTER TABLE buildings DROP COLUMN IF EXISTS location_coordinates_source; ALTER TABLE buildings DROP COLUMN IF EXISTS location_coordinates_links; ALTER TABLE buildings DROP COLUMN IF EXISTS is_domestic_source; -ALTER TABLE buildings DROP COLUMN IF EXISTS is_domestic_links; \ No newline at end of file +ALTER TABLE buildings DROP COLUMN IF EXISTS is_domestic_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_storeys_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_storeys_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_height_apex_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_height_apex_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_height_eaves_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_height_eaves_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_height_eaves; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_width_frontage_source_type; +ALTER TABLE buildings DROP COLUMN IF EXISTS size_width_frontage_source_links; +ALTER TABLE buildings DROP COLUMN IF EXISTS survival_source_links; diff --git a/migrations/040.ui_revamp_sources.up.sql b/migrations/040.ui_revamp_sources.up.sql index 7a08b6fd..49e3cd76 100644 --- a/migrations/040.ui_revamp_sources.up.sql +++ b/migrations/040.ui_revamp_sources.up.sql @@ -3,4 +3,16 @@ ALTER TABLE buildings ADD COLUMN IF NOT EXISTS location_address_links text[]; ALTER TABLE buildings ADD COLUMN IF NOT EXISTS location_coordinates_source text; ALTER TABLE buildings ADD COLUMN IF NOT EXISTS location_coordinates_links text[]; ALTER TABLE buildings ADD COLUMN IF NOT EXISTS is_domestic_source text; -ALTER TABLE buildings ADD COLUMN IF NOT EXISTS is_domestic_links text[]; \ No newline at end of file +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS is_domestic_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_storeys_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_storeys_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_height_apex_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_height_apex_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_height_eaves_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_height_eaves_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_height_eaves text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_floor_area_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_floor_area_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_width_frontage_source_type text; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS size_width_frontage_source_links text[]; +ALTER TABLE buildings ADD COLUMN IF NOT EXISTS survival_source_links text[]; \ No newline at end of file