feat: Enhance UI feedback and improve data filtering logic
This commit is contained in:
+31
-14
@@ -1017,9 +1017,8 @@ Use Ctrl+S to save entries and Ctrl+Q to quit."""
|
||||
self._mark_data_modified() # Mark for auto-save
|
||||
edit_win.destroy()
|
||||
self.ui_manager.update_status("Entry updated successfully!", "success")
|
||||
messagebox.showinfo(
|
||||
"Success", "Entry updated successfully!", parent=self.root
|
||||
)
|
||||
if hasattr(self.ui_manager, "show_toast"):
|
||||
self.ui_manager.show_toast("Entry updated", 1500)
|
||||
self._clear_entries()
|
||||
self.refresh_data_display()
|
||||
new_date = values[0]
|
||||
@@ -1170,11 +1169,23 @@ Use Ctrl+S to save entries and Ctrl+Q to quit."""
|
||||
return
|
||||
entry_data["note"] = validated_note
|
||||
|
||||
# Check entry completeness
|
||||
is_complete, missing_fields = InputValidator.validate_entry_completeness(
|
||||
entry_data
|
||||
# Check entry completeness: require date and at least one of
|
||||
# (any pathology score > 0) or (any medicine taken == 1)
|
||||
missing_fields: list[str] = []
|
||||
if not entry_data.get("date"):
|
||||
missing_fields.append("Date")
|
||||
|
||||
has_pathology = any(
|
||||
entry_data.get(k, 0) > 0
|
||||
for k in self.pathology_manager.get_pathology_keys()
|
||||
)
|
||||
if not is_complete:
|
||||
has_medicine = any(
|
||||
entry_data.get(k, 0) == 1 for k in self.medicine_manager.get_medicine_keys()
|
||||
)
|
||||
if not (has_pathology or has_medicine):
|
||||
missing_fields.append("At least one pathology score or medicine entry")
|
||||
|
||||
if missing_fields:
|
||||
missing_msg = "Missing required data:\n" + "\n".join(
|
||||
f"• {field}" for field in missing_fields
|
||||
)
|
||||
@@ -1224,9 +1235,8 @@ Use Ctrl+S to save entries and Ctrl+Q to quit."""
|
||||
if self.data_manager.add_entry(entry):
|
||||
self._mark_data_modified() # Mark for auto-save
|
||||
self.ui_manager.update_status("Entry added successfully!", "success")
|
||||
messagebox.showinfo(
|
||||
"Success", "Entry added successfully!", parent=self.root
|
||||
)
|
||||
if hasattr(self.ui_manager, "show_toast"):
|
||||
self.ui_manager.show_toast("Entry added", 1500)
|
||||
self._clear_entries()
|
||||
self.refresh_data_display()
|
||||
added_date = entry[0]
|
||||
@@ -1278,9 +1288,8 @@ Use Ctrl+S to save entries and Ctrl+Q to quit."""
|
||||
self._mark_data_modified() # Mark for auto-save
|
||||
edit_win.destroy()
|
||||
self.ui_manager.update_status("Entry deleted successfully!", "success")
|
||||
messagebox.showinfo(
|
||||
"Success", "Entry deleted successfully!", parent=self.root
|
||||
)
|
||||
if hasattr(self.ui_manager, "show_toast"):
|
||||
self.ui_manager.show_toast("Entry deleted", 1500)
|
||||
self.refresh_data_display()
|
||||
if deleted_row:
|
||||
|
||||
@@ -1308,7 +1317,11 @@ Use Ctrl+S to save entries and Ctrl+Q to quit."""
|
||||
def _clear_entries(self) -> None:
|
||||
"""Clear all input fields."""
|
||||
logger.debug("Clearing input fields.")
|
||||
self.date_var.set("")
|
||||
# Keep date practical: default to today's date after clear
|
||||
try:
|
||||
self.date_var.set(datetime.now().strftime("%m/%d/%Y"))
|
||||
except Exception:
|
||||
self.date_var.set("")
|
||||
for key in self.pathology_vars:
|
||||
self.pathology_vars[key].set(0)
|
||||
for key in self.medicine_vars:
|
||||
@@ -1336,6 +1349,10 @@ Use Ctrl+S to save entries and Ctrl+Q to quit."""
|
||||
# Use efficient tree update to reduce flickering
|
||||
self._update_tree_efficiently(df)
|
||||
|
||||
# Reapply last sort state if any
|
||||
if hasattr(self.ui_manager, "reapply_last_sort"):
|
||||
self.ui_manager.reapply_last_sort(self.tree)
|
||||
|
||||
# Update the graph (always use unfiltered data for complete picture)
|
||||
# Graph gets preprocessed, use dedicated cached transformation
|
||||
if hasattr(self.data_manager, "get_graph_ready_data"):
|
||||
|
||||
Reference in New Issue
Block a user