Files
vibetree/web/templates/partials/asset_fields.html
T
Owen fb85c9edbb 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.
2026-08-17 16:28:14 -05:00

48 lines
2.7 KiB
HTML

{{define "asset_fields_only"}}
{{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">&minus;</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 .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>
{{if eq .Def.FieldType "long_text"}}
<textarea class="form-control" id="field-{{.Def.ID}}" name="field_{{.Def.ID}}" rows="3" {{if .Def.Required}}required{{end}}>{{.Value}}</textarea>
{{else if eq .Def.FieldType "boolean"}}
<select class="form-select" id="field-{{.Def.ID}}" name="field_{{.Def.ID}}">
<option value="false" {{if ne .Value "true"}}selected{{end}}>No</option>
<option value="true" {{if eq .Value "true"}}selected{{end}}>Yes</option>
</select>
{{else if eq .Def.FieldType "dropdown"}}
<select class="form-select" id="field-{{.Def.ID}}" name="field_{{.Def.ID}}" {{if .Def.Required}}required{{end}}>
<option value="">&mdash;</option>
{{range .Def.Options}}<option value="{{.}}" {{if eq . $fv.Value}}selected{{end}}>{{.}}</option>{{end}}
</select>
{{else if eq .Def.FieldType "date"}}
<input type="date" class="form-control" id="field-{{.Def.ID}}" name="field_{{.Def.ID}}" value="{{.Value}}" {{if .Def.Required}}required{{end}}>
{{else if eq .Def.FieldType "number"}}
<input type="number" step="any" class="form-control" id="field-{{.Def.ID}}" name="field_{{.Def.ID}}" value="{{.Value}}" {{if .Def.Required}}required{{end}}>
{{else if eq .Def.FieldType "url"}}
<input type="url" class="form-control" id="field-{{.Def.ID}}" name="field_{{.Def.ID}}" value="{{.Value}}" {{if .Def.Required}}required{{end}}>
{{else if eq .Def.FieldType "ip_address"}}
<input type="text" pattern="^[0-9a-fA-F:\.]+$" class="form-control" id="field-{{.Def.ID}}" name="field_{{.Def.ID}}" value="{{.Value}}" placeholder="192.168.1.1" {{if .Def.Required}}required{{end}}>
{{else}}
<input type="text" class="form-control" id="field-{{.Def.ID}}" name="field_{{.Def.ID}}" value="{{.Value}}" {{if .Def.Required}}required{{end}}>
{{end}}
</div>
{{end}}
{{end}}
{{end}}