fix: add red highlighting for Terminal ID, if not configured

This commit is contained in:
Lance Edgar 2024-07-04 16:56:03 -05:00
parent 56ac6b2770
commit b8bb42e38c
2 changed files with 14 additions and 5 deletions

View file

@ -2,7 +2,7 @@
################################################################################
#
# WuttaPOS -- Pythonic Point of Sale System
# Copyright © 2023 Lance Edgar
# Copyright © 2023-2024 Lance Edgar
#
# This file is part of WuttaPOS.
#
@ -37,7 +37,7 @@ from .feedback import WuttaFeedback
class WuttaHeader(WuttaControl):
def __init__(self, *args, **kwargs):
self.term_display = kwargs.pop('term_display', '??')
self.terminal_id = kwargs.pop('terminal_id', None)
super().__init__(*args, **kwargs)
def build(self):
@ -51,6 +51,11 @@ class WuttaHeader(WuttaControl):
self.logout_divider = ft.VerticalDivider(visible=False)
self.title_button = ft.FilledButton(self.app.get_title(), on_click=self.title_click)
terminal_style = ft.TextStyle(size=20, weight=ft.FontWeight.BOLD)
if not self.terminal_id:
terminal_style.bgcolor = 'red'
terminal_style.color = 'white'
return ft.Stack(
controls=[
ft.Container(
@ -81,7 +86,11 @@ class WuttaHeader(WuttaControl):
ft.VerticalDivider(),
self.logout_button,
self.logout_divider,
ft.Text(f"Term: {self.term_display}", weight=ft.FontWeight.BOLD, size=20),
ft.Text(
spans=[
ft.TextSpan(style=terminal_style, text=f"Term: {self.terminal_id or '??'}"),
],
),
ft.VerticalDivider(),
self.title_button,
],

View file

@ -2,7 +2,7 @@
################################################################################
#
# WuttaPOS -- Pythonic Point of Sale System
# Copyright © 2023 Lance Edgar
# Copyright © 2023-2024 Lance Edgar
#
# This file is part of WuttaPOS.
#
@ -60,7 +60,7 @@ class WuttaView(ft.View):
def build_header(self):
handler = self.get_batch_handler()
self.header = WuttaHeader(self.config, on_reset=self.reset,
term_display=handler.get_terminal_id() or '??')
terminal_id=handler.get_terminal_id())
return self.header
def get_batch_handler(self):