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:
@@ -1,7 +1,20 @@
|
||||
{{define "asset_fields_only"}}
|
||||
{{if .}}
|
||||
{{if not .IsUnique}}
|
||||
<div class="mb-3">
|
||||
<label class="form-label" for="assetFormQuantity">Quantity</label>
|
||||
<div class="input-group" style="max-width: 220px">
|
||||
<button class="btn btn-outline-secondary" type="button" data-action="quantity-step" data-step="-1">−</button>
|
||||
<input type="number" class="form-control text-center" name="quantity" id="assetFormQuantity" min="0" step="1" value="{{.Quantity}}">
|
||||
<button class="btn btn-outline-secondary" type="button" data-action="quantity-step" data-step="1">+</button>
|
||||
</div>
|
||||
<div class="form-text">This item type isn't Unique, so it's tracked by quantity instead of one row per unit.</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<input type="hidden" name="quantity" value="1">
|
||||
{{end}}
|
||||
{{if .Fields}}
|
||||
<h6 class="mt-3 mb-2">Type-Specific Fields</h6>
|
||||
{{range .}}
|
||||
{{range .Fields}}
|
||||
{{$fv := .}}
|
||||
<div class="mb-2">
|
||||
<label class="form-label" for="field-{{.Def.ID}}">{{.Def.Name}}{{if .Def.Required}} <span class="text-danger">*</span>{{end}}</label>
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
<select class="form-select" name="assigned_user_id">
|
||||
<option value="">Unassigned</option>
|
||||
{{range .Users}}
|
||||
<option value="{{.ID}}" {{if eq $selectedUser .ID}}selected{{end}}>{{.Username}}</option>
|
||||
<option value="{{.ID}}" {{if eq $selectedUser .ID}}selected{{end}}>{{.Username}}{{if eq .Role "contact"}} (Contact){{end}}</option>
|
||||
{{end}}
|
||||
</select>
|
||||
</div>
|
||||
@@ -60,7 +60,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col-12" id="asset-fields-container">
|
||||
{{template "asset_fields_only" .Fields}}
|
||||
{{template "asset_fields_only" (dict "IsUnique" .SelectedITUnique "Quantity" .Quantity "Fields" .Fields)}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -128,6 +128,29 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Check out / check in asset -->
|
||||
<div class="modal fade" id="checkoutModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="checkoutModalTitle">Check Out Asset</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="text-body-secondary small mb-3" id="checkoutCurrent"></p>
|
||||
<label class="form-label">Assigned User</label>
|
||||
<select class="form-select" id="checkoutUserSelect">
|
||||
<option value="">Unassigned (check in)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" id="confirmCheckoutBtn">Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import CSV into a specific folder (right-click a folder > Import CSV...) -->
|
||||
<div class="modal fade" id="importModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
|
||||
@@ -25,7 +25,19 @@
|
||||
<div class="card-header py-2 fw-semibold">Details</div>
|
||||
<table class="table table-sm mb-0">
|
||||
<tbody>
|
||||
<tr><th class="w-25">Assigned User</th><td>{{if .Asset.AssignedUsername}}{{.Asset.AssignedUsername}}{{else}}<span class="text-body-secondary">Unassigned</span>{{end}}</td></tr>
|
||||
<tr><th class="w-25">Assigned User</th><td>{{if .Asset.AssignedUsername}}{{.Asset.AssignedUsername}}{{else}}<span class="text-body-secondary">Unassigned — right-click above to check out</span>{{end}}</td></tr>
|
||||
{{if not .Asset.ItemTypeIsUnique}}
|
||||
<tr>
|
||||
<th>Quantity</th>
|
||||
<td>
|
||||
<div class="input-group input-group-sm" style="max-width: 150px" data-quantity-stepper data-asset-id="{{.Asset.ID}}">
|
||||
<button class="btn btn-outline-secondary" type="button" data-action="panel-quantity-step" data-step="-1">−</button>
|
||||
<span class="form-control text-center" data-quantity-value>{{.Asset.Quantity}}</span>
|
||||
<button class="btn btn-outline-secondary" type="button" data-action="panel-quantity-step" data-step="1">+</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
<tr><th>Created</th><td>{{fmtDate .Asset.CreatedAt}}</td></tr>
|
||||
<tr><th>Updated</th><td>{{fmtDate .Asset.UpdatedAt}}</td></tr>
|
||||
</tbody>
|
||||
|
||||
@@ -38,13 +38,23 @@
|
||||
{{if .Assets}}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm table-hover asset-table">
|
||||
<thead><tr><th>Asset ID</th><th>Name</th><th>Type</th><th>Status</th><th>Assigned</th></tr></thead>
|
||||
<thead><tr><th>Asset ID</th><th>Name</th><th>Type</th><th>Qty</th><th>Status</th><th>Assigned</th></tr></thead>
|
||||
<tbody>
|
||||
{{range .Assets}}
|
||||
<tr class="asset-row" data-id="{{.ID}}">
|
||||
<td>{{.AssetTag}}</td>
|
||||
<td><i class="bi {{iconOr .ItemTypeIcon "bi-box-seam"}} me-1"></i>{{.Name}}</td>
|
||||
<td>{{.ItemTypeName}}</td>
|
||||
<td>
|
||||
{{if .ItemTypeIsUnique}}<span class="text-body-secondary">—</span>
|
||||
{{else}}
|
||||
<div class="input-group input-group-sm" style="width:6.5rem" data-quantity-stepper data-asset-id="{{.ID}}">
|
||||
<button class="btn btn-outline-secondary py-0" type="button" data-action="table-quantity-step" data-step="-1">−</button>
|
||||
<span class="form-control text-center py-0" data-quantity-value>{{.Quantity}}</span>
|
||||
<button class="btn btn-outline-secondary py-0" type="button" data-action="table-quantity-step" data-step="1">+</button>
|
||||
</div>
|
||||
{{end}}
|
||||
</td>
|
||||
<td><span class="badge text-bg-{{.StatusColor}}">{{.StatusName}}</span></td>
|
||||
<td>{{if .AssignedUsername}}{{.AssignedUsername}}{{else}}<span class="text-body-secondary">—</span>{{end}}</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user