04/23 Enhance app functionalities

This commit is contained in:
2026-04-23 16:54:24 -04:00
parent 64419a445a
commit f4eea48e4d
8 changed files with 427 additions and 45 deletions
+20 -1
View File
@@ -33,6 +33,7 @@ class AdminShiftsView(ttk.Frame):
def __init__(self, parent, current_user: dict):
super().__init__(parent)
self.current_user = current_user
self._show_inactive = tk.BooleanVar(value=False)
self._build_ui()
self._load_shifts()
@@ -56,6 +57,15 @@ class AdminShiftsView(ttk.Frame):
style="Ghost.TButton",
command=self._export_pdf).pack(side="right", padx=(0, 12))
# Show / hide inactive shifts toggle
ttk.Checkbutton(
toolbar,
text="Show inactive",
variable=self._show_inactive,
command=self._load_shifts,
style="TCheckbutton",
).pack(side="left", padx=(16, 0))
cols = ("ID", "Shift Name", "Days", "Start", "End",
"Users", "Websites", "Active", "Note")
self.tree = ttk.Treeview(self, columns=cols,
@@ -80,8 +90,13 @@ class AdminShiftsView(ttk.Frame):
def _load_shifts(self):
from models import get_all_shifts
self.tree.delete(*self.tree.get_children())
show_inactive = self._show_inactive.get()
try:
for s in get_all_shifts():
all_shifts = get_all_shifts()
shown = 0
for s in all_shifts:
if not s["is_active"] and not show_inactive:
continue
days_str = _days_label(s["days_of_week"])
active = "" if s["is_active"] else ""
tag = "active" if s["is_active"] else "inactive"
@@ -99,6 +114,10 @@ class AdminShiftsView(ttk.Frame):
(s["note"] or "")[:60],
)
)
shown += 1
hidden = len(all_shifts) - shown
if hidden and not show_inactive:
logger.debug(f"Shifts view: {hidden} inactive shift(s) hidden.")
except Exception as e:
show_error(f"Failed to load shifts:\n{e}")