arif670 commited on
Commit
357035a
Β·
verified Β·
1 Parent(s): 497ec38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -64
app.py CHANGED
@@ -516,72 +516,72 @@ def main():
516
 
517
  # Edit Tasks
518
  elif menu == "✏️ Edit Tasks":
519
- tasks = get_tasks()
520
- if tasks:
521
- task_options = [f"{t['task']} ({t['project']})" for t in tasks]
522
- selected = st.selectbox("Select Task", task_options)
523
- task = next(t for t in tasks if f"{t['task']} ({t['project']})" == selected)
524
-
525
- with st.form(key="edit_form"):
526
- col1, col2 = st.columns(2)
527
-
528
- # Left Column
529
- with col1:
530
- new_task = st.text_area("Description", value=task['task'], height=100)
531
- new_type = st.selectbox(
532
- "Type",
533
- ["Design", "Procurement", "Construction", "Testing", "Other"],
534
- index=["Design", "Procurement", "Construction", "Testing", "Other"].index(task['type'])
535
- )
536
 
537
- # Right Column
538
- with col2:
539
- projects = [p.id for p in db.collection("projects").stream()] + ["Add New Project"]
540
- new_project = st.selectbox(
541
- "Project",
542
- projects,
543
- index=projects.index(task['project']) if task['project'] in projects else 0
544
- )
545
- if new_project == "Add New Project":
546
- new_project = st.text_input("New Project Name")
547
 
548
- new_status = st.selectbox(
549
- "Status",
550
- ["Pending", "In Progress", "Completed"],
551
- index=["Pending", "In Progress", "Completed"].index(task['status'])
552
- )
553
- new_date = st.date_input(
554
- "Due Date",
555
- value=datetime.strptime(task['date'], "%Y-%m-%d").date()
556
- )
557
-
558
- # Attachment Management
559
- st.subheader("πŸ“Ž Attachments")
560
- attachments = task.get('attachments', []) # Safely get attachments
561
- if attachments:
562
- for att in attachments:
563
- col1, col2 = st.columns([4,1])
564
- with col1:
565
- st.markdown(f"""
566
- <div style="margin:0.5rem 0; padding:0.5rem; border-radius:5px; background:#f0f2f6;">
567
- <div style="display:flex; align-items:center; gap:1rem;">
568
- <span style="flex:1;">πŸ“„ {att['name']}</span>
569
- <a href="{att['url']}" target="_blank" style="text-decoration:none;">
570
- πŸ”— View
571
- </a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
572
  </div>
573
- <small style="color:#666;">{att['type']} | {att['size'] // 1024} KB</small>
574
- </div>
575
- """, unsafe_allow_html=True)
576
- with col2:
577
- if st.button("πŸ—‘οΈ", key=f"del_att_{att['name']}"):
578
- # Remove attachment from task
579
- updated_attachments = [a for a in attachments if a['name'] != att['name']]
580
- db.collection("tasks").document(task['id']).update({
581
- "attachments": updated_attachments
582
- })
583
- st.rerun()
584
-
585
  # New Attachments
586
  new_attachments = st.file_uploader(
587
  "Add New Attachments",
@@ -591,7 +591,7 @@ def main():
591
  )
592
 
593
  # Submit Button
594
- submitted = st.form_submit_button("πŸ’Ύ Save Changes")
595
 
596
  if submitted:
597
  try:
 
516
 
517
  # Edit Tasks
518
  elif menu == "✏️ Edit Tasks":
519
+ tasks = get_tasks()
520
+ if tasks:
521
+ task_options = [f"{t['task']} ({t['project']})" for t in tasks]
522
+ selected = st.selectbox("Select Task", task_options)
523
+ task = next(t for t in tasks if f"{t['task']} ({t['project']})" == selected)
 
 
 
 
 
 
 
 
 
 
 
 
524
 
525
+ with st.form(key="edit_form"):
526
+ col1, col2 = st.columns(2)
 
 
 
 
 
 
 
 
527
 
528
+ # Left Column
529
+ with col1:
530
+ new_task = st.text_area("Description", value=task['task'], height=100)
531
+ new_type = st.selectbox(
532
+ "Type",
533
+ ["Design", "Procurement", "Construction", "Testing", "Other"],
534
+ index=["Design", "Procurement", "Construction", "Testing", "Other"].index(task['type'])
535
+ )
536
+
537
+ # Right Column
538
+ with col2:
539
+ projects = [p.id for p in db.collection("projects").stream()] + ["Add New Project"]
540
+ new_project = st.selectbox(
541
+ "Project",
542
+ projects,
543
+ index=projects.index(task['project']) if task['project'] in projects else 0
544
+ )
545
+ if new_project == "Add New Project":
546
+ new_project = st.text_input("New Project Name")
547
+
548
+ new_status = st.selectbox(
549
+ "Status",
550
+ ["Pending", "In Progress", "Completed"],
551
+ index=["Pending", "In Progress", "Completed"].index(task['status'])
552
+ )
553
+ new_date = st.date_input(
554
+ "Due Date",
555
+ value=datetime.strptime(task['date'], "%Y-%m-%d").date()
556
+ )
557
+
558
+ # Attachment Management
559
+ st.subheader("πŸ“Ž Attachments")
560
+ attachments = task.get('attachments', []) # Safely get attachments
561
+ if attachments:
562
+ for att in attachments:
563
+ col1, col2 = st.columns([4,1])
564
+ with col1:
565
+ st.markdown(f"""
566
+ <div style="margin:0.5rem 0; padding:0.5rem; border-radius:5px; background:#f0f2f6;">
567
+ <div style="display:flex; align-items:center; gap:1rem;">
568
+ <span style="flex:1;">πŸ“„ {att['name']}</span>
569
+ <a href="{att['url']}" target="_blank" style="text-decoration:none;">
570
+ πŸ”— View
571
+ </a>
572
+ </div>
573
+ <small style="color:#666;">{att['type']} | {att['size'] // 1024} KB</small>
574
  </div>
575
+ """, unsafe_allow_html=True)
576
+ with col2:
577
+ if st.button("πŸ—‘οΈ", key=f"del_att_{att['name']}"):
578
+ # Remove attachment from task
579
+ updated_attachments = [a for a in attachments if a['name'] != att['name']]
580
+ db.collection("tasks").document(task['id']).update({
581
+ "attachments": updated_attachments
582
+ })
583
+ st.rerun()
584
+
 
 
585
  # New Attachments
586
  new_attachments = st.file_uploader(
587
  "Add New Attachments",
 
591
  )
592
 
593
  # Submit Button
594
+ submitted = st.form_submit_button("πŸ’Ύ Save Changes")
595
 
596
  if submitted:
597
  try: