Spaces:
Running
Running
silvia.fallone
commited on
Commit
Β·
b4bcbd8
1
Parent(s):
8db385b
Added unique name verification, and disabled save button by default.
Browse files- app/pages/0_π_AOIs.py +10 -2
app/pages/0_π_AOIs.py
CHANGED
@@ -74,8 +74,16 @@ elif radio_selection == "Create New Area":
|
|
74 |
},
|
75 |
).add_to(folium_map)
|
76 |
|
77 |
-
new_area_name = st.text_input("Area name")
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
st.session_state["prev_radio_selection"] = "Create New Area"
|
81 |
|
|
|
74 |
},
|
75 |
).add_to(folium_map)
|
76 |
|
77 |
+
new_area_name = st.text_input("Area name") #TODO: this is where we need to enforce unique AOI names
|
78 |
+
|
79 |
+
# Check if the name already exists
|
80 |
+
existing_names = [aoi["name"] for aoi in st.session_state["all_aois"].values()]
|
81 |
+
is_name_valid = new_area_name and new_area_name not in existing_names
|
82 |
+
|
83 |
+
if new_area_name and not is_name_valid:
|
84 |
+
st.error(f"An area with the name '{new_area_name}' already exists. Please choose a different name.")
|
85 |
+
|
86 |
+
save_area = st.button("Save Area", disabled=not is_name_valid)
|
87 |
|
88 |
st.session_state["prev_radio_selection"] = "Create New Area"
|
89 |
|