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.
70 lines
3.1 KiB
HTML
70 lines
3.1 KiB
HTML
{{define "asset_form"}}
|
|
<form id="assetForm" data-mode="{{if .Asset}}edit{{else}}create{{end}}" {{if .Asset}}data-asset-id="{{.Asset.ID}}"{{end}}
|
|
data-title="{{if .Asset}}Edit {{.Asset.Name}}{{else}}New Asset{{end}}">
|
|
<div class="row g-3">
|
|
<div class="col-md-6">
|
|
<label class="form-label">Asset ID</label>
|
|
<input type="text" class="form-control" name="asset_id" value="{{if .Asset}}{{.Asset.AssetTag}}{{end}}" placeholder="Auto-generated if left blank">
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label">Name <span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" name="name" value="{{if .Asset}}{{.Asset.Name}}{{end}}" required autofocus>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<label class="form-label">Item Type <span class="text-danger">*</span></label>
|
|
{{if .Asset}}
|
|
<input type="text" class="form-control" value="{{.Asset.ItemTypeName}}" disabled>
|
|
<div class="form-text">Item type cannot be changed after creation.</div>
|
|
{{else}}
|
|
<select class="form-select" name="item_type_id" id="assetFormItemType" required>
|
|
{{range .ItemTypes}}<option value="{{.ID}}" {{if eq .ID $.SelectedIT}}selected{{end}}>{{.Name}}</option>{{end}}
|
|
</select>
|
|
{{end}}
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label">Folder</label>
|
|
{{$selectedFolder := deref .FolderID}}
|
|
{{if .Asset}}{{$selectedFolder = deref .Asset.FolderID}}{{end}}
|
|
<select class="form-select" name="folder_id">
|
|
<option value="">Inventory (top level)</option>
|
|
{{range .FolderOptions}}
|
|
<option value="{{.ID}}" {{if eq $selectedFolder .ID}}selected{{end}}>
|
|
{{range seq .Depth}} {{end}}{{.Path}}
|
|
</option>
|
|
{{end}}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<label class="form-label">Status <span class="text-danger">*</span></label>
|
|
<select class="form-select" name="status_id" required>
|
|
{{range .Statuses}}<option value="{{.ID}}" {{if $.Asset}}{{if eq .ID $.Asset.StatusID}}selected{{end}}{{end}}>{{.Name}}</option>{{end}}
|
|
</select>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label">Assigned User</label>
|
|
{{$selectedUser := 0}}
|
|
{{if .Asset}}{{$selectedUser = deref .Asset.AssignedUserID}}{{end}}
|
|
<select class="form-select" name="assigned_user_id">
|
|
<option value="">Unassigned</option>
|
|
{{range .Users}}
|
|
<option value="{{.ID}}" {{if eq $selectedUser .ID}}selected{{end}}>{{.Username}}{{if eq .Role "contact"}} (Contact){{end}}</option>
|
|
{{end}}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-12">
|
|
<label class="form-label">Notes</label>
|
|
<textarea class="form-control" name="notes" rows="3">{{if .Asset}}{{.Asset.Notes}}{{end}}</textarea>
|
|
</div>
|
|
|
|
<div class="col-12" id="asset-fields-container">
|
|
{{template "asset_fields_only" (dict "IsUnique" .SelectedITUnique "Quantity" .Quantity "Fields" .Fields)}}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="alert alert-danger mt-3 d-none" id="assetFormError"></div>
|
|
</form>
|
|
{{end}}
|