arif670 commited on
Commit
8ae6cfc
Β·
verified Β·
1 Parent(s): 06ce53e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -15
app.py CHANGED
@@ -221,7 +221,7 @@ def main():
221
  st.session_state.first_login = False
222
 
223
  # Navigation Menu
224
- menu_items = ["πŸ“₯ Task Entry", "🏠 Dashboard", "πŸ‘€ Task Explorer", "✏️ Edit Tasks", "βš™οΈ Settings"]
225
  if st.session_state.is_admin:
226
  menu_items.insert(3, "πŸ—οΈ Project Management")
227
 
@@ -300,8 +300,16 @@ def main():
300
 
301
  # Task Entry
302
  elif menu == "πŸ“₯ Task Entry":
 
 
 
 
 
 
 
 
 
303
  with st.form(key="task_form", clear_on_submit=True):
304
- st.subheader("βž• Add New Task")
305
  col1, col2 = st.columns(2)
306
 
307
  # Left Column
@@ -322,11 +330,9 @@ def main():
322
  status = st.selectbox("πŸ“Œ Status", ["Pending", "In Progress", "Completed"])
323
  date = st.date_input("πŸ“… Due Date", min_value=datetime.today())
324
 
325
- # Recurrence Settings
326
- recurrence = st.selectbox("πŸ”„ Repeat", ["None", "Daily", "Weekly", "Monthly"])
327
-
328
- # Show recurrence options immediately after selecting recurrence type
329
- if recurrence != "None":
330
  end_condition = st.radio(
331
  "End Condition",
332
  ["End Date", "Number of Occurrences"],
@@ -347,6 +353,7 @@ def main():
347
  help="Total number of task instances"
348
  )
349
  else:
 
350
  end_condition = None
351
  end_date = None
352
  num_occurrences = None
@@ -368,8 +375,8 @@ def main():
368
  st.stop()
369
 
370
  try:
371
- # Validate recurrence
372
- if recurrence != "None":
373
  if end_condition == "End Date" and (not end_date or end_date <= date):
374
  st.error("❌ End date must be after initial due date")
375
  st.stop()
@@ -399,9 +406,9 @@ def main():
399
  "size": file.size
400
  })
401
 
402
- # Generate recurring dates
403
  dates = [date]
404
- if recurrence != "None":
405
  current_date = date
406
  if end_condition == "End Date":
407
  while current_date < end_date:
@@ -435,11 +442,11 @@ def main():
435
  "status": status,
436
  "date": str(task_date),
437
  "recurrence": {
438
- "type": recurrence,
439
  "original_date": str(date),
440
- "end_condition": end_condition,
441
- "end_date": str(end_date) if end_condition == "End Date" else None,
442
- "num_occurrences": num_occurrences if end_condition == "Number of Occurrences" else None,
443
  "sequence": idx + 1
444
  },
445
  "attachments": attachments,
 
221
  st.session_state.first_login = False
222
 
223
  # Navigation Menu
224
+ menu_items = ["🏠 Dashboard", "πŸ“₯ Task Entry", "πŸ‘€ Task Explorer", "✏️ Edit Tasks", "βš™οΈ Settings"]
225
  if st.session_state.is_admin:
226
  menu_items.insert(3, "πŸ—οΈ Project Management")
227
 
 
300
 
301
  # Task Entry
302
  elif menu == "πŸ“₯ Task Entry":
303
+ # Part 1: Task Type Selection
304
+ st.subheader("βž• Add New Task")
305
+ task_type_selection = st.radio(
306
+ "Select Task Type",
307
+ ["One-Time Task", "Recurring Task"],
308
+ horizontal=True
309
+ )
310
+
311
+ # Part 2: Task Details Form
312
  with st.form(key="task_form", clear_on_submit=True):
 
313
  col1, col2 = st.columns(2)
314
 
315
  # Left Column
 
330
  status = st.selectbox("πŸ“Œ Status", ["Pending", "In Progress", "Completed"])
331
  date = st.date_input("πŸ“… Due Date", min_value=datetime.today())
332
 
333
+ # Recurrence Settings (only for recurring tasks)
334
+ if task_type_selection == "Recurring Task":
335
+ recurrence = st.selectbox("πŸ”„ Repeat", ["Daily", "Weekly", "Monthly"])
 
 
336
  end_condition = st.radio(
337
  "End Condition",
338
  ["End Date", "Number of Occurrences"],
 
353
  help="Total number of task instances"
354
  )
355
  else:
356
+ recurrence = "None"
357
  end_condition = None
358
  end_date = None
359
  num_occurrences = None
 
375
  st.stop()
376
 
377
  try:
378
+ # Validate recurrence (if applicable)
379
+ if task_type_selection == "Recurring Task":
380
  if end_condition == "End Date" and (not end_date or end_date <= date):
381
  st.error("❌ End date must be after initial due date")
382
  st.stop()
 
406
  "size": file.size
407
  })
408
 
409
+ # Generate recurring dates (if applicable)
410
  dates = [date]
411
+ if task_type_selection == "Recurring Task":
412
  current_date = date
413
  if end_condition == "End Date":
414
  while current_date < end_date:
 
442
  "status": status,
443
  "date": str(task_date),
444
  "recurrence": {
445
+ "type": recurrence if task_type_selection == "Recurring Task" else "None",
446
  "original_date": str(date),
447
+ "end_condition": end_condition if task_type_selection == "Recurring Task" else None,
448
+ "end_date": str(end_date) if task_type_selection == "Recurring Task" and end_condition == "End Date" else None,
449
+ "num_occurrences": num_occurrences if task_type_selection == "Recurring Task" and end_condition == "Number of Occurrences" else None,
450
  "sequence": idx + 1
451
  },
452
  "attachments": attachments,