Move the '@' button next to main input

not really needed on the 10-key, so replace that with minus sign

this also adds feature to select a line item, then click ITEM to
re-ring the same item (and honor set quantity)
This commit is contained in:
Lance Edgar 2023-10-12 17:23:51 -05:00
parent 7b73438cf9
commit d933a6acbc
2 changed files with 58 additions and 35 deletions

View file

@ -53,7 +53,7 @@ class WuttaTenkeyMenu(WuttaControl):
]
if not self.simple:
row1.extend([
self.make_tenkey_button("@"),
self.make_tenkey_button("-"),
])
row2 = [

View file

@ -78,8 +78,10 @@ class POSView(WuttaView):
"""
# clear set (@) quantity
if clear_quantity:
if self.set_quantity.data:
self.set_quantity.data = None
self.set_quantity.value = None
self.set_quantity_button.visible = True
# clear/focus main input
self.main_input.value = ''
@ -114,6 +116,15 @@ class POSView(WuttaView):
if not self.attempt_add_product():
self.item_lookup(value)
elif self.selected_item:
row = self.selected_item.data['row']
if row.product_uuid:
if self.attempt_add_product(uuid=row.product_uuid):
self.clear_item_selection()
self.page.update()
else:
self.item_lookup()
else:
self.item_lookup()
@ -504,34 +515,6 @@ class POSView(WuttaView):
self.customer_lookup()
def tenkey_char(self, key):
if key == '@':
quantity = self.main_input.value
valid = False
if self.set_quantity.data is not None:
quantity = self.set_quantity.data
self.show_snackbar(f"QUANTITY ALREADY SET: {quantity}", bgcolor='yellow')
else:
try:
quantity = decimal.Decimal(quantity)
valid = True
except decimal.InvalidOperation:
pass
if valid and quantity:
self.set_quantity.data = quantity
self.set_quantity.value = self.app.render_quantity(quantity) + " @ "
self.main_input.value = ""
self.main_input.focus()
else:
self.show_snackbar(f"INVALID @ QUANTITY: {quantity}", bgcolor='yellow')
self.page.update()
else: # normal char
self.main_input.value = f"{self.main_input.value or ''}{key}"
self.main_input.focus()
self.page.update()
@ -630,6 +613,7 @@ class POSView(WuttaView):
elif self.set_quantity.data is not None:
self.set_quantity.data = None
self.set_quantity.value = None
self.set_quantity_button.visible = True
elif self.selected_item:
self.clear_item_selection()
self.main_input.focus()
@ -743,15 +727,27 @@ class POSView(WuttaView):
self.set_quantity = ft.Text(value=None, data=None, weight=ft.FontWeight.BOLD, size=40)
self.set_quantity_button = self.make_button("@",
font_size=40,
height=70,
width=70,
bgcolor='green',
on_click=self.set_quantity_click)
return [
self.build_header(),
ft.Row(
[
self.make_logo_image(height=80),
ft.Row(
[
ft.Row(
[
self.set_quantity,
self.set_quantity_button,
],
),
self.main_input,
self.make_button("", font_size=40, bgcolor='green',
height=70, width=70,
@ -799,6 +795,33 @@ class POSView(WuttaView):
kwargs.setdefault('size', 24)
return ft.Text(*args, **kwargs)
def set_quantity_click(self, e):
quantity = self.main_input.value
valid = False
if self.set_quantity.data is not None:
quantity = self.set_quantity.data
self.show_snackbar(f"QUANTITY ALREADY SET: {quantity}", bgcolor='yellow')
else:
try:
quantity = decimal.Decimal(quantity)
valid = True
except decimal.InvalidOperation:
pass
if valid and quantity:
self.set_quantity.data = quantity
self.set_quantity.value = self.app.render_quantity(quantity) + " @ "
self.set_quantity_button.visible = False
self.main_input.value = ""
self.main_input.focus()
else:
self.show_snackbar(f"INVALID @ QUANTITY: {quantity}", bgcolor='yellow')
self.page.update()
def make_tender_button(self, tender, **kwargs):
if isinstance(tender, self.model.Tender):
info = {'tender_code': tender.code,