From ff8618beb8cf34c83c1c7c31623cfdb9729d502b Mon Sep 17 00:00:00 2001 From: Mike Simpson Date: Thu, 29 Jun 2023 11:09:12 +0100 Subject: [PATCH] Calculate total floors #1192 --- .../building/data-containers/size.tsx | 830 +++++++++--------- 1 file changed, 429 insertions(+), 401 deletions(-) diff --git a/app/src/frontend/building/data-containers/size.tsx b/app/src/frontend/building/data-containers/size.tsx index 1ae07ab8..763b2a5a 100644 --- a/app/src/frontend/building/data-containers/size.tsx +++ b/app/src/frontend/building/data-containers/size.tsx @@ -15,441 +15,469 @@ import { MultiDataEntry } from '../data-components/multi-data-entry/multi-data-e /** * Size view/edit section */ -const SizeView: React.FunctionComponent = (props) => ( - - - - - - - - - - {(props.building.size_storeys_source_type == commonSourceTypes[0] || - props.building.size_storeys_source_type == commonSourceTypes[1] || - props.building.size_storeys_source_type == null) ? <> : - <> = (props) => { + + // Calculate the total number of floors + let total_floors = 0; + + if (props.building.size_storeys_attic != null) { + total_floors += props.building.size_storeys_attic; + } + if (props.building.size_storeys_core != null) { + total_floors += props.building.size_storeys_core; + } + if (props.building.size_storeys_basement != null) { + total_floors += props.building.size_storeys_basement; + } + + return ( + + + + + + + + + + - - } - - - - - - {(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.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.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.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) ? <> : - <> + - - } -
- - - - {(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) ? <> : - <> + + {(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.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) ? <> : + <> + + } +
+ + + + {(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) ? <> : + <> + + } +
+
+ ) +}; const SizeContainer = withCopyEdit(SizeView); export default SizeContainer;