wrolpi/app/src
Roland 305c73921e
Add "Count by Weight" to estimate item counts from weighing
Counting bulk hardware (screws, nails) by hand is slow.  This adds a workflow
to estimate the count from weight instead: weigh one item, weigh the lot, and
the count is filled in automatically.

- The Fields modal gains a "Count by Weight" button that adds two quantity
  fields, Unit Weight and Total Weight (default grams), and tags the Count
  field as computed.  An existing `count` field is linked in place rather than
  duplicated, so hand-counted items keep their values.
- The link is plain metadata on the Count field
  (`compute: {kind: 'count_by_weight', total, unit}`), so it round-trips
  through the config/API with no backend change (covered by a backend test).
- During item entry, Count = round(Total Weight / Unit Weight), converting
  mismatched units first (g/kg/oz) and refusing to divide when only one side
  has a unit.  It rounds to a whole number (no 403.7 nails).
- When a weight changes, the count always reflects the new reality: it is set
  to the computed value (0 for a sub-unit total) when both weights are present,
  or cleared when they can't produce one (a weight blanked, incompatible
  units) — so a stale count can never persist against edited weights.  A
  hand-typed count is only touched when a weight actually changes.

countByWeight lives in units.js; the field preset, config detection, and the
entry-time apply hook live in a new computeFields.js.  Covered by unit tests
(countByWeight, computeFields), InventoryTable auto-fill / clear / sub-unit on
draft and inline edit, the FieldSchemaEditor preset, and a backend
field-metadata round-trip.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 14:36:56 -06:00
..
api Warning users when files exist in mount location. Users may have accidentally downloaded files into the media directory, we want to warn them. 2026-05-14 17:02:52 -06:00
components Add "Count by Weight" to estimate item counts from weighing 2026-06-19 14:36:56 -06:00
contexts Migrating Controller from port 8087 to 80 so that it is more discoverable. Reformatting Controller dashboard to make header at the top. Reformatting navigation bar to handle the new links which prevented Admin from being visible in some screens. 2026-04-09 15:01:05 -06:00
hooks Rebuild Inventory as a config-only system with food catalog and calculators 2026-06-14 17:14:54 -06:00
types Converting Theme.js to typescript so we can use shorthands like Card.Icon. 2025-12-07 12:41:10 -07:00
api.js Rebuild Inventory as a config-only system with food catalog and calculators 2026-06-14 17:14:54 -06:00
App.css Add a recommended Food Storage example, a Ration tab, and a supply planner 2026-06-19 12:40:30 -06:00
App.js Rebuild Inventory as a config-only system with food catalog and calculators 2026-06-14 17:14:54 -06:00
DashboardPage.js Displaying warning when no drive is mounted. 2026-05-14 16:16:18 -06:00
DashboardPage.test.js Displaying warning when no drive is mounted. 2026-05-14 16:16:18 -06:00
Events.js Map search added to global search. Preview cards are displayed for all results in new Map tab. 2026-04-13 12:17:08 -06:00
index.css Renaming examples to avoid grouping of pdf with ebooks. Reworking URLs for media files to avoid escaping url safe characters. 2023-03-29 13:46:39 -06:00
index.js Fixing changes before merge. 2023-02-08 21:18:51 -07:00
logo.svg Renaming examples to avoid grouping of pdf with ebooks. Reworking URLs for media files to avoid escaping url safe characters. 2023-03-29 13:46:39 -06:00
reportWebVitals.js Renaming examples to avoid grouping of pdf with ebooks. Reworking URLs for media files to avoid escaping url safe characters. 2023-03-29 13:46:39 -06:00
setupTests.js Updating code to use new version of react-router. 2025-12-07 11:54:20 -07:00
Tags.cy.js Video downloads have many more options. Downloads are migrated. 2024-11-28 09:48:57 -07:00
Tags.js Reworking file preview buttons to be consistent across screens. 2026-04-15 13:18:45 -06:00
test-utils.js FileGroups in Collections can be reorganized in the Collection's directory. 2026-01-31 18:08:41 -07:00