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:
+12
-1
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"inventree/internal/models"
|
||||
@@ -19,6 +20,7 @@ const (
|
||||
colStatus = "status"
|
||||
colAssignedUser = "assigned user"
|
||||
colNotes = "notes"
|
||||
colQuantity = "quantity"
|
||||
cfColPrefix = "cf_"
|
||||
)
|
||||
|
||||
@@ -201,6 +203,13 @@ func (s *Store) Import(ctx context.Context, r io.Reader, opts ImportOptions,
|
||||
}
|
||||
}
|
||||
|
||||
quantity := 1
|
||||
if qtyStr := get(row, colQuantity); qtyStr != "" {
|
||||
if n, err := strconv.Atoi(qtyStr); err == nil {
|
||||
quantity = n
|
||||
}
|
||||
}
|
||||
|
||||
asset := &models.Asset{
|
||||
AssetTag: get(row, colAssetID),
|
||||
Name: name,
|
||||
@@ -209,6 +218,7 @@ func (s *Store) Import(ctx context.Context, r io.Reader, opts ImportOptions,
|
||||
StatusID: statusID,
|
||||
AssignedUserID: assignedUserID,
|
||||
Notes: get(row, colNotes),
|
||||
Quantity: quantity,
|
||||
}
|
||||
|
||||
if asset.AssetTag != "" {
|
||||
@@ -282,7 +292,7 @@ func (s *Store) Export(ctx context.Context, w io.Writer, f ListFilter) error {
|
||||
}
|
||||
|
||||
cw := csv.NewWriter(w)
|
||||
header := []string{"Asset ID", "Name", "Item Type", "Folder", "Status", "Assigned User", "Notes", "Created At", "Updated At"}
|
||||
header := []string{"Asset ID", "Name", "Item Type", "Folder", "Status", "Assigned User", "Notes", "Quantity", "Created At", "Updated At"}
|
||||
for _, k := range fieldDefs {
|
||||
header = append(header, cfColPrefix+k)
|
||||
}
|
||||
@@ -304,6 +314,7 @@ func (s *Store) Export(ctx context.Context, w io.Writer, f ListFilter) error {
|
||||
}
|
||||
row := []string{
|
||||
a.AssetTag, a.Name, a.ItemTypeName, folderPathString(a.FolderPath), a.StatusName, a.AssignedUsername, a.Notes,
|
||||
strconv.Itoa(a.Quantity),
|
||||
a.CreatedAt.Format("2006-01-02 15:04:05"), a.UpdatedAt.Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
values := map[string]string{}
|
||||
|
||||
Reference in New Issue
Block a user