From be93a8f6b41cd7276cc824135c31ed9cef1b4933 Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 8 May 2024 17:45:51 -0500 Subject: [PATCH 1/8] Create new var to determine if coords are present or not --- atd-vze/src/views/Crashes/Crash.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/atd-vze/src/views/Crashes/Crash.js b/atd-vze/src/views/Crashes/Crash.js index 659b27980..e6b131ab6 100644 --- a/atd-vze/src/views/Crashes/Crash.js +++ b/atd-vze/src/views/Crashes/Crash.js @@ -168,7 +168,8 @@ function Crash(props) { data && data?.atd_txdot_crashes.length > 0 && data?.atd_txdot_crashes[0]["location_id"]; - const notEditingCoords = !isEditingCoords && latitude && longitude; + const hasCoordinates = Boolean(latitude) && Boolean(longitude); + const notEditingCoords = !isEditingCoords && hasCoordinates; return !data?.atd_txdot_crashes?.length ? ( @@ -237,7 +238,7 @@ function Crash(props) { )
Geocode Provider:{" "} - {latitude && longitude + {hasCoordinates ? geocodeMethod.name : "No Primary Coordinates"} @@ -255,7 +256,7 @@ function Crash(props) { - {(!latitude || !longitude) && ( + {!hasCoordinates && ( Crash record is missing latitude and longitude values required for map display. From 68934eee61dbeb08ffdd38c1ac64b0f9b8403760 Mon Sep 17 00:00:00 2001 From: Mike Date: Thu, 9 May 2024 18:42:38 -0500 Subject: [PATCH 2/8] Make use column flex direction on Alert and Map in Crash view --- atd-vze/src/views/Crashes/Crash.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/atd-vze/src/views/Crashes/Crash.js b/atd-vze/src/views/Crashes/Crash.js index e6b131ab6..ada721388 100644 --- a/atd-vze/src/views/Crashes/Crash.js +++ b/atd-vze/src/views/Crashes/Crash.js @@ -169,7 +169,6 @@ function Crash(props) { data?.atd_txdot_crashes.length > 0 && data?.atd_txdot_crashes[0]["location_id"]; const hasCoordinates = Boolean(latitude) && Boolean(longitude); - const notEditingCoords = !isEditingCoords && hasCoordinates; return !data?.atd_txdot_crashes?.length ? ( @@ -255,14 +254,14 @@ function Crash(props) { - + {!hasCoordinates && ( Crash record is missing latitude and longitude values required for map display. )} - {notEditingCoords ? ( + {!isEditingCoords ? ( ) : ( Date: Thu, 9 May 2024 18:47:25 -0500 Subject: [PATCH 3/8] Display 'None' in CrashEditLatLonForm inputs if lat or lon is null --- atd-vze/src/views/Crashes/Maps/CrashEditLatLonForm.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atd-vze/src/views/Crashes/Maps/CrashEditLatLonForm.js b/atd-vze/src/views/Crashes/Maps/CrashEditLatLonForm.js index 51b0f73ca..f9738ccf6 100644 --- a/atd-vze/src/views/Crashes/Maps/CrashEditLatLonForm.js +++ b/atd-vze/src/views/Crashes/Maps/CrashEditLatLonForm.js @@ -21,7 +21,7 @@ export const CrashEditLatLonForm = ({ id="qa-latitude" name="qa-latitude" placeholder="" - value={truncateCoordinate(latitude)} + value={!!latitude ? truncateCoordinate(latitude) : "None"} readOnly /> @@ -36,7 +36,7 @@ export const CrashEditLatLonForm = ({ id="qa-longitude" name="qa-longitude" placeholder="" - value={truncateCoordinate(longitude)} + value={!!longitude ? truncateCoordinate(longitude) : "None"} readOnly /> From 0525b19dfe348bc075d7e4695d35d4568e3ac0c3 Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 10 May 2024 14:35:35 -0500 Subject: [PATCH 4/8] Double negate these lat/lon too --- atd-vze/src/views/Crashes/Crash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atd-vze/src/views/Crashes/Crash.js b/atd-vze/src/views/Crashes/Crash.js index ada721388..d4f6296ea 100644 --- a/atd-vze/src/views/Crashes/Crash.js +++ b/atd-vze/src/views/Crashes/Crash.js @@ -168,7 +168,7 @@ function Crash(props) { data && data?.atd_txdot_crashes.length > 0 && data?.atd_txdot_crashes[0]["location_id"]; - const hasCoordinates = Boolean(latitude) && Boolean(longitude); + const hasCoordinates = !!latitude && !!longitude; return !data?.atd_txdot_crashes?.length ? ( From 95feb8d34366fd8bb145e7fe55b2252b42e643df Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 10 May 2024 14:47:43 -0500 Subject: [PATCH 5/8] Give the marker the default lat/lon if the crash doesn't have them so it shows initially --- atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js b/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js index 910c2eb43..53c92af5b 100644 --- a/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js +++ b/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js @@ -31,8 +31,8 @@ const CrashEditCoordsMap = ({ const mapRef = React.useRef(); const [isDragging, setIsDragging] = React.useState(false); const [markerCoordinates, setMarkerCoordinates] = React.useState({ - latitude: latitude_primary, - longitude: longitude_primary, + latitude: latitude_primary || defaultInitialState.latitude, + longitude: longitude_primary || defaultInitialState.longitude, }); const [isSubmitting, setIsSubmitting] = React.useState(false); From 538f906a13874c7a04287fdbf6ead77ec49911e6 Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 10 May 2024 15:02:01 -0500 Subject: [PATCH 6/8] Add minHeight back in for when there is no crash diagram available --- atd-vze/src/views/Crashes/Crash.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/atd-vze/src/views/Crashes/Crash.js b/atd-vze/src/views/Crashes/Crash.js index d4f6296ea..ee08a09f1 100644 --- a/atd-vze/src/views/Crashes/Crash.js +++ b/atd-vze/src/views/Crashes/Crash.js @@ -254,7 +254,10 @@ function Crash(props) { - + {!hasCoordinates && ( Crash record is missing latitude and longitude values required From 9a6e6291a1ccde3ef619a1afbe87f32d050b5472 Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 10 May 2024 15:29:17 -0500 Subject: [PATCH 7/8] Initialize marker coords props with default and not state --- atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js b/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js index 53c92af5b..d4f89393e 100644 --- a/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js +++ b/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js @@ -31,8 +31,8 @@ const CrashEditCoordsMap = ({ const mapRef = React.useRef(); const [isDragging, setIsDragging] = React.useState(false); const [markerCoordinates, setMarkerCoordinates] = React.useState({ - latitude: latitude_primary || defaultInitialState.latitude, - longitude: longitude_primary || defaultInitialState.longitude, + latitude: latitude_primary, + longitude: longitude_primary, }); const [isSubmitting, setIsSubmitting] = React.useState(false); @@ -108,7 +108,12 @@ const CrashEditCoordsMap = ({ > - + {/* add nearmap raster source and style */} From 6c4dce4ff4b4043ff9f1a05211b6f142ab4800fc Mon Sep 17 00:00:00 2001 From: Mike Date: Fri, 10 May 2024 15:40:29 -0500 Subject: [PATCH 8/8] Fix yet another small bug --- atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js b/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js index d4f89393e..0cae826b3 100644 --- a/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js +++ b/atd-vze/src/views/Crashes/Maps/CrashEditCoordsMap.js @@ -72,7 +72,7 @@ const CrashEditCoordsMap = ({ // Reset marker to original coordinates or default fallback const originalMarkerCoordinates = { latitude: latitude_primary || defaultInitialState.latitude, - longitude: longitude_primary || defaultInitialState.latitude, + longitude: longitude_primary || defaultInitialState.longitude, }; // Move map center and marks to original coordinates or default fallback