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

View File

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

View File

@@ -161,7 +161,7 @@ class Navbar(rio.Component):
), ),
#fill=self.session.theme.neutral_color, #fill=self.session.theme.neutral_color,
fill=rio.FrostedGlassFill( fill=rio.FrostedGlassFill(
color=rio.Color.from_hex("#a850f480"), color=rio.Color.from_hex("#a850f4ff"),
blur_size = 0.2 blur_size = 0.2
), ),
#corner_radius=self.session.theme.corner_radius_medium, #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: if get_location_id(self.parent) != False:
self.parent_code = self.parent self.parent_code = self.parent
print("Found location " + get_location_id(self.parent).name) 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): async def add_part(self):
if self.code == "": if self.code == "":

View File

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

View File

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

View File

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