printedparts stage 16: kiosk touch fixes from first hands-on use
The tap-anywhere wedge refocus stole focus from the manual-entry field the moment it was tapped - the handler now only reclaims focus from dead space, never from a real control. Manual entry works without a physical keyboard: badge entry uses the TouchKeypad (an SSO is digits), and item lookup accepts bare digits resolved by row id - the digits in a minted code are the id, which also keeps labels printed under an older prefix scannable after the prefix changes.
This commit is contained in:
@@ -381,12 +381,28 @@ def adjust_item(item_id: int):
|
||||
# physically rate-limited. It can reduce stock of an active item and nothing
|
||||
# else; identity comes from the badge resolved server-side, never the client.
|
||||
|
||||
def _kiosk_find_item(itemcode):
|
||||
"""Resolve a scanned or typed code to an active item.
|
||||
|
||||
Accepts the full code (WJRP0042) or bare digits from the touch keypad
|
||||
(42 -> prefix + zero-pad), so manual entry never needs letters."""
|
||||
itemcode = (itemcode or '').strip()
|
||||
item = PrintedItem.query.filter(
|
||||
PrintedItem.itemcode == itemcode,
|
||||
PrintedItem.isactive == True).first()
|
||||
if not item and itemcode.isdigit():
|
||||
# The digits in a minted code ARE the row id, so id lookup keeps
|
||||
# working even for labels printed under an older prefix.
|
||||
candidate = db.session.get(PrintedItem, int(itemcode))
|
||||
if candidate and candidate.isactive:
|
||||
item = candidate
|
||||
return item
|
||||
|
||||
|
||||
@printedparts_bp.route('/kiosk/item/<itemcode>', methods=['GET'])
|
||||
def kiosk_item(itemcode):
|
||||
"""Item summary for a scanned bin barcode (open read for the kiosk)."""
|
||||
item = PrintedItem.query.filter(
|
||||
PrintedItem.itemcode == itemcode.strip(),
|
||||
PrintedItem.isactive == True).first()
|
||||
item = _kiosk_find_item(itemcode)
|
||||
if not item:
|
||||
return error_response(ErrorCodes.NOT_FOUND,
|
||||
'No part matches that barcode', http_code=404)
|
||||
@@ -398,9 +414,7 @@ def kiosk_take():
|
||||
"""Take parts from a bin. Body: {itemcode, badge, quantity}."""
|
||||
data = request.get_json() or {}
|
||||
|
||||
item = PrintedItem.query.filter(
|
||||
PrintedItem.itemcode == (data.get('itemcode') or '').strip(),
|
||||
PrintedItem.isactive == True).first()
|
||||
item = _kiosk_find_item(data.get('itemcode'))
|
||||
if not item:
|
||||
return error_response(ErrorCodes.NOT_FOUND,
|
||||
'No part matches that barcode', http_code=404)
|
||||
|
||||
Reference in New Issue
Block a user