Add responsive mobile view for Inventory with configurable columns
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Controller Tests / controller-tests (push) Waiting to run
Jest Tests / jest-tests (push) Waiting to run

Portrait mobile shows a condensed, read-only table; landscape/tablet+ keeps
the full editable spreadsheet.  The columns shown on mobile are configurable
per field via a new "Mobile" toggle in the Customize Fields editor.

- defaults.py: seed `mobile` on each type's default columns (food: Name,
  Subcategory, Size, Count; fuel/tool: sensible analogs).
- FieldSchemaEditor: per-field Mobile toggle (persists through PUT /<slug>/fields).
- InventoryItemsMobile: read-only condensed view driven by the `mobile` flag,
  falling back to a default column set for schemas predating the flag.
- InventoryRoute: split Items tab via <Media> — mobile vs tablet+.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roland 2026-06-18 13:56:53 -06:00
parent 3d6aead072
commit cc5afe3fbc
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
6 changed files with 190 additions and 29 deletions

View file

@ -57,34 +57,36 @@ DEFAULT_FOOD_CATEGORIES = [
_FOOD_CATEGORY_OPTIONS = sorted({category for _, category in DEFAULT_FOOD_CATEGORIES})
DEFAULT_FIELD_SETS = {
# `mobile=True` marks the columns shown in the condensed, read-only portrait-mobile view; the user can change
# which fields are mobile in the field-schema editor.
'food': [
_field('brand', 'Brand', 'text', 0),
_field('name', 'Name', 'text', 1, required=True),
_field('name', 'Name', 'text', 1, required=True, mobile=True),
_field('category', 'Category', 'select', 2, options=_FOOD_CATEGORY_OPTIONS),
_field('subcategory', 'Subcategory', 'text', 3),
_field('item_size', 'Size', 'quantity', 4, unit='lb'),
_field('count', 'Count', 'number', 5),
_field('subcategory', 'Subcategory', 'text', 3, mobile=True),
_field('item_size', 'Size', 'quantity', 4, unit='lb', mobile=True),
_field('count', 'Count', 'number', 5, mobile=True),
_field('calories', 'kcal per unit', 'calories', 6),
_field('expiration_date', 'Expires', 'date', 7),
],
'fuel': [
_field('name', 'Name', 'text', 0, required=True),
_field('name', 'Name', 'text', 0, required=True, mobile=True),
_field('fuel_type', 'Fuel Type', 'select', 1,
options=['gasoline', 'diesel', 'propane', 'kerosene', 'oil']),
options=['gasoline', 'diesel', 'propane', 'kerosene', 'oil'], mobile=True),
_field('container', 'Container', 'text', 2),
_field('item_size', 'Size', 'quantity', 3, unit='gallon'),
_field('count', 'Count', 'number', 4),
_field('item_size', 'Size', 'quantity', 3, unit='gallon', mobile=True),
_field('count', 'Count', 'number', 4, mobile=True),
_field('purchase_date', 'Purchased', 'date', 5),
_field('location', 'Location', 'location', 6),
],
'tool': [
_field('name', 'Name', 'text', 0, required=True),
_field('name', 'Name', 'text', 0, required=True, mobile=True),
_field('brand', 'Brand', 'text', 1),
_field('category', 'Category', 'select', 2,
options=['hand', 'power', 'garden', 'automotive', 'measuring', 'safety']),
_field('count', 'Count', 'number', 3),
options=['hand', 'power', 'garden', 'automotive', 'measuring', 'safety'], mobile=True),
_field('count', 'Count', 'number', 3, mobile=True),
_field('condition', 'Condition', 'select', 4, options=['new', 'good', 'worn', 'broken']),
_field('location', 'Location', 'location', 5),
_field('location', 'Location', 'location', 5, mobile=True),
_field('notes', 'Notes', 'text', 6),
],
}