AjaykumarPilla commited on
Commit
24c0798
·
verified ·
1 Parent(s): 3e747ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -342,11 +342,18 @@ with st.form("project_form"):
342
  project_name = st.text_input("Project Name")
343
  phase = st.selectbox("Phase", [""] + ["Planning", "Design", "Construction"], index=0, key="phase_select")
344
 
345
- if phase != st.session_state.phase:
 
346
  st.session_state.phase = phase
347
- st.session_state.task = ""
 
 
 
 
 
348
  task_options_list = [""] + task_options.get(phase, []) if phase else [""]
349
  task = st.selectbox("Task", task_options_list, index=0, key="task_select")
 
350
  current_progress = st.number_input("Current Progress (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0)
351
  task_expected_duration = st.number_input("Task Expected Duration (days)", min_value=0, step=1, value=0)
352
  task_actual_duration = st.number_input("Task Actual Duration (days)", min_value=0, step=1, value=0)
 
342
  project_name = st.text_input("Project Name")
343
  phase = st.selectbox("Phase", [""] + ["Planning", "Design", "Construction"], index=0, key="phase_select")
344
 
345
+ # Update task options and reset task when phase changes
346
+ if phase != st.session_state.get("phase", ""):
347
  st.session_state.phase = phase
348
+ st.session_state.task = "" # Reset task
349
+ # Clear task_select to avoid stale values
350
+ if "task_select" in st.session_state:
351
+ del st.session_state.task_select
352
+
353
+ # Define task options based on phase
354
  task_options_list = [""] + task_options.get(phase, []) if phase else [""]
355
  task = st.selectbox("Task", task_options_list, index=0, key="task_select")
356
+
357
  current_progress = st.number_input("Current Progress (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0)
358
  task_expected_duration = st.number_input("Task Expected Duration (days)", min_value=0, step=1, value=0)
359
  task_actual_duration = st.number_input("Task Actual Duration (days)", min_value=0, step=1, value=0)