Update app.py
Browse files
app.py
CHANGED
|
@@ -334,26 +334,30 @@ def save_to_salesforce(input_data, prediction, pdf_buffer):
|
|
| 334 |
logger.error(f"Error saving to Salesforce: {str(e)}")
|
| 335 |
return f"Error saving to Salesforce: {str(e)}"
|
| 336 |
|
| 337 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 338 |
with st.form("project_form"):
|
| 339 |
col1, col2 = st.columns(2)
|
| 340 |
|
| 341 |
with col1:
|
| 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)
|
|
|
|
| 334 |
logger.error(f"Error saving to Salesforce: {str(e)}")
|
| 335 |
return f"Error saving to Salesforce: {str(e)}"
|
| 336 |
|
| 337 |
+
# Phase and Task selection (outside the form for immediate updates)
|
| 338 |
+
col1, col2 = st.columns(2)
|
| 339 |
+
with col1:
|
| 340 |
+
phase = st.selectbox("Phase", [""] + ["Planning", "Design", "Construction"], index=0, key="phase_select")
|
| 341 |
+
|
| 342 |
+
# Update task options and reset task when phase changes
|
| 343 |
+
if phase != st.session_state.get("phase", ""):
|
| 344 |
+
st.session_state.phase = phase
|
| 345 |
+
st.session_state.task = ""
|
| 346 |
+
if "task_select" in st.session_state:
|
| 347 |
+
del st.session_state.task_select
|
| 348 |
+
logger.info(f"Phase changed to {phase}, resetting task and task_select")
|
| 349 |
+
|
| 350 |
+
# Define task options based on phase
|
| 351 |
+
task_options_list = [""] + task_options.get(phase, []) if phase else [""]
|
| 352 |
+
logger.info(f"Task options for phase '{phase}': {task_options_list}")
|
| 353 |
+
task = st.selectbox("Task", task_options_list, index=0, key="task_select")
|
| 354 |
+
|
| 355 |
+
# Input form for other fields
|
| 356 |
with st.form("project_form"):
|
| 357 |
col1, col2 = st.columns(2)
|
| 358 |
|
| 359 |
with col1:
|
| 360 |
project_name = st.text_input("Project Name")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
current_progress = st.number_input("Current Progress (%)", min_value=0.0, max_value=100.0, step=1.0, value=0.0)
|
| 362 |
task_expected_duration = st.number_input("Task Expected Duration (days)", min_value=0, step=1, value=0)
|
| 363 |
task_actual_duration = st.number_input("Task Actual Duration (days)", min_value=0, step=1, value=0)
|