Add asset checkout, quantity/uniqueness, contacts, and QR labels

Checkout:
- assets.AssignUser + POST /app/assets/{id}/checkout assign/unassign an
  asset's user independent of the full edit form. New shared
  #checkoutModal, wired from a "Check Out..." context-menu action, backed
  by GET /app/assets/{id} and GET /app/users/options JSON endpoints.

Quantity / uniqueness:
- Item types gain an IsUnique flag (checked by default, matching prior
  behavior). Assets gain a Quantity column, fixed at 1 for unique types
  and adjustable via +/- steppers (POST /app/assets/{id}/quantity) for
  non-unique ones. Flipping a type back to unique clamps existing assets'
  quantity back to 1. CSV import/export gained a Quantity column.
  Migration 0003_quantity.sql.

Contacts:
- New models.RoleContact: an assignable person who cannot sign in
  (User.CanLogin). Migration 0004_contacts.sql rebuilds the users table
  (SQLite can't alter a CHECK constraint in place) to allow the role.
  Users form/list updated; contact creation auto-generates an unusable
  password since the login path is blocked by role regardless.

QR asset tags and printable labels:
- Each asset's QR code (via github.com/skip2/go-qrcode, pure Go) encodes
  an absolute /scan/<tag> URL; GET /scan/{tag} resolves it and redirects
  into /inventory?asset=<id>, which app.js picks up on load to
  auto-select that asset - works from a phone camera or a USB
  scanner-as-keyboard-wedge pointed at the address bar.
- GET /labels renders a print-ready sheet (right-click an asset for one
  label, a folder for every asset in it) with a template switcher between
  Avery 5160 (verified dimensions) and 61526 asset tag labels (best-effort
  layout, flagged as such on the page).

Also refreshed README to reflect the right-click-first tree UX and all of
the above.
This commit is contained in:
Owen
2026-08-17 16:28:14 -05:00
parent 42e7b2a21c
commit fb85c9edbb
31 changed files with 975 additions and 77 deletions
+59 -13
View File
@@ -66,8 +66,12 @@ asset).
never fully reloads when you browse the tree.
- **Drag and drop** folders and assets onto another folder (or onto
"Inventory" itself) to move them. Admin only.
- **Right-click-style actions**: each folder has a "…" action menu (New
Subfolder, Add Asset, Rename, Delete).
- **Right-click for everything**: it's meant to feel like a native file
manager. Right-click a folder, an asset, a breadcrumb crumb, or empty
tree/panel background for the actions available there (New Subfolder, Add
Asset, Rename, Check Out, Move, Print Label, Delete, …) instead of hunting
for a toolbar button. The main panel itself stays blank until you actually
click into a folder or asset — browsing happens in the tree.
- **Deleting a folder** that still contains subfolders or assets requires
confirmation, and offers a safe "move contents elsewhere" option instead
of an accidental cascade. A "permanently delete everything inside" option
@@ -84,21 +88,63 @@ number, date, boolean, dropdown, URL, IP address), marked required or not,
with a default value and display order. A representative starter set of
types and fields is seeded on first run — feel free to edit or delete it.
## Checkout, quantity, and contacts
- **Check out / check in**: right-click an asset → **Check Out…** to assign
it to a user (or clear the assignment to check it back in). Works from any
asset row, not just its detail view.
- **Quantity vs. unique**: item types have a **Unique** flag (checked by
default). Unique types — a laptop, a server — get one asset row per
physical unit, same as before. Uncheck it for bulk/consumable types (a USB
cable, a box of screws) and assets of that type are tracked as a single
row with a **Quantity** and +/- steppers in the asset panel and folder
tables, instead of one row per unit. Flipping a type back to Unique clamps
any existing quantities back down to 1.
- **Contacts**: under Settings → Users, a third role alongside Admin and
User. Contacts can't sign in at all — they exist purely so you can assign
assets to end users (e.g. "this laptop belongs to Jane in Accounting")
without creating them a login account. A blank password is fine when
creating one.
## QR asset tags and printable labels
Every asset can have a QR-coded label printed for it: right-click an asset
for **Print Label**, or right-click a folder for **Print Labels…** (every
asset in that folder, recursively). The QR code encodes an absolute
`/scan/<Asset ID>` URL, so scanning it with a phone camera — or a USB
barcode/QR scanner focused on the browser's address bar — opens straight to
that asset.
The print page supports two label sheet layouts, switchable from a dropdown
on the page itself:
- **Avery 5160** (1" x 2-5/8", 30/sheet) — standard address labels, exact
published dimensions.
- **61526** asset tag labels (3/4" x 2", ~48/sheet) — the grid/margins here
are a best-effort layout, not a verified spec sheet, so print one test
page on plain paper and check it against a real label before committing a
full (often non-refundable) sheet.
## CSV import / export
- **Export**: from the Inventory toolbar, or `/export/assets.csv` (optionally
scoped to a folder, with `?recursive=1` to include subfolders). Includes
one `cf_<field_key>` column per distinct custom field in use.
- **Import**: CSV with columns `Asset ID` (optional — auto-generated if
blank), `Name`, `Item Type`, `Folder` (a `/`-separated path, e.g.
`Main Office/Network`), `Status`, `Assigned User`, `Notes`, plus
`cf_<field_key>` columns for custom fields. Existing assets are matched
and updated by Asset ID; everything else is created. Missing folders in
the path can optionally be created automatically.
- **Export**: from the tree's right-click menu, or `/export/assets.csv`
(optionally scoped to a folder, with `?recursive=1` to include
subfolders). Includes a `Quantity` column and one `cf_<field_key>` column
per distinct custom field in use.
- **Folder-scoped import**: right-click a folder → **Import CSV…** imports
every row directly into that folder. No `Folder` column needed — that's
the whole point of doing it from a specific folder. Never available at the
top level.
- **Global import**: Settings → Import / Export has the full-featured
version — a CSV with a `Folder` column (a `/`-separated path, e.g.
`Main Office/Network`) that can optionally auto-create missing folders —
plus a separate CSV import for bulk-adding/updating Statuses (`Name`,
`Color`). Both matching-by-name/Asset-ID semantics and full column
references with examples are documented right on that page.
A full backup/restore of everything (folders, assets, types, custom fields,
statuses) is just `inventree database backup` — it's a consistent snapshot
of the whole SQLite database.
statuses, users) is just `inventree database backup` — it's a consistent
snapshot of the whole SQLite database.
## Project layout