Displaying differences for changeset
 
display as  

static/er2_303d_assess/js/actions/assessment_tracking.js

@@ -3,12 +3,23 @@
 import { setMapMessage } from "@owsi/catena/er2_map_userlayers/js/actions"
 import { appendToLogger } from "@owsi/catena/er2_map_userlayers/js/actions/logger"
 import * as types from "../constants/action_types"
+import {SET_ASSESSMENT_REGISTRY_LIST} from "../constants/action_types";
 
 export const updateAssessmentTracking = (assessmentTracking) => ({
     type: types.SET_ASSESSMENT_TRACKING,
     assessmentTracking,
 })
 
+export const setAssessmentRegistryList = (registryList) => ({
+    type: types.SET_ASSESSMENT_REGISTRY_LIST,
+    registryList,
+})
+
+export const setTrackingSheet = (selectedTrackingSheet) => ({
+    type: types.SET_CURRENT_TRACKING_SHEET,
+    selectedTrackingSheet,
+})
+
 export const onUpdateAssessmentTracking = () => (dispatch, getState) => {
     // This has two uses:
     // 1) load a selected tracking sheet, i.e. when you get to the website for the first time or change which tracking sheet you are on
@@ -42,3 +53,43 @@
         })
         .catch((res) => console.error(res))
 }
+
+export const onLoadTrackingRegistry = () => async (dispatch, getState) => {
+    // dispatch(setZoneFetching(true))
+    let hasError = false
+    fetch(
+        `/${getState().meta.name}/load_assessment_registry/?token=${
+            getState().token.value
+        }`,
+        {
+            body: JSON.stringify({}),
+            method: "POST",
+        },
+    )
+        .then((res) => {
+            hasError = res.status !== 200
+            return res.json()
+        })
+        .then((json) => {
+            if (hasError) {
+                dispatch(appendToLogger([json]))
+                dispatch(
+                    setMapMessage(
+                        "Tracking registry options failed to retrieve. See logger.",
+                    ),
+                )
+            } else {
+                dispatch(setTrackingRegistry(json))
+                const selectedTrackingSheet = selectedTrackingsheet[0]
+                dispatch(onSetTrackingSheet(selectedTrackingSheet))
+            }
+        })
+
+
+    // dispatch(setZoneFetching(false))
+}
+
+export const onSetTrackingSheet = (selectedTrackingSheet) => async (dispatch, getState) => {
+    dispatch(setTrackingSheet(selectedTrackingSheet))
+    dispatch(onUpdateAssessmentTracking(selectedTrackingSheet))
+}

static/er2_303d_assess/js/components/assessment_tracking.js

@@ -11,6 +11,26 @@
 }
 
 function AssessmentTracking(props: Props) {
+    const dispatch = useDispatch()
+    const handleSelectTrackingSheet = (e) => {
+        let currentTrackingSheet
+        if (e.target.value !== "") {
+            currentTrackingSheet = e.target.value
+        }
+        dispatch(onSetTrackingSheet(currentTrackingSheet))
+    }
+
+    const trackingSheetNames = React.useMemo(
+        () =>
+            floodPotential.zoneFeatures
+                ? floodPotential.zoneFeatures.map((f) => [
+                    f.get("Zone"),
+                    `${f.get("Zone")} (${f.get("ZoneName")})`,
+                ])
+                : [],
+        [floodPotential.zoneFeatures],
+    )
+
     function renderAssessmentChart() {
         const { basins } = props.assessmentTracking.registry
         if (basins) {
@@ -87,7 +107,29 @@
     }
 
     return (
-        <div className={props.theme.controlBar}>{renderAssessmentChart()}</div>
+        <div style={{ marginTop: 20, position: "relative" }}>
+            <div style={{ display: "flex", flexFlow: "row nowrap" }}>
+                <PaddedDiv>
+                    <FormControl fullWidth>
+                        <InputLabel htmlFor="assess_sel">
+                            Select a Tracking Sheet for an Assessment Cycle
+                        </InputLabel>
+                        <Select
+                            inputProps={{name: "assess_sel",}}
+                            onChange={handleSelectTrackingSheet}
+                            value={"2021 Arkansas-Rio Grande"}
+                        >
+                            {trackingSheetNames.map((z, i) => (
+                                <MenuItem key={z[0]} value={z[0]}>
+                                    {z[1]}
+                                </MenuItem>
+                            ))}
+                        </Select>
+                    </FormControl>
+                </PaddedDiv>
+            </div>
+            <div className={props.theme.controlBar}>{renderAssessmentChart()}</div>
+        </div>
     )
 }
 

static/er2_303d_assess/js/constants/action_types.js

@@ -18,7 +18,9 @@
 export const SET_AOI_STATE = "SET_AOI_STATE"
 export const SET_ASSESSMENTS = "SET_ASSESSMENTS"
 export const SET_ASSESSMENT_TAB = "SET_ASSESSMENT_TAB"
+export const SET_ASSESSMENT_REGISTRY_LIST = "SET_ASSESSMENT_REGISTRY_LIST"
 export const SET_ASSESSMENT_TRACKING = "SET_ASSESSMENT_TRACKING"
+export const SET_CURRENT_TRACKING_SHEET = "SET_CURRENT_TRACKING_SHEET"
 export const SET_AUID_FILTER = "SET_AUID_FILTER"
 export const SET_AUIDS = "SET_AUIDS"
 export const SET_CSV = "SET_CSV"

static/er2_303d_assess/js/reducers/assessment_tracking.js

@@ -10,13 +10,15 @@
 
 export type AssessmentTrackingType = {
     visible: boolean,
-    assessments: AssessmentTrackingItemType[],
+    registryList: string[],
+    selectedTrackingSheet: string
     registry: {
         basins: {
             name: string,
             basin: string,
         }[],
     },
+    assessments: AssessmentTrackingItemType[],
 }
 
 const initialState = {
@@ -36,6 +38,12 @@
             state.visible = !state.visible
         }
     },
+    [actionTypes.SET_ASSESSMENT_REGISTRY_LIST]: (state, action) => {
+        state.registryList = action.assessmentTracking.registryList
+    },
+    [actionTypes.SET_CURRENT_TRACKING_SHEET]: (state, action) => {
+        state.selectedTrackingSheet = action.assessmentTracking.selectedTrackingSheet
+    },
     [actionTypes.SET_ASSESSMENT_TRACKING]: (state, action) => {
         state.assessments = action.assessmentTracking.assessments
         state.registry = action.assessmentTracking.registry