From 05b28ed23762ef4cb24276cfb4aa741ca8f1fccf Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Tue, 3 Jan 2023 17:41:44 +0100 Subject: [PATCH 01/14] rename field in Location section --- app/src/frontend/config/data-fields-config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/frontend/config/data-fields-config.ts b/app/src/frontend/config/data-fields-config.ts index bddd225e..f7df04c1 100644 --- a/app/src/frontend/config/data-fields-config.ts +++ b/app/src/frontend/config/data-fields-config.ts @@ -118,7 +118,7 @@ export const buildingUserFields = { export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ location_name: { category: Category.Location, - title: "Building information (link)", + title: "Building Name (Information link)", tooltip: "Link to a website with information on the building, not needed for most.", example: "https://en.wikipedia.org/wiki/Palace_of_Westminster", }, From 38947b6cd8caccf74770845f1dd428e2849490dd Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Wed, 4 Jan 2023 13:04:58 +0100 Subject: [PATCH 02/14] remove no longer needed hint replaced by notice in the sidebar --- app/src/frontend/map/map.css | 13 ------------- app/src/frontend/map/map.tsx | 6 ------ 2 files changed, 19 deletions(-) diff --git a/app/src/frontend/map/map.css b/app/src/frontend/map/map.css index 00a265a3..95466458 100644 --- a/app/src/frontend/map/map.css +++ b/app/src/frontend/map/map.css @@ -28,19 +28,6 @@ .leaflet-grab { cursor: crosshair; } -.map-notice { - position: absolute; - top: 3.5rem; - left: 0.5rem; - z-index: 1000; - padding: 0.5rem 0.75rem; - width: 250px; - background: #fff; - border: 1px solid #fff; - border-radius: 4px; - box-shadow: 0px 0px 1px 1px #222; - display: none; -} @media (min-width: 990px){ /* Only show the "Click a building ..." notice for larger screens */ .map-notice { diff --git a/app/src/frontend/map/map.tsx b/app/src/frontend/map/map.tsx index 80261c67..9b96e426 100644 --- a/app/src/frontend/map/map.tsx +++ b/app/src/frontend/map/map.tsx @@ -165,12 +165,6 @@ export const ColouringMap : FC = ({ { mode !== 'basic' && <> - { - !hasSelection && -
- {isEdit ? 'Click a building to edit' : 'Click a building for details'} -
- } From 31b75fa0413deccfc5d351d46e3b1b4acb16cf57 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Wed, 4 Jan 2023 13:10:45 +0100 Subject: [PATCH 03/14] fix typo in performance optimization --- app/src/tiles/rendererDefinition.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/tiles/rendererDefinition.ts b/app/src/tiles/rendererDefinition.ts index f47ec8f4..d42911ba 100644 --- a/app/src/tiles/rendererDefinition.ts +++ b/app/src/tiles/rendererDefinition.ts @@ -53,7 +53,7 @@ const tileCache = new TileCache( shouldCacheFn, // don't clear on bounding box cache clear tilesets not affected by user-editable data - (tileset: string) => tileset !== 'base_light' && tileset !== 'base_night' && tileset !== 'base_night_outlines' && tileset !== 'base_burough' && tileset !== "planning_applications_status_recent" && tileset !== "planning_applications_status_very_recent" && tileset !== "planning_applications_status_all" + (tileset: string) => tileset !== 'base_light' && tileset !== 'base_night' && tileset !== 'base_night_outlines' && tileset !== 'base_borough' && tileset !== "planning_applications_status_recent" && tileset !== "planning_applications_status_very_recent" && tileset !== "planning_applications_status_all" ); const renderBuildingTile = (t: TileParams, d: any) => renderDataSourceTile(t, d, getDataConfig, getLayerVariables); From cf90e052ed826e1818e64ca1ecb81022684d4de1 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Wed, 4 Jan 2023 13:17:56 +0100 Subject: [PATCH 04/14] fix some typos --- migrations/011.sustainability.down.sql | 6 +++--- migrations/011.sustainability.down1-extra.sql | 4 ++-- migrations/011.sustainability.up.sql | 2 +- migrations/011.sustainability.up1-extra.sql | 4 ++-- migrations/016.landuse.down.sql | 2 +- migrations/016.landuse.up.sql | 6 +++--- migrations/022.community.down.sql | 2 +- migrations/unreleased/0xx.team.down.sql | 2 +- migrations/unreleased/0xx.team.up.sql | 2 +- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/migrations/011.sustainability.down.sql b/migrations/011.sustainability.down.sql index a1279e3e..68740b84 100644 --- a/migrations/011.sustainability.down.sql +++ b/migrations/011.sustainability.down.sql @@ -1,15 +1,15 @@ --- Remove sustainability fields, update in paralell with adding new fields +-- Remove sustainability fields, update in parallel with adding new fields -- BREEAM rating ALTER TABLE buildings DROP COLUMN IF EXISTS sust_breeam_rating; -- BREEAM date ALTER TABLE buildings DROP COLUMN IF EXISTS sust_breeam_date; --- DEC (display energy certifcate, only applies to non domestic buildings) +-- DEC (display energy certificate, only applies to non domestic buildings) ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec; -- DEC date ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec_date; ---DEC certifcate lmk key, this would be lmkkey, no online lookup but can scrape through API. Numeric (25) +--DEC certificate lmk key, this would be lmkkey, no online lookup but can scrape through API. Numeric (25) ALTER TABLE buildings DROP COLUMN IF EXISTS sust_dec_lmkey; -- Aggregate EPC rating (Estimated) for a building, derived from inidividual certificates diff --git a/migrations/011.sustainability.down1-extra.sql b/migrations/011.sustainability.down1-extra.sql index 0dc39b72..385b36aa 100644 --- a/migrations/011.sustainability.down1-extra.sql +++ b/migrations/011.sustainability.down1-extra.sql @@ -1,4 +1,4 @@ --- Remove sustainability fields, update in paralell with adding new fields +-- Remove sustainability fields, update in parallel with adding new fields -- Last significant retrofit date YYYY -- Need to add a constraint to sust_retrofit_date -- Renewal technologies @@ -6,7 +6,7 @@ -- Values: ALTER TABLE buildings DROP COLUMN IF EXISTS sust_renewables_tech; ---Has a building had a major renovation without extenstion (captured in form) +--Has a building had a major renovation without extension (captured in form) --Boolean yes/no - links to the the DATE ALTER TABLE buildings DROP COLUMN IF EXISTS sust_retrofitted; diff --git a/migrations/011.sustainability.up.sql b/migrations/011.sustainability.up.sql index 500fe728..a6e7fac0 100644 --- a/migrations/011.sustainability.up.sql +++ b/migrations/011.sustainability.up.sql @@ -20,7 +20,7 @@ ALTER TABLE buildings ALTER TABLE buildings ADD COLUMN IF NOT EXISTS sust_breeam_date smallint; --- DEC (display energy certifcate, only applies to non domestic buildings) +-- DEC (display energy certificate, only applies to non domestic buildings) -- A - G CREATE TYPE sust_dec AS ENUM ('A', diff --git a/migrations/011.sustainability.up1-extra.sql b/migrations/011.sustainability.up1-extra.sql index 11cc62d5..bcf9864e 100644 --- a/migrations/011.sustainability.up1-extra.sql +++ b/migrations/011.sustainability.up1-extra.sql @@ -1,10 +1,10 @@ --- Remove sustainability fields, update in paralell with adding new fields +-- Remove sustainability fields, update in parallel with adding new fields -- Last significant retrofit date YYYY -- Need to add a constraint to sust_retrofit_date ALTER TABLE buildings ADD CONSTRAINT sust_retrofit_date_end CHECK (sust_retrofit_date <= DATE_PART('year', CURRENT_DATE)); ---Has a building had a major renovation without extenstion (captured in form) +--Has a building had a major renovation without extension (captured in form) --Boolean yes/no - links to the the DATE ALTER TABLE buildings ADD COLUMN IF NOT EXISTS sust_retrofitted boolean DEFAULT 'n'; diff --git a/migrations/016.landuse.down.sql b/migrations/016.landuse.down.sql index 5e1f869b..02f0cfbf 100644 --- a/migrations/016.landuse.down.sql +++ b/migrations/016.landuse.down.sql @@ -1,4 +1,4 @@ ---Landuse is hierachical. Highest level is Order (ie. Residential) then Group (ie Residential-Dwelling) then Class (ie Residential-Dwelling-Detached house) +--Landuse is hierarchical. Highest level is Order (ie. Residential) then Group (ie Residential-Dwelling) then Class (ie Residential-Dwelling-Detached house) --Interface will collected most detailed (class) but visualise highest level (order) --Landuse is a table as #358 --Land use class, group and order will be stored in a new table diff --git a/migrations/016.landuse.up.sql b/migrations/016.landuse.up.sql index f182f9b6..bb9c668a 100644 --- a/migrations/016.landuse.up.sql +++ b/migrations/016.landuse.up.sql @@ -1,5 +1,5 @@ -- Create land use and fields ---Landuse is hierachical. Highest level is Order (Residential) then Group (Residential-Dwelling) then Class (Residential-Dwelling-Detached house) +--Landuse is hierarchical. Highest level is Order (Residential) then Group (Residential-Dwelling) then Class (Residential-Dwelling-Detached house) --Some ETL work required to get this together refer to analysis repo --Prerequesite is to have first run bulk_data_sources migrations --Then create table landuse_order for the app, this is used as foreign key for current and original landuse_order @@ -36,11 +36,11 @@ FROM reference_tables.landuse_classifications a WHERE a.level = 'class' AND a.is_used; ---Landuse is hierachical. Highest level is Order (Residential) then Group (Residential-Dwelling) then Class (Residential-Dwelling-Detached house) +--Landuse is hierarchical. Highest level is Order (Residential) then Group (Residential-Dwelling) then Class (Residential-Dwelling-Detached house) --Interface will collected most detailed (class) but visualise highest level (order) --Landuse is a table as #358 --Prerequisite run bulk_sources migration first - -- Land use is table with 3 levels of hierachy (highest to lowest). order > group > class + -- Land use is table with 3 levels of hierarchy (highest to lowest). order > group > class -- Land use order, singular. Client and db constrained with foreign key diff --git a/migrations/022.community.down.sql b/migrations/022.community.down.sql index 83431649..01030579 100644 --- a/migrations/022.community.down.sql +++ b/migrations/022.community.down.sql @@ -3,7 +3,7 @@ -- -- Ownership type, enumerate type from: -- ALTER TABLE buildings DROP COLUMN IF EXISTS ownership_type; --- -- Ownerhsip perception, would you describe this as a community asset? +-- -- Ownership perception, would you describe this as a community asset? -- -- Boolean yes / no -- ALTER TABLE buildings DROP COLUMN IF EXISTS ownership_perception; diff --git a/migrations/unreleased/0xx.team.down.sql b/migrations/unreleased/0xx.team.down.sql index 6d34b6de..1257501f 100644 --- a/migrations/unreleased/0xx.team.down.sql +++ b/migrations/unreleased/0xx.team.down.sql @@ -1,3 +1,3 @@ --- Remove team fields, update in paralell with adding new fields +-- Remove team fields, update in parallel with adding new fields -- Award or awards (may be multiple) stored as json b object ALTER TABLE buildings DROP COLUMN IF EXISTS team_awards; diff --git a/migrations/unreleased/0xx.team.up.sql b/migrations/unreleased/0xx.team.up.sql index ac9868f3..050770e5 100644 --- a/migrations/unreleased/0xx.team.up.sql +++ b/migrations/unreleased/0xx.team.up.sql @@ -3,6 +3,6 @@ ALTER TABLE buildings ADD COLUMN IF NOT EXISTS team_awards jsonb; ---To validate this input, the following confirms it's an valid object but not that the items in the object are validated agains those we will acccept +--To validate this input, the following confirms it's an valid object but not that the items in the object are validated against those we will accept ALTER TABLE buildings ADD CONSTRAINT data_is_valid CHECK (is_jsonb_valid ('{"type": "object"}', team_awards)); From 60397aaefb1d678417ff9551ec7a386f68c73880 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Wed, 4 Jan 2023 16:22:55 +0100 Subject: [PATCH 05/14] set message about planned layer to yellow for conistency with other similar boxes --- app/src/frontend/building/data-containers/streetscape.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/frontend/building/data-containers/streetscape.tsx b/app/src/frontend/building/data-containers/streetscape.tsx index ff25d7bc..4a0ee069 100644 --- a/app/src/frontend/building/data-containers/streetscape.tsx +++ b/app/src/frontend/building/data-containers/streetscape.tsx @@ -13,7 +13,7 @@ import { CategoryViewProps } from './category-view-props'; */ const StreetscapeView: React.FunctionComponent = (props) => ( - +
  • Gardens
  • Trees
  • From 7f48ffeb7c2661b9588057cc341dd17cc2e19d12 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Fri, 6 Jan 2023 11:36:23 +0100 Subject: [PATCH 06/14] just immediately go to the first match and do not show hard to dismiss dropdown --- app/src/frontend/map/search-box.tsx | 31 ++--------------------------- 1 file changed, 2 insertions(+), 29 deletions(-) diff --git a/app/src/frontend/map/search-box.tsx b/app/src/frontend/map/search-box.tsx index 132b57a8..ac06984c 100644 --- a/app/src/frontend/map/search-box.tsx +++ b/app/src/frontend/map/search-box.tsx @@ -103,10 +103,7 @@ class SearchBox extends Component { apiGet(`/api/search?q=${this.state.q}`) .then((data) => { if (data && data.results){ - this.setState({ - results: data.results, - fetching: false - }); + this.props.onLocate(data.results[0].geometry.coordinates[1], data.results[0].geometry.coordinates[0], data.results[0].attributes.zoom) } else { console.error(data); @@ -157,31 +154,7 @@ class SearchBox extends Component { ); } - const resultsList = this.state.results.length? - - : null; + const resultsList = null; return (
    From 1bec59d269917f750922c684f5ba75ace0369156 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Fri, 6 Jan 2023 12:33:23 +0100 Subject: [PATCH 07/14] Make status title less confusing especially for historic data 'current' was confusing also it is shorter and easier to read fixes #1013 --- .../frontend/building/data-components/planning-data-entry.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/frontend/building/data-components/planning-data-entry.tsx b/app/src/frontend/building/data-components/planning-data-entry.tsx index cb4643e0..d062bf96 100644 --- a/app/src/frontend/building/data-components/planning-data-entry.tsx +++ b/app/src/frontend/building/data-components/planning-data-entry.tsx @@ -99,7 +99,7 @@ const PlanningDataOfficialDataEntry: React.FC -
    Current planning application status for this site: Planning application status for this site:
    From 14c2860d7996d10a9a2c566795897a73161ce0f7 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Mon, 9 Jan 2023 17:26:54 +0100 Subject: [PATCH 08/14] better margin handling for category buttons --- app/src/frontend/building/category-link.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/frontend/building/category-link.css b/app/src/frontend/building/category-link.css index 6ec547f0..cca4315b 100644 --- a/app/src/frontend/building/category-link.css +++ b/app/src/frontend/building/category-link.css @@ -3,7 +3,7 @@ justify-content: center; align-items: center; box-sizing: border-box; - /* padding: 0.1em; */ + padding: 0.5em; width: 100%; height: 100%; } From b225c9e8ae04790ae0259ae7135529bf7e3d5edd Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Mon, 9 Jan 2023 17:32:21 +0100 Subject: [PATCH 09/14] label on top of lines --- .../map/layers/borough-boundary-layer.tsx | 19 +++++-------------- .../map/layers/borough-label-layer.tsx | 17 +++++++++++++++++ app/src/frontend/map/map.tsx | 7 +++++++ 3 files changed, 29 insertions(+), 14 deletions(-) create mode 100644 app/src/frontend/map/layers/borough-label-layer.tsx diff --git a/app/src/frontend/map/layers/borough-boundary-layer.tsx b/app/src/frontend/map/layers/borough-boundary-layer.tsx index aaec43f6..752efc65 100644 --- a/app/src/frontend/map/layers/borough-boundary-layer.tsx +++ b/app/src/frontend/map/layers/borough-boundary-layer.tsx @@ -15,23 +15,14 @@ export function BoroughBoundaryLayer({}) { }, []); if(borough == "enabled") { - return boundaryGeojson && - <>; - } else if (borough == "disabled") { - return
    - // do not display anything return boundaryGeojson && + attribution='Borough boundary from London Datastore Ordnance Survey Open Data - Contains public sector information licensed under the Open Government Licence v3.0' + data={boundaryGeojson} + style={{color: '#f00', fill: false, weight: 1}} + />; } else { - return boundaryGeojson && - ; + return <> } } diff --git a/app/src/frontend/map/layers/borough-label-layer.tsx b/app/src/frontend/map/layers/borough-label-layer.tsx new file mode 100644 index 00000000..34787602 --- /dev/null +++ b/app/src/frontend/map/layers/borough-label-layer.tsx @@ -0,0 +1,17 @@ +import { GeoJsonObject } from 'geojson'; +import React, { useEffect, useState } from 'react'; +import { GeoJSON } from 'react-leaflet'; +import { useDisplayPreferences } from '../../displayPreferences-context'; +import { apiGet } from '../../apiHelpers'; +import { BuildingBaseLayerAllZoom } from './building-base-layer-all-zoom'; + +export function BoroughLabelLayer({}) { + const { borough } = useDisplayPreferences(); + + if(borough == "enabled") { + return ; + } else { + return <> + } +} + diff --git a/app/src/frontend/map/map.tsx b/app/src/frontend/map/map.tsx index 80261c67..c35ea3dc 100644 --- a/app/src/frontend/map/map.tsx +++ b/app/src/frontend/map/map.tsx @@ -14,6 +14,7 @@ import { Building } from '../models/building'; import { CityBaseMapLayer } from './layers/city-base-map-layer'; import { CityBoundaryLayer } from './layers/city-boundary-layer'; import { BoroughBoundaryLayer } from './layers/borough-boundary-layer'; +import { BoroughLabelLayer } from './layers/borough-label-layer'; import { ParcelBoundaryLayer } from './layers/parcel-boundary-layer'; import { HistoricDataLayer } from './layers/historic-data-layer'; import { FloodBoundaryLayer } from './layers/flood-boundary-layer'; @@ -158,6 +159,12 @@ export const ColouringMap : FC = ({ /> } + + + From e89e79671c97f7e262b9efe5bb9b55aca4548df4 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Mon, 9 Jan 2023 18:37:36 +0100 Subject: [PATCH 10/14] better place for extra padding --- app/src/frontend/building/category-link.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/frontend/building/category-link.css b/app/src/frontend/building/category-link.css index cca4315b..d72ab0f8 100644 --- a/app/src/frontend/building/category-link.css +++ b/app/src/frontend/building/category-link.css @@ -3,7 +3,6 @@ justify-content: center; align-items: center; box-sizing: border-box; - padding: 0.5em; width: 100%; height: 100%; } @@ -18,5 +17,6 @@ text-align: center; font-size: 1em; margin: 0; + padding: 0.5em; } \ No newline at end of file From e4bfa4ba4180662c144a9c03e24e49a526a16884 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Mon, 9 Jan 2023 18:49:46 +0100 Subject: [PATCH 11/14] reduce extra padding to avoid unexpected runaway boxes --- app/src/frontend/building/category-link.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/frontend/building/category-link.css b/app/src/frontend/building/category-link.css index d72ab0f8..b495e77b 100644 --- a/app/src/frontend/building/category-link.css +++ b/app/src/frontend/building/category-link.css @@ -17,6 +17,6 @@ text-align: center; font-size: 1em; margin: 0; - padding: 0.5em; + padding: 0.25em; } \ No newline at end of file From 6e6852191a77f63413b3665bf96f4b5d5dcc1b60 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Tue, 10 Jan 2023 16:12:46 +0100 Subject: [PATCH 12/14] adjust flex to work better with long titles --- app/src/frontend/building/container-header.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/frontend/building/container-header.css b/app/src/frontend/building/container-header.css index 04c81d33..0b3fa068 100644 --- a/app/src/frontend/building/container-header.css +++ b/app/src/frontend/building/container-header.css @@ -17,7 +17,7 @@ .section-header .h2 { display: inline-block; - flex-basis: 150px; + flex-basis: 200px; flex-shrink: 0; flex-grow: 1; margin: 0.75rem 0 0.5em 0.1em; @@ -33,7 +33,8 @@ .section-header .section-header-actions { display: inline-block; - flex-basis: 400px; + flex-basis: 220px; + flex-shrink: 0; display: flex; flex-flow: row wrap; align-items: center; From 55b1a46c573818a7870d8cfb172fae834bfbb4cc Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Tue, 10 Jan 2023 16:23:49 +0100 Subject: [PATCH 13/14] proper check on login --- app/src/frontend/route.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/frontend/route.tsx b/app/src/frontend/route.tsx index 1d595d22..c43beae9 100644 --- a/app/src/frontend/route.tsx +++ b/app/src/frontend/route.tsx @@ -39,7 +39,7 @@ export const AuthRoute: React.FC = ({ component: Component, children if(isAuthenticated) { let state = props.location.state as any; let from = '/my-account.html'; - if (typeof state == 'object' && 'from' in state){ + if (typeof state == 'object' && state !== null && 'from' in state) { from = state.from; } From 9c07119e6d9e3e39ce9a7f65cb6759b8d1fb452b Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Tue, 10 Jan 2023 21:40:16 +0100 Subject: [PATCH 14/14] add button to reset overlay state --- .../frontend/displayPreferences-context.tsx | 78 +++++++++++++++++-- app/src/frontend/map/map-button.css | 8 ++ app/src/frontend/map/map.tsx | 2 + app/src/frontend/map/reset-switcher.tsx | 20 +++++ 4 files changed, 100 insertions(+), 8 deletions(-) create mode 100644 app/src/frontend/map/reset-switcher.tsx diff --git a/app/src/frontend/displayPreferences-context.tsx b/app/src/frontend/displayPreferences-context.tsx index bde2d89d..67c0f69a 100644 --- a/app/src/frontend/displayPreferences-context.tsx +++ b/app/src/frontend/displayPreferences-context.tsx @@ -3,6 +3,9 @@ import React, { createContext, useCallback, useContext, useEffect, useState } fr import { LayerEnablementState, MapTheme } from './config/map-config'; interface DisplayPreferencesContextState { + resetLayers: (e: React.FormEvent) => void; + anyLayerModifiedState: () => boolean; + vista: LayerEnablementState; vistaSwitch: (e: React.FormEvent) => void; vistaSwitchOnClick: React.MouseEventHandler; @@ -45,6 +48,9 @@ const stub = (): never => { }; export const DisplayPreferencesContext = createContext({ + resetLayers: stub, + anyLayerModifiedState: stub, + vista: undefined, vistaSwitch: stub, vistaSwitchOnClick: undefined, @@ -85,16 +91,69 @@ export const DisplayPreferencesContext = createContext {}; export const DisplayPreferencesProvider: React.FC<{}> = ({children}) => { - const [vista, setVista] = useState('disabled'); - const [flood, setFlood] = useState('disabled'); - const [creative, setCreative] = useState('disabled'); - const [housing, setHousing] = useState('disabled'); - const [borough, setBorough] = useState('enabled'); - const [parcel, setParcel] = useState('disabled'); - const [conservation, setConservation] = useState('disabled'); - const [historicData, setHistoricData] = useState('disabled'); + const defaultVista = 'disabled' + const defaultFlood = 'disabled' + const defaultCreative = 'disabled' + const defaultHousing = 'disabled' + const defaultBorough = 'enabled' + const defaultParcel = 'disabled' + const defaultConservation = 'disabled' + const defaultHistoricData = 'disabled' + const [vista, setVista] = useState(defaultVista); + const [flood, setFlood] = useState(defaultFlood); + const [creative, setCreative] = useState(defaultCreative); + const [housing, setHousing] = useState(defaultHousing); + const [borough, setBorough] = useState(defaultBorough); + const [parcel, setParcel] = useState(defaultParcel); + const [conservation, setConservation] = useState(defaultConservation); + const [historicData, setHistoricData] = useState(defaultHistoricData); const [darkLightTheme, setDarkLightTheme] = useState('night'); + const resetLayers = useCallback( + (e) => { + e.preventDefault(); + setVista(defaultVista); + setFlood(defaultFlood); + setCreative(defaultCreative); + setHousing(defaultHousing); + setBorough(defaultBorough) + setParcel(defaultParcel); + setConservation(defaultConservation); + setHistoricData(defaultHistoricData); + //setDarkLightTheme('night'); // reset only layers + }, + [] + ) + + function anyLayerModifiedState() { + if(vista != defaultVista) { + return true; + } + if(flood != defaultFlood) { + return true; + } + if(creative != defaultCreative) { + return true; + } + if(housing != defaultHousing) { + return true; + } + if(borough != defaultBorough) { + return true; + } + if(parcel != defaultParcel) { + return true; + } + if(conservation != defaultConservation) { + return true; + } + if(historicData != defaultHistoricData) { + return true; + } + //darkLightTheme not handled here + return false; + } + const vistaSwitch = useCallback( (e) => { e.preventDefault(); @@ -233,6 +292,9 @@ export const DisplayPreferencesProvider: React.FC<{}> = ({children}) => { return ( = ({ mode !== 'basic' && <> + { diff --git a/app/src/frontend/map/reset-switcher.tsx b/app/src/frontend/map/reset-switcher.tsx new file mode 100644 index 00000000..d8c06845 --- /dev/null +++ b/app/src/frontend/map/reset-switcher.tsx @@ -0,0 +1,20 @@ +import React from 'react'; + +import './map-button.css'; +import { useDisplayPreferences } from '../displayPreferences-context'; + +export const ResetSwitcher: React.FC<{}> = () => { + const { resetLayers, darkLightTheme, anyLayerModifiedState } = useDisplayPreferences(); + if(anyLayerModifiedState()) { + return ( +
    + +
    + ); + } else { + return <> + } +}