Displaying differences for changeset
 
display as  

static/er2_303d_assess/js/actions/assessment_summary.js

@@ -2,7 +2,7 @@
 import { setMapMessage } from "@owsi/catena/er2_map_userlayers/js/actions"
 import * as types from "../constants/action_types"
 import { updateAppState } from "./server_state"
-import { onUpdateAssessmentTracking } from "./assessment_tracking"
+import { onUpdateTrackingSheetContent } from "./assessment_tracking"
 
 export const setAssessmentSummaryType = (summaryType) => ({
     type: types.SET_ASSESSMENT_SUMMARY_TYPE,
@@ -35,7 +35,7 @@
                     ),
                 )
             } else {
-                dispatch(onUpdateAssessmentTracking())
+                dispatch(onUpdateTrackingSheetContent())
                 dispatch(setMapMessage(res.ret))
             }
         })
@@ -72,7 +72,7 @@
                     ),
                 )
             } else {
-                dispatch(onUpdateAssessmentTracking())
+                dispatch(onUpdateTrackingSheetContent())
                 dispatch(setMapMessage(res.ret))
             }
         })

static/er2_303d_assess/js/actions/assessment_tracking.js

@@ -3,24 +3,24 @@
 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,
+export const setTrackingRegistryList = (registryList) => ({
+    type: types.SET_TRACKING_REGISTRY_LIST,
     registryList,
 })
 
 export const setTrackingSheet = (selectedTrackingSheet) => ({
-    type: types.SET_CURRENT_TRACKING_SHEET,
+    type: types.SET_CURRENT_TRACKING_SHEET_KEY,
     selectedTrackingSheet,
 })
 
-export const onUpdateAssessmentTracking = () => (dispatch, getState) => {
+export const updateTrackingSheetContent = (assessmentTracking) => ({
+    type: types.SET_TRACKING_SHEET_CONTENT,
+    assessmentTracking,
+})
+
+
+export const onUpdateTrackingSheetContent = () => (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
     // 2) reload the data for a selected tracking sheet after it has been modified (add/update/delete of an assessment entry)
@@ -44,11 +44,11 @@
                 dispatch(appendToLogger([json]))
                 dispatch(
                     setMapMessage(
-                        "Tracking sheet retrieval failed. See logger.",
+                        "Failed to retrieve and update the specified Tracking. See logger.",
                     ),
                 )
             } else {
-                dispatch(updateAssessmentTracking(json))
+                dispatch(updateTrackingSheetContent(json))
             }
         })
         .catch((res) => console.error(res))
@@ -61,10 +61,10 @@
         `/${getState().meta.name}/load_assessment_registry/?token=${
             getState().token.value
         }`,
-        {
-            body: JSON.stringify({}),
-            method: "POST",
-        },
+            {
+                body: "",
+                method: "POST",
+            },
     )
         .then((res) => {
             hasError = res.status !== 200
@@ -79,9 +79,9 @@
                     ),
                 )
             } else {
-                dispatch(setTrackingRegistry(json))
-                const selectedTrackingSheet = selectedTrackingsheet[0]
-                dispatch(onSetTrackingSheet(selectedTrackingSheet))
+                dispatch(setTrackingRegistryList(json))
+                const selectedTrackingSheet = json[0]
+                dispatch(onSetCurrentTrackingSheetKey(selectedTrackingSheet))
             }
         })
 
@@ -89,7 +89,7 @@
     // dispatch(setZoneFetching(false))
 }
 
-export const onSetTrackingSheet = (selectedTrackingSheet) => async (dispatch, getState) => {
-    dispatch(setTrackingSheet(selectedTrackingSheet))
-    dispatch(onUpdateAssessmentTracking(selectedTrackingSheet))
+export const onSetCurrentTrackingSheetKey = (selectedTrackingSheet) => async (dispatch, getState) => {
+    dispatch(setCurrentTrackingSheetKey(selectedTrackingSheet))
+    dispatch(onUpdateTrackingSheetContent(selectedTrackingSheet))
 }

static/er2_303d_assess/js/actions/server_state.js

@@ -7,7 +7,7 @@
 import { updateUser } from "@owsi/catena/er2_ui/actions"
 import * as types from "../constants/action_types"
 import { getStreams, runRetrieval, setAssessments, setAUIDfilter } from "./aoi"
-import { onUpdateAssessmentTracking } from "./assessment_tracking"
+import { onLoadTrackingRegistry } from "./assessment_tracking"
 
 const setFetchingState = (isFetching: boolean) => ({
     type: types.SET_FETCHING_STATE,
@@ -74,8 +74,8 @@
             }
 
             if (json.meta?.user?.id) {
-                // Load tracking info
-                dispatch(onUpdateAssessmentTracking())
+                // Load tracking registry (which auto-selects the first tracking sheet then loads it's content to the UI)
+                dispatch(onLoadTrackingRegistry())
             }
         })
 }

static/er2_303d_assess/js/constants/action_types.js

@@ -18,9 +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_TRACKING_REGISTRY_LIST = "SET_TRACKING_REGISTRY_LIST"
+export const SET_CURRENT_TRACKING_SHEET_KEY = "SET_CURRENT_TRACKING_SHEET_KEY"
+export const SET_TRACKING_SHEET_CONTENT = "SET_TRACKING_SHEET_CONTENT"
 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/containers/app.js

@@ -140,7 +140,9 @@
         onSetCSV: Function,
         onSetPDF: Function,
         onShowTrackingSheetEditor: Function,
-        onUpdateAssessmentTracking: Function,
+        onLoadTrackingRegistry: Function,
+        onSetCurrentTrackingSheetKey: Function,
+        onUpdateTrackingSheetContent: Function,
         onAppendThirdPartyStations: Function,
         onUploadThirdPartyStations: Function,
         runAssessment: Function,
@@ -505,9 +507,14 @@
                                     assessmentTracking={
                                         theprops.assessmentTracking
                                     }
-                                    onUpdateAssessmentTracking={
-                                        theprops.actions
-                                            .onUpdateAssessmentTracking
+                                    onLoadTrackingRegistry={
+                                        theprops.actions.onLoadTrackingRegistry
+                                    }
+                                    onSetCurrentTrackingSheetKey={
+                                        theprops.actions.onSetCurrentTrackingSheetKey
+                                    }
+                                    onUpdateTrackingSheetContent={
+                                        theprops.actions.onUpdateTrackingSheetContent
                                     }
                                     theme={classes}
                                 />

static/er2_303d_assess/js/reducers/assessment_tracking.js

@@ -38,13 +38,13 @@
             state.visible = !state.visible
         }
     },
-    [actionTypes.SET_ASSESSMENT_REGISTRY_LIST]: (state, action) => {
+    [actionTypes.SET_TRACKING_REGISTRY_LIST]: (state, action) => {
         state.registryList = action.assessmentTracking.registryList
     },
-    [actionTypes.SET_CURRENT_TRACKING_SHEET]: (state, action) => {
+    [actionTypes.SET_CURRENT_TRACKING_SHEET_KEY]: (state, action) => {
         state.selectedTrackingSheet = action.assessmentTracking.selectedTrackingSheet
     },
-    [actionTypes.SET_ASSESSMENT_TRACKING]: (state, action) => {
+    [actionTypes.SET_TRACKING_SHEET_CONTENT]: (state, action) => {
         state.assessments = action.assessmentTracking.assessments
         state.registry = action.assessmentTracking.registry
     },