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

@ -98,17 +98,8 @@ export function InventoryTable({slug, fields, items, locations, catalog, onChang
setSort(null);
}, [slug, fields]);
// Expired = any date-type field strictly before the start of today.
const dateFields = useMemo(() => fields.filter(f => f.type === 'date'), [fields]);
const todayStart = useMemo(() => {
const d = new Date();
d.setHours(0, 0, 0, 0);
return d.getTime();
}, []);
const isExpired = (item) => dateFields.some(f => {
const t = Date.parse(item[f.key]);
return !isNaN(t) && t < todayStart;
});
// Expired = any date-type field strictly before the start of today (shared with the mobile view).
const isExpired = (item) => isItemExpired(item, fields);
const toggleSort = (key) => setSort(prev =>
prev && prev.key === key
@ -273,7 +264,8 @@ export function InventoryTable({slug, fields, items, locations, catalog, onChang
</>;
}
function formatValue(item, field) {
// Format an item's value for a field for display (shared with the read-only mobile view).
export function formatValue(item, field) {
const value = item[field.key];
if (value === '' || value == null) {
return '';
@ -284,3 +276,16 @@ function formatValue(item, field) {
}
return String(value);
}
// True when any `date`-type field is before the start of today (item is expired).
export function isItemExpired(item, fields) {
const start = new Date();
start.setHours(0, 0, 0, 0);
return (fields || []).some(f => {
if (f.type !== 'date') {
return false;
}
const t = Date.parse(item[f.key]);
return !isNaN(t) && t < start.getTime();
});
}