Fix checkin/out pages, add location refresh, and misc bugfix
This commit is contained in:
@@ -26,20 +26,22 @@ class CheckoutPage(rio.Component):
|
||||
if get_location_id(self.loc) != False:
|
||||
self.loc_code = self.loc
|
||||
print("Found location " + get_location_id(self.loc).name)
|
||||
self.loc = get_location_id(self.loc).name
|
||||
self.loc = '* ' + fancy_location(get_location_id(self.loc))
|
||||
|
||||
async def _update_user(self, event: rio.TextInputChangeEvent):
|
||||
print("Checking " + self.name)
|
||||
if get_location_id(self.name) != False:
|
||||
if get_user(self.name) != False:
|
||||
self.user_code = self.name
|
||||
print("Found user " + get_user(self.name).name)
|
||||
self.name = get_user(self.name).name
|
||||
self.name = '* ' + get_user(self.name).name
|
||||
|
||||
async def _checkout_item_enter(self, event: rio.TextInputConfirmEvent):
|
||||
await self.check_out()
|
||||
|
||||
async def check_out(self):
|
||||
if checkout(get_user(self.user_code), self.code, get_location_id(self.loc_code)):
|
||||
user = get_user(self.user_code)
|
||||
loc = get_location_id(self.loc_code)
|
||||
if user is not False and checkout(user, self.code, loc):
|
||||
self.popup_message = "\n Item checked out! \n\n"
|
||||
self.popup_show = True
|
||||
self.popup_color = 'success'
|
||||
@@ -48,13 +50,19 @@ class CheckoutPage(rio.Component):
|
||||
self.code: str = ""
|
||||
self.loc_code: str = ""
|
||||
self.loc: str = ""
|
||||
await asyncio.sleep(2)
|
||||
await asyncio.sleep(0.5)
|
||||
self.session.navigate_to("/")
|
||||
await asyncio.sleep(0.01)
|
||||
self.session.navigate_to("/out")
|
||||
self.popup_show = False
|
||||
else:
|
||||
self.popup_message = "\n Error! Check item & location! \n\n"
|
||||
self.popup_show = True
|
||||
self.popup_color = 'warning'
|
||||
await asyncio.sleep(2)
|
||||
self.session.navigate_to("/")
|
||||
await asyncio.sleep(0.01)
|
||||
self.session.navigate_to("/out")
|
||||
self.popup_show = False
|
||||
|
||||
def build(self) -> rio.Component:
|
||||
@@ -74,7 +82,8 @@ class CheckoutPage(rio.Component):
|
||||
),
|
||||
rio.TextInput(
|
||||
label="Barcode",
|
||||
text=self.bind().code
|
||||
text=self.bind().code,
|
||||
auto_focus=True
|
||||
),
|
||||
rio.TextInput(
|
||||
label="New location",
|
||||
@@ -84,10 +93,17 @@ class CheckoutPage(rio.Component):
|
||||
rio.TextInput(
|
||||
label="User",
|
||||
text=self.bind().name,
|
||||
on_confirm=self._checkout_item_enter
|
||||
on_confirm=self.check_out,
|
||||
on_change=self._update_user
|
||||
),
|
||||
# rio.TextInput(
|
||||
# label="N/A",
|
||||
# text="",
|
||||
# on_confirm=self.check_out,
|
||||
# ),
|
||||
rio.Button(
|
||||
content="Go"
|
||||
content="Go",
|
||||
on_press=self.check_out,
|
||||
),
|
||||
|
||||
spacing=2,
|
||||
|
||||
Reference in New Issue
Block a user