Update app.py
Browse files
app.py
CHANGED
|
@@ -569,37 +569,58 @@ except Exception as e:
|
|
| 569 |
# Load assignees directly from the file
|
| 570 |
assignee_list = load_assignees()
|
| 571 |
|
| 572 |
-
# Display small status indicator if we're using in-memory storage
|
| 573 |
if st.session_state.using_memory_storage:
|
| 574 |
st.markdown('<div style="background-color: #fff3cd; color: #856404; padding: 8px; border-radius: 4px; font-size: 12px; margin-bottom: 10px;">Using in-memory storage due to file permission issues. Tasks may not persist after refresh.</div>', unsafe_allow_html=True)
|
| 575 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 576 |
with col1:
|
| 577 |
-
|
| 578 |
with col2:
|
| 579 |
-
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 584 |
if title: # Basic validation
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
|
| 594 |
-
|
| 595 |
-
|
| 596 |
-
|
| 597 |
-
st.session_state.tasks
|
| 598 |
-
|
| 599 |
-
|
| 600 |
-
|
| 601 |
-
|
| 602 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 603 |
else:
|
| 604 |
st.warning("Please enter a task title")
|
| 605 |
|
|
|
|
| 569 |
# Load assignees directly from the file
|
| 570 |
assignee_list = load_assignees()
|
| 571 |
|
|
|
|
| 572 |
if st.session_state.using_memory_storage:
|
| 573 |
st.markdown('<div style="background-color: #fff3cd; color: #856404; padding: 8px; border-radius: 4px; font-size: 12px; margin-bottom: 10px;">Using in-memory storage due to file permission issues. Tasks may not persist after refresh.</div>', unsafe_allow_html=True)
|
| 574 |
|
| 575 |
+
# Sidebar for new tasks
|
| 576 |
+
with st.sidebar:
|
| 577 |
+
st.markdown('<div class="sidebar-title">➕ Add New Task</div>', unsafe_allow_html=True)
|
| 578 |
+
title = st.text_input("Task Title", key="new_title")
|
| 579 |
+
description = st.text_area("Description", key="new_desc", height=100)
|
| 580 |
+
|
| 581 |
+
# More compact layout for form
|
| 582 |
+
col1, col2 = st.columns(2)
|
| 583 |
with col1:
|
| 584 |
+
assignee = st.selectbox("Assignee", assignee_list, key="new_assignee")
|
| 585 |
with col2:
|
| 586 |
+
status = st.selectbox("Status", ["Backlog", "To Do", "In Progress", "Done"], key="new_status")
|
| 587 |
+
|
| 588 |
+
# Added date fields in more compact layout
|
| 589 |
+
col3, col4 = st.columns(2)
|
| 590 |
+
with col3:
|
| 591 |
+
date_started = st.date_input("Date Started", value=datetime.now().date(), key="new_date_start")
|
| 592 |
+
with col4:
|
| 593 |
+
date_to_finish = st.date_input("Date to Finish", value=datetime.now().date(), key="new_date_finish")
|
| 594 |
+
|
| 595 |
+
due_date = st.date_input("Due Date", key="new_due_date")
|
| 596 |
+
|
| 597 |
+
# Add task button with try-catch
|
| 598 |
+
if st.button("Add Task", key="add_btn"):
|
| 599 |
if title: # Basic validation
|
| 600 |
+
try:
|
| 601 |
+
task_id = generate_task_id()
|
| 602 |
+
new_task = {
|
| 603 |
+
'ID': task_id,
|
| 604 |
+
'Title': title,
|
| 605 |
+
'Description': description,
|
| 606 |
+
'Assignee': assignee,
|
| 607 |
+
'Status': status,
|
| 608 |
+
'Date Started': date_started,
|
| 609 |
+
'Date to Finish': date_to_finish,
|
| 610 |
+
'Due Date': due_date
|
| 611 |
+
}
|
| 612 |
+
st.session_state.tasks = pd.concat([
|
| 613 |
+
st.session_state.tasks,
|
| 614 |
+
pd.DataFrame([new_task])
|
| 615 |
+
], ignore_index=True)
|
| 616 |
+
save_tasks()
|
| 617 |
+
# Show success but don't mention storage
|
| 618 |
+
st.success("Task added!")
|
| 619 |
+
except Exception as e:
|
| 620 |
+
st.error(f"Error adding task: {str(e)}")
|
| 621 |
+
# Still add to session state even if file save fails
|
| 622 |
+
st.session_state.in_memory_tasks = st.session_state.tasks.to_dict(orient='records')
|
| 623 |
+
st.info("Task was added to memory but might not persist after refresh.")
|
| 624 |
else:
|
| 625 |
st.warning("Please enter a task title")
|
| 626 |
|