Autofocus, autorefresh

This commit is contained in:
2025-09-30 14:33:48 -05:00
parent 97cb5a6e3e
commit 2af690ee15
7 changed files with 27 additions and 19 deletions

View File

@@ -107,7 +107,7 @@ def init():
print("Cache build complete.")
# locations_list()
def search_item(query, filters: dict={}):
def search_item(query, filters: dict={}) -> list:
#print(filters)
if len(filters) > 0:
filt = ""
@@ -230,6 +230,7 @@ def delete_item_id(barcode):
#item.delete(itm)
itm = get_item(barcode)
itm.delete_instance()
search.delete_document(barcode)
def item_location_str(itm):
try:

View File

@@ -19,10 +19,11 @@ from db_classes import init
# https://rio.dev/docs/api/theme
theme = rio.Theme.from_colors(
secondary_color=rio.Color.from_hex("#84329B"),
primary_color=rio.Color.from_hex("#84329B"),
primary_color=rio.Color.from_hex("#020f22"),
#neutral_color=rio.Color.from_hex("#a850f480"),
neutral_color=rio.Color.from_hex("#D0A2F7"),
mode='light',
neutral_color=rio.Color.from_hex("#BBC7D6c0"),
background_color=rio.Color.from_hex("#7D9CC0"),
mode='dark',
)
init()

View File

@@ -161,7 +161,7 @@ class Navbar(rio.Component):
),
#fill=self.session.theme.neutral_color,
fill=rio.FrostedGlassFill(
color=rio.Color.from_hex("#a850f480"),
color=rio.Color.from_hex("#a850f4ff"),
blur_size = 0.2
),
#corner_radius=self.session.theme.corner_radius_medium,

View File

@@ -30,7 +30,7 @@ class AddLocationPage(rio.Component):
if get_location_id(self.parent) != False:
self.parent_code = self.parent
print("Found location " + get_location_id(self.parent).name)
self.parent = '*' + get_location_id(self.parent).name
self.parent = '* ' + fancy_location(get_location_id(self.parent))
async def add_part(self):
if self.code == "":

View File

@@ -8,7 +8,7 @@ import datetime
from mac_vendor_lookup import AsyncMacLookup
# from db_classes import *
from db_classes import get_location_id, create_item
from db_classes import get_location_id, create_item, fancy_location
from .. import components as comps
import asyncio
@@ -141,7 +141,7 @@ class AddPage(rio.Component):
if get_location_id(self.location) != False:
self.location_code = self.location
print("Found location " + get_location_id(self.location).name)
self.location = '*' + get_location_id(self.location).name
self.location = '* ' + fancy_location(get_location_id(self.location))
def _update_partnum(self, event: rio.TextInputChangeEvent):

View File

@@ -59,17 +59,16 @@ class BrowsePage(rio.Component):
self.office = self.session[comps.Settings].office
#print("Office:",self.office)
self.filters['office'] = self.office
self.items = search_item(query, self.filters)
if query == "":
self.items.sort(key=lambda i: i["fullname"])
mid = time()
self.loading_text = "Loading data..."
#self.force_refresh()
end = time()
self.loading_text = ""
render = str(int((end - mid) * 1000)) + "ms"
search = str(int((mid - start) * 1000)) + "ms"
self.loading_text = search + " search, " + render + " load and render"
self.loading_text = search + " search time"
@rio.event.periodic(1)
async def set_office_init(self):
@@ -143,8 +142,11 @@ class BrowsePage(rio.Component):
async def _delete_edit_popup(self):
self.popup_message = "\n Part deleted! \n\n"
self.popup_show = True
self.popup_color = 'success'
self.edit_show = False
self.info_show = True
self.info_show = False
self.force_refresh()
delete_item_id(self.ibarcode)
await self._search()
@@ -230,7 +232,7 @@ class BrowsePage(rio.Component):
if get_location_id(self.elocation) != False:
self.elocation_code = self.elocation
print("Found location " + get_location_id(self.elocation).name)
self.elocation = '*' + get_location_id(self.elocation).name
self.elocation = '* ' + fancy_location(get_location_id(self.elocation))
def build(self) -> rio.Component:
searchview: rio.ListView = rio.ListView(grow_y=True)
@@ -238,15 +240,15 @@ class BrowsePage(rio.Component):
if len(self.searchtext) > 2:
check = True
ref = self.searchtext.lower()
icon_ref = rio.Icon("material/stars", fill=rio.Color.from_hex("#3FBF3F"))
#icon_ref =
for item in self.items:
icon = None
if check:
# if the search has an exact match anywhere
for val in item.values():
if type(val) is str and val.lower() == ref:
icon=icon_ref
if type(val) is str and val.lower() == ref and len(self.searchtext) > 2:
icon=rio.Icon("material/stars", fill=rio.Color.from_hex("#3FBF3F"))
try:
loc = item["location"]
except:
@@ -338,7 +340,7 @@ class BrowsePage(rio.Component):
rio.TextInput(
label="Barcode",
text=self.bind().ecode,
is_sensitive=False
is_sensitive=False,
),
rio.TextInput(
label="Full part number",
@@ -398,7 +400,8 @@ class BrowsePage(rio.Component):
rio.TextInput(
text=self.bind().searchtext,
on_change=self._search_trigger,
label="Search"
label="Search",
auto_focus=True
),
rio.Text(

View File

@@ -71,6 +71,9 @@ class InventorySearch:
taskinfo = self.add_document(i)
return taskinfo
def delete_document(self, docid):
return self.idxref.delete_document(docid)
def update_filterables(self, filterables: list):
"""Update filterable attributes and wait for database to fully index. If the filterable attributes matches the
current attributes in the database, don't update (saves reindexing).