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:
@@ -0,0 +1,50 @@
|
||||
{{define "content"}}
|
||||
<style>{{.SheetCSS}}
|
||||
@media print {
|
||||
.app-navbar, .print-toolbar { display: none !important; }
|
||||
body { margin: 0; background: #fff; }
|
||||
.label-sheet { margin: 0; }
|
||||
}
|
||||
.label-tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; font-size: 11pt; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.label-name { font-size: 8pt; color: #333; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
</style>
|
||||
|
||||
<div class="print-toolbar d-flex flex-wrap align-items-center gap-3 p-3 border-bottom">
|
||||
<button class="btn btn-primary" onclick="window.print()"><i class="bi bi-printer"></i> Print</button>
|
||||
<span class="text-body-secondary">{{len .Labels}} label(s)</span>
|
||||
<form method="get" class="d-flex align-items-center gap-2 ms-auto">
|
||||
{{if .AssetID}}<input type="hidden" name="asset_id" value="{{.AssetID}}">{{end}}
|
||||
{{if .FolderID}}<input type="hidden" name="folder_id" value="{{.FolderID}}">{{end}}
|
||||
{{if .Recursive}}<input type="hidden" name="recursive" value="1">{{end}}
|
||||
<label class="form-label mb-0 small text-body-secondary" for="labelTemplateSelect">Label sheet</label>
|
||||
<select class="form-select form-select-sm" id="labelTemplateSelect" name="template" onchange="this.form.submit()">
|
||||
{{range $key := .TemplateKeys}}
|
||||
{{$t := index $.Templates $key}}
|
||||
<option value="{{$key}}" {{if eq $key $.Selected.Key}}selected{{end}}>{{$t.DisplayName}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{{if .Selected.Approximate}}
|
||||
<div class="alert alert-warning m-3">
|
||||
This layout's grid/margins aren't from a verified spec sheet - print one test page on plain paper and
|
||||
hold it up to a real label sheet before printing a full (often waterproof, non-refundable) sheet.
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="label-sheet">
|
||||
{{range .Labels}}
|
||||
<div class="label">
|
||||
<img src="{{.QRData}}" alt="QR code for {{.Asset.AssetTag}}">
|
||||
<div class="min-w-0">
|
||||
<div class="label-tag">{{.Asset.AssetTag}}</div>
|
||||
<div class="label-name">{{.Asset.Name}}</div>
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{if not .Labels}}
|
||||
<p class="text-body-secondary p-3">No assets to print.</p>
|
||||
{{end}}
|
||||
{{end}}
|
||||
Reference in New Issue
Block a user