Fix checkin/out pages, add location refresh, and misc bugfix

This commit is contained in:
2026-04-09 17:16:56 -05:00
parent 6952402178
commit f793bd01e1
6 changed files with 97 additions and 32 deletions

View File

@@ -15,8 +15,8 @@ class CheckinPage(rio.Component):
popup_message: str = ""
popup_show: bool = False
popup_color: str = 'warning'
name: str = ""
user_code: str = ""
name: str = ""
loc_code: str = ""
loc: str = ""
@@ -25,35 +25,43 @@ class CheckinPage(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 _checkin_item_enter(self, event: rio.TextInputConfirmEvent):
await self.check_in()
async def check_in(self):
if checkin(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 checkin(user, self.code, loc):
self.popup_message = "\n Item checked in! \n\n"
self.popup_show = True
self.popup_color = 'success'
self.name: str = ""
self.user_code: str = ""
self.name: str = ""
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("/in")
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("/in")
self.popup_show = False
def build(self) -> rio.Component:
@@ -73,7 +81,8 @@ class CheckinPage(rio.Component):
),
rio.TextInput(
label="Barcode",
text=self.bind().code
text=self.bind().code,
auto_focus=True
),
rio.TextInput(
label="New location",
@@ -83,10 +92,17 @@ class CheckinPage(rio.Component):
rio.TextInput(
label="User",
text=self.bind().name,
on_confirm=self._checkin_item_enter
on_confirm=self.check_in,
on_change=self._update_user
),
# rio.TextInput(
# label="N/A",
# text="",
# on_confirm=self.check_in,
# ),
rio.Button(
content="Go"
content="Go",
on_press=self.check_in
),
spacing=2,