114 lines
5.0 KiB
Python
114 lines
5.0 KiB
Python
import gi
|
|
gi.require_version('Gtk', '3.0')
|
|
from gi.repository import Gtk
|
|
from .location_card import ActiveLocationCard, InactiveLocationCard
|
|
|
|
|
|
class ActiveCustomerCard:
|
|
def __init__(self, customer, callbacks):
|
|
self.customer = customer
|
|
self.callbacks = callbacks
|
|
self.widget = self._create_widget()
|
|
|
|
def _create_widget(self):
|
|
# GNOME-style card container
|
|
card_frame = Gtk.Frame()
|
|
card_frame.get_style_context().add_class("card")
|
|
card_frame.set_shadow_type(Gtk.ShadowType.NONE) # Shadow handled by CSS
|
|
|
|
card_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
|
|
card_frame.add(card_vbox)
|
|
|
|
# Customer header
|
|
customer_label = Gtk.Label()
|
|
customer_label.set_markup(f"<b><big>🏢 {self.customer.name}</big></b>")
|
|
customer_label.set_halign(Gtk.Align.START)
|
|
card_vbox.pack_start(customer_label, False, False, 0)
|
|
|
|
# Customer services section
|
|
if self.customer.services:
|
|
services_label = Gtk.Label()
|
|
services_label.set_markup("<b>Cloud Services</b>")
|
|
services_label.set_halign(Gtk.Align.START)
|
|
services_label.set_margin_top(8)
|
|
card_vbox.pack_start(services_label, False, False, 0)
|
|
|
|
# Services box with indent
|
|
services_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8)
|
|
services_box.set_margin_start(16)
|
|
services_box.set_margin_bottom(8)
|
|
card_vbox.pack_start(services_box, False, False, 0)
|
|
|
|
for service in self.customer.services:
|
|
service_btn = Gtk.Button(label=service.name)
|
|
service_btn.get_style_context().add_class("suggested-action")
|
|
service_btn.connect("clicked", lambda btn, s=service: self.callbacks['open_customer_service'](s))
|
|
services_box.pack_start(service_btn, False, False, 0)
|
|
|
|
# Locations section
|
|
for i, location in enumerate(self.customer.locations):
|
|
if i > 0: # Add separator between locations
|
|
separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
|
|
separator.set_margin_top(8)
|
|
separator.set_margin_bottom(8)
|
|
card_vbox.pack_start(separator, False, False, 0)
|
|
|
|
location_card = ActiveLocationCard(location, self.customer.name, self.callbacks)
|
|
card_vbox.pack_start(location_card.widget, False, False, 0)
|
|
|
|
return card_frame
|
|
|
|
|
|
class InactiveCustomerCard:
|
|
def __init__(self, customer, callbacks):
|
|
self.customer = customer
|
|
self.callbacks = callbacks
|
|
self.widget = self._create_widget()
|
|
|
|
def _create_widget(self):
|
|
# GNOME-style card container
|
|
card_frame = Gtk.Frame()
|
|
card_frame.get_style_context().add_class("card")
|
|
card_frame.set_shadow_type(Gtk.ShadowType.NONE) # Shadow handled by CSS
|
|
|
|
card_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
|
|
card_frame.add(card_vbox)
|
|
|
|
# Customer header - muted
|
|
customer_label = Gtk.Label()
|
|
customer_label.set_markup(f"<span alpha='60%'><b><big>🏢 {self.customer.name}</big></b></span>")
|
|
customer_label.set_halign(Gtk.Align.START)
|
|
card_vbox.pack_start(customer_label, False, False, 0)
|
|
|
|
# Customer services section - list format for inactive
|
|
if self.customer.services:
|
|
services_label = Gtk.Label()
|
|
services_label.set_markup("<span alpha='60%'><b>Cloud Services</b></span>")
|
|
services_label.set_halign(Gtk.Align.START)
|
|
services_label.set_margin_top(8)
|
|
card_vbox.pack_start(services_label, False, False, 0)
|
|
|
|
# Services list with indent
|
|
services_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=2)
|
|
services_vbox.set_margin_start(16)
|
|
services_vbox.set_margin_bottom(8)
|
|
card_vbox.pack_start(services_vbox, False, False, 0)
|
|
|
|
for service in self.customer.services:
|
|
service_label = Gtk.Label()
|
|
service_label.set_markup(f"<span alpha='60%'><small>• {service.name} ({service.service_type})</small></span>")
|
|
service_label.set_halign(Gtk.Align.START)
|
|
services_vbox.pack_start(service_label, False, False, 0)
|
|
|
|
# Locations section
|
|
for i, location in enumerate(self.customer.locations):
|
|
if i > 0: # Add separator between locations
|
|
separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
|
|
separator.set_margin_top(8)
|
|
separator.set_margin_bottom(8)
|
|
card_vbox.pack_start(separator, False, False, 0)
|
|
|
|
location_card = InactiveLocationCard(location, self.customer.name, self.callbacks)
|
|
card_vbox.pack_start(location_card.widget, False, False, 0)
|
|
|
|
return card_frame |