Add custom fields + warranty plugin, rework settings into two-pane shell

Feature work from the 2026-07 session:

Settings IA
- Replace the flat 27-card settings hub with a persistent two-pane shell
  (SettingsLayout.vue): grouped, searchable left rail + content pane.
- Nest all settings/* routes under the shell via router post-processing;
  shared nav catalog in settingsNav.js. Group by asset class (PCs, Printers,
  Equipment, Network) so per-type settings stop scattering.

Custom fields (core)
- customfields + customfieldvalues tables (migration 7d14), CRUD API at
  /api/customfields, per-asset value get/save.
- Settings management page + reusable CustomFieldsSection (detail) and
  CustomFieldsInputs (form) wired into all four asset types.

Warranty (new plugin)
- plugins/warranty: warranties + warrantyassets (migration 7d15), derived
  coverage status, provider abstraction (manual now; Dell/Lenovo/HP stubs).
- API CRUD + per-asset panel + report buckets; WarrantyPanel on all four
  detail pages; Warranties management page; Warranty report + Reports card.
- Seed warranty.* permissions.

Printer drivers
- printerdrivers table (migration 7d13) linked to printer models; drivers now
  surface on the matching printer's detail page.

Other
- PCDetail rebalanced (Network + Status + Warranty + custom fields on the right).
- Rename PCs list "Features" column to "Remote Access"; fix badge hover underline.
- Drop equipment islocationonly field.
- Centralize asset-type label/route maps into utils/assetTypes.js.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
cproudlock
2026-07-09 15:37:21 -04:00
parent 419f26107d
commit 78a0ee8d83
154 changed files with 9479 additions and 1098 deletions

View File

@@ -15,6 +15,7 @@ from .user import User, Role, Permission
from .application import Application, AppVersion, AppOwner, SupportTeam
from .setting import Setting
from .auditlog import AuditLog
from .customfield import CustomField, CustomFieldValue
__all__ = [
# Base
@@ -55,4 +56,7 @@ __all__ = [
'Setting',
# Audit
'AuditLog',
# Custom fields
'CustomField',
'CustomFieldValue',
]

View File

@@ -32,6 +32,7 @@ class AssetType(BaseModel):
)
description = db.Column(db.Text)
icon = db.Column(db.String(50), comment='Icon name for UI')
color = db.Column(db.String(20), comment='CSS color for UI/map markers')
def __repr__(self):
return f"<AssetType {self.assettype}>"
@@ -215,8 +216,10 @@ class Asset(BaseModel, SoftDeleteMixin, AuditMixin):
# Add related object names for convenience
if self.assettype:
result['assettypename'] = self.assettype.assettype
result['assettypecolor'] = getattr(self.assettype, 'color', None)
if self.status:
result['statusname'] = self.status.status
result['statuscolor'] = self.status.color
if self.location:
result['locationname'] = self.location.locationname
if self.businessunit:

View File

@@ -0,0 +1,91 @@
"""Custom fields: site-defined extra attributes per asset type.
A CustomField is a definition scoped to one asset type (equipment, computer,
printer, network_device). A CustomFieldValue holds one asset's value for one
field. This is the generic form of the built-in identifier columns - sites add
their own attributes without a schema change.
"""
from shopdb.extensions import db
# Allowed datatypes for a custom field. Values are always stored as text and
# cast on render/input by the frontend.
CUSTOM_FIELD_DATATYPES = ('text', 'number', 'date', 'boolean', 'select')
class CustomField(db.Model):
__tablename__ = 'customfields'
fieldid = db.Column(db.Integer, primary_key=True)
assettypeid = db.Column(
db.Integer,
db.ForeignKey('assettypes.assettypeid'),
nullable=False,
comment='Which asset category this field applies to'
)
# Machine-name key, unique per asset type. Used for stable references.
fieldkey = db.Column(db.String(50), nullable=False)
label = db.Column(db.String(150), nullable=False)
datatype = db.Column(db.String(20), nullable=False, server_default='text')
# JSON array of options, only meaningful when datatype='select'
options = db.Column(db.Text)
showondetail = db.Column(db.Boolean, nullable=False, server_default='1')
showonform = db.Column(db.Boolean, nullable=False, server_default='1')
sortorder = db.Column(db.Integer, nullable=False, server_default='0')
isactive = db.Column(db.Boolean, nullable=False, server_default='1')
__table_args__ = (
db.UniqueConstraint('assettypeid', 'fieldkey', name='uq_customfield_type_key'),
)
def to_dict(self):
import json
parsed_options = []
if self.options:
try:
parsed_options = json.loads(self.options)
except (ValueError, TypeError):
parsed_options = []
return {
'fieldid': self.fieldid,
'assettypeid': self.assettypeid,
'fieldkey': self.fieldkey,
'label': self.label,
'datatype': self.datatype,
'options': parsed_options,
'showondetail': bool(self.showondetail),
'showonform': bool(self.showonform),
'sortorder': self.sortorder,
'isactive': bool(self.isactive),
}
class CustomFieldValue(db.Model):
__tablename__ = 'customfieldvalues'
valueid = db.Column(db.Integer, primary_key=True)
fieldid = db.Column(
db.Integer,
db.ForeignKey('customfields.fieldid', ondelete='CASCADE'),
nullable=False
)
assetid = db.Column(
db.Integer,
db.ForeignKey('assets.assetid', ondelete='CASCADE'),
nullable=False
)
value = db.Column(db.Text)
field = db.relationship('CustomField')
__table_args__ = (
db.UniqueConstraint('fieldid', 'assetid', name='uq_customfieldvalue_field_asset'),
)
def to_dict(self):
return {
'valueid': self.valueid,
'fieldid': self.fieldid,
'assetid': self.assetid,
'value': self.value,
}

View File

@@ -15,6 +15,7 @@ class LocationType(BaseModel):
locationtypeid = db.Column(db.Integer, primary_key=True)
locationtype = db.Column(db.String(50), unique=True, nullable=False)
description = db.Column(db.Text)
color = db.Column(db.String(20), comment='CSS color for UI')
def __repr__(self):
return f"<LocationType {self.locationtype}>"

View File

@@ -19,6 +19,7 @@ class RelationshipType(BaseModel):
relationshiptypeid = db.Column(db.Integer, primary_key=True)
relationshiptype = db.Column(db.String(50), unique=True, nullable=False)
description = db.Column(db.Text)
color = db.Column(db.String(20), comment='CSS color for relationship badges')
# Sibling propagation (ADR-001): when a relationship of this type is
# created/deleted, the framework finds all assets related to the source

View File

@@ -75,6 +75,16 @@ class Permission(db.Model):
('notifications.create', 'Create notifications', 'notifications'),
('notifications.edit', 'Edit notifications', 'notifications'),
('notifications.delete', 'Delete notifications', 'notifications'),
# USB devices
('usb.view', 'View USB devices', 'usb'),
('usb.create', 'Create USB devices', 'usb'),
('usb.edit', 'Edit USB devices', 'usb'),
('usb.delete', 'Delete USB devices', 'usb'),
# Warranty
('warranty.view', 'View warranties', 'warranty'),
('warranty.create', 'Create warranties', 'warranty'),
('warranty.edit', 'Edit warranties', 'warranty'),
('warranty.delete', 'Delete warranties', 'warranty'),
# Reports
('reports.view', 'View reports', 'reports'),
('reports.export', 'Export reports', 'reports'),