Skip to content

Commit

Permalink
Merge pull request #1424 from colouring-cities/minor-tweaks-oct-24
Browse files Browse the repository at this point in the history
Fixes to Construction Year fields
  • Loading branch information
mdsimpson42 authored Oct 23, 2024
2 parents 5c37503 + f2ced57 commit 71135d1
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 26 deletions.
4 changes: 4 additions & 0 deletions app/src/api/config/dataFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ export const buildingAttributesConfig = valueType<DataFieldConfig>()({ /* eslint
edit: true,
verify: true,
},
date_year_completed: {
edit: true,
verify: true,
},
date_lower: {
edit: true,
verify: true,
Expand Down
47 changes: 24 additions & 23 deletions app/src/frontend/building/data-containers/age-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,17 @@ const AgeHistoryView: React.FunctionComponent<CategoryViewProps> = (props) => {

let construction_length = null;

if (props.building.date_year != null && props.building.date_lower != null) {
construction_length += props.building.date_year - props.building.date_lower;
if (props.building.date_year != null && props.building.date_year_completed != null) {
construction_length = props.building.date_year_completed - props.building.date_year;
construction_length = Math.max(construction_length, 1);
}

const queryParameters = new URLSearchParams(window.location.search);
const subcat = queryParameters.get("sc");

return (
<Fragment>
<DataEntryGroup name="Architectural style/historial period" collapsed={subcat==null || subcat!="2"}>
<DataEntryGroup name="Architectural style/historical period" collapsed={subcat==null || subcat!="2"}>
{(props.mapColourScale != "typology_style_period") ?
<button className={`map-switcher-inline enabled-state btn btn-outline btn-outline-dark key-button`} onClick={switchToStylePeriodMapStyle}>
Click to show architectural style.
Expand Down Expand Up @@ -142,44 +143,44 @@ const AgeHistoryView: React.FunctionComponent<CategoryViewProps> = (props) => {
<></>
}
<NumericDataEntry
title={dataFields.date_lower.title}
slug="date_lower"
value={props.building.date_lower}
title={dataFields.date_year.title}
slug="date_year"
value={props.building.date_year}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
step={1}
min={1}
max={currentYear}
tooltip={dataFields.date_lower.tooltip}
max={props.building.date_year_completed}
tooltip={dataFields.date_year.tooltip}
/>
<Verification
slug="date_lower"
allow_verify={props.user !== undefined && props.building.date_lower !== null && !props.edited}
slug="date_year"
allow_verify={props.user !== undefined && props.building.date_year !== null && !props.edited}
onVerify={props.onVerify}
user_verified={props.user_verified.hasOwnProperty("date_lower")}
user_verified_as={props.user_verified.date_lower}
verified_count={props.building.verified.date_lower}
user_verified={props.user_verified.hasOwnProperty("date_year")}
user_verified_as={props.user_verified.date_year}
verified_count={props.building.verified.date_year}
/>
<NumericDataEntry
title={dataFields.date_year.title}
slug="date_year"
value={props.building.date_year}
title={dataFields.date_year_completed.title}
slug="date_year_completed"
value={props.building.date_year_completed}
mode={props.mode}
copy={props.copy}
onChange={props.onChange}
step={1}
min={1}
min={props.building.date_year}
max={currentYear}
tooltip={dataFields.date_year.tooltip}
tooltip={dataFields.date_year_completed.tooltip}
/>
<Verification
slug="date_year"
allow_verify={props.user !== undefined && props.building.date_year !== null && !props.edited}
slug="date_year_completed"
allow_verify={props.user !== undefined && props.building.date_year_completed !== 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}
user_verified={props.user_verified.hasOwnProperty("date_year_completed")}
user_verified_as={props.user_verified.date_year_completed}
verified_count={props.building.verified.date_year_completed}
/>
<NumericDataEntry
title="Estimated duration of construction (years)"
Expand Down
12 changes: 9 additions & 3 deletions app/src/frontend/config/data-fields-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,16 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
},
date_year: {
category: Category.AgeHistory,
title: "Year of construction completed (best estimate)",
tooltip: "Best estimate for the year that construction of main body of the building was completed.",
title: "Year construction started (best estimate)",
tooltip: "Best estimate for the year that construction began on this building.",
example: 1924,
},
date_year_completed: {
category: Category.AgeHistory,
title: "Year construction completed (best estimate)",
tooltip: "Best estimate for the year that construction completed on this building.",
example: 1925,
},
date_lower: {
category: Category.AgeHistory,
title: "Year construction started (best estimate)",
Expand Down Expand Up @@ -556,7 +562,7 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */
date_source_links: {
category: Category.AgeHistory,
title: "Alternative Source link(s)",
tooltip: "URL(s) for historial data source(s) - Alternative data source(s)",
tooltip: "URL(s) for historical data source(s) - Alternative data source(s)",
example: ["", "", ""],
},
size_storeys_core: {
Expand Down
7 changes: 7 additions & 0 deletions app/src/tiles/dataDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ const LAYER_QUERIES = {
FROM
buildings
WHERE date_year IS NOT NULL`,
date_year_completed: `
SELECT
geometry_id,
date_year_completed
FROM
buildings
WHERE date_year_completed IS NOT NULL`,
size_storeys: `
SELECT
geometry_id,
Expand Down
1 change: 1 addition & 0 deletions migrations/054.building_age.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE buildings DROP COLUMN IF EXISTS date_year_completed;
1 change: 1 addition & 0 deletions migrations/054.building_age.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE buildings ADD COLUMN IF NOT EXISTS date_year_completed integer NULL;

0 comments on commit 71135d1

Please sign in to comment.