This commit is contained in:
2025-09-07 23:33:55 +02:00
parent d918f1e497
commit fbacfde9f2
33 changed files with 2626 additions and 1236 deletions

View File

@@ -1,52 +1,54 @@
from widgets import InactiveCustomerCard
from gi.repository import Gtk
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from widgets import InactiveCustomerCard
class InactiveView:
"""View for displaying inactive customer locations (search results)."""
def __init__(self, callbacks):
self.callbacks = callbacks
self.widget = self._create_widget()
self.current_search = ""
def _create_widget(self):
"""Create the main container for inactive/search results."""
# Main container
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
# Scrolled window for content
scrolled = Gtk.ScrolledWindow()
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
scrolled.set_shadow_type(Gtk.ShadowType.NONE)
vbox.pack_start(scrolled, True, True, 0)
# Content box
self.content_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
self.content_box = Gtk.Box(
orientation=Gtk.Orientation.VERTICAL, spacing=12)
scrolled.add(self.content_box)
return vbox
def update(self, customers, search_term=""):
"""Update the view with search results.
Args:
customers: List of Customer objects with inactive locations to display
search_term: The current search term
"""
self.current_search = search_term
# Clear existing content
for child in self.content_box.get_children():
child.destroy()
if customers:
# Add customer cards
for customer in customers:
customer_card = InactiveCustomerCard(customer, self.callbacks)
self.content_box.pack_start(customer_card.widget, False, False, 0)
self.content_box.pack_start(
customer_card.widget, False, False, 0)
else:
# Show no results message
if search_term:
@@ -56,14 +58,14 @@ class InactiveView:
)
no_results_label.set_margin_top(20)
self.content_box.pack_start(no_results_label, False, False, 0)
self.content_box.show_all()
def set_visible(self, visible):
"""Set visibility of the entire view."""
self.widget.set_visible(visible)
def clear(self):
"""Clear all content from the view."""
for child in self.content_box.get_children():
child.destroy()
child.destroy()