More tweaks for training mode

make sure the TRAINING MODE sign in header stays put, instead of
"wandering" as the timestamp is updated

also make sure suspend/resume honors current training mode flag
This commit is contained in:
Lance Edgar 2023-10-19 21:12:23 -05:00
parent 0e5ad257c8
commit 95bf8ecfca
3 changed files with 41 additions and 23 deletions

View file

@ -44,38 +44,53 @@ class WuttaHeader(WuttaControl):
self.txn_display = ft.Text("Txn: N", weight=ft.FontWeight.BOLD, size=20) self.txn_display = ft.Text("Txn: N", weight=ft.FontWeight.BOLD, size=20)
self.cust_display = ft.Text("Cust: N", weight=ft.FontWeight.BOLD, size=20) self.cust_display = ft.Text("Cust: N", weight=ft.FontWeight.BOLD, size=20)
self.training_mode = ft.Text(size=40, weight=ft.FontWeight.BOLD, bgcolor='yellow') self.training_mode = ft.Text(size=40, weight=ft.FontWeight.BOLD)
self.user_display = ft.Text("User: N", weight=ft.FontWeight.BOLD, size=20) self.user_display = ft.Text("User: N", weight=ft.FontWeight.BOLD, size=20)
self.logout_button = ft.OutlinedButton("Logout", on_click=self.logout_click, visible=False) self.logout_button = ft.OutlinedButton("Logout", on_click=self.logout_click, visible=False)
self.logout_divider = ft.VerticalDivider(visible=False) self.logout_divider = ft.VerticalDivider(visible=False)
self.title_button = ft.FilledButton(self.app.get_title(), on_click=self.title_click) self.title_button = ft.FilledButton(self.app.get_title(), on_click=self.title_click)
return ft.Row( return ft.Stack(
[ controls=[
ft.Container(
content=ft.Row(
[
ft.Container(
content=self.training_mode,
bgcolor='yellow',
),
],
alignment=ft.MainAxisAlignment.CENTER,
),
),
ft.Row( ft.Row(
[ [
self.txn_display, ft.Row(
ft.VerticalDivider(), [
self.cust_display, self.txn_display,
ft.VerticalDivider(), ft.VerticalDivider(),
WuttaTimestamp(self.config, weight=ft.FontWeight.BOLD, size=20), self.cust_display,
], ft.VerticalDivider(),
), WuttaTimestamp(self.config, weight=ft.FontWeight.BOLD, size=20),
self.training_mode, ],
ft.Row( ),
[ ft.Row(
self.user_display, [
ft.VerticalDivider(), self.user_display,
self.logout_button, ft.VerticalDivider(),
self.logout_divider, self.logout_button,
ft.Text(f"Term: {self.term_display}", weight=ft.FontWeight.BOLD, size=20), self.logout_divider,
ft.VerticalDivider(), ft.Text(f"Term: {self.term_display}", weight=ft.FontWeight.BOLD, size=20),
self.title_button, ft.VerticalDivider(),
self.title_button,
],
),
], ],
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
), ),
], ],
alignment=ft.MainAxisAlignment.SPACE_BETWEEN,
) )
def did_mount(self): def did_mount(self):
@ -102,7 +117,7 @@ class WuttaHeader(WuttaControl):
def update_training_display(self): def update_training_display(self):
if self.page.session.get('training'): if self.page.session.get('training'):
self.training_mode.value = "TRAINING MODE" self.training_mode.value = " TRAINING MODE "
else: else:
self.training_mode.value = "" self.training_mode.value = ""

View file

@ -60,9 +60,11 @@ class WuttaTransactionLookup(WuttaLookup):
# TODO: how to deal with 'modes' # TODO: how to deal with 'modes'
assert self.mode == 'resume' assert self.mode == 'resume'
training = bool(self.mypage.session.get('training'))
query = session.query(model.POSBatch)\ query = session.query(model.POSBatch)\
.filter(model.POSBatch.status_code == model.POSBatch.STATUS_SUSPENDED)\ .filter(model.POSBatch.status_code == model.POSBatch.STATUS_SUSPENDED)\
.filter(model.POSBatch.executed == None)\ .filter(model.POSBatch.executed == None)\
.filter(model.POSBatch.training_mode == training)\
.order_by(model.POSBatch.created.desc()) .order_by(model.POSBatch.created.desc())
transactions = [] transactions = []

View file

@ -1000,7 +1000,7 @@ class POSView(WuttaView):
# prompt to choose txn # prompt to choose txn
dlg = ft.AlertDialog( dlg = ft.AlertDialog(
title=ft.Text("Resume Transaction"), title=ft.Text("Resume Transaction"),
content=WuttaTransactionLookup(self.config, mode='resume', content=WuttaTransactionLookup(self.config, page=self.page, mode='resume',
on_select=select, on_cancel=cancel), on_select=select, on_cancel=cancel),
) )
@ -1410,6 +1410,7 @@ class POSView(WuttaView):
on_click=self.list_item_click, on_click=self.list_item_click,
data={'row': row}, data={'row': row},
key=row.uuid, key=row.uuid,
bgcolor='white',
)) ))
if scroll: if scroll: