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

@@ -13,20 +13,90 @@ from shopdb.utils.responses import (
)
from shopdb.utils.pagination import get_pagination_params, paginate_query
from shopdb.utils.authz import require_permission, require_role
locations_bp = Blueprint('locations', __name__)
def _loc_type_dict(t):
return {
'locationtypeid': t.locationtypeid,
'locationtype': t.locationtype,
'description': t.description,
'color': t.color,
'isactive': t.isactive,
}
@locations_bp.route('/types', methods=['GET'])
@jwt_required(optional=True)
def list_location_types():
"""List all location types."""
types = LocationType.query.filter_by(isactive=True).order_by(
LocationType.locationtype).all()
return success_response([{
'locationtypeid': t.locationtypeid,
'locationtype': t.locationtype,
'description': t.description,
} for t in types])
"""List location types. ?active=false includes inactive ones."""
query = LocationType.query
if request.args.get('active', 'true').lower() != 'false':
query = query.filter_by(isactive=True)
types = query.order_by(LocationType.locationtype).all()
return success_response([_loc_type_dict(t) for t in types])
@locations_bp.route('/types', methods=['POST'])
@jwt_required()
@require_role('admin')
def create_location_type():
data = request.get_json() or {}
if not data.get('locationtype'):
return error_response(ErrorCodes.VALIDATION_ERROR, 'locationtype is required')
existing = LocationType.query.filter_by(locationtype=data['locationtype']).first()
if existing:
if not existing.isactive:
existing.isactive = True
for key in ('description', 'color'):
if data.get(key) is not None:
setattr(existing, key, data[key])
db.session.commit()
return success_response(_loc_type_dict(existing), message='Reactivated existing type')
return error_response(ErrorCodes.CONFLICT,
f"Location type '{data['locationtype']}' already exists", http_code=409)
t = LocationType(locationtype=data['locationtype'],
description=data.get('description'), color=data.get('color'))
db.session.add(t)
db.session.commit()
return success_response(_loc_type_dict(t), message='Location type created', http_code=201)
@locations_bp.route('/types/<int:type_id>', methods=['PUT'])
@jwt_required()
@require_role('admin')
def update_location_type(type_id):
t = LocationType.query.get(type_id)
if not t:
return error_response(ErrorCodes.NOT_FOUND, 'Location type not found', http_code=404)
data = request.get_json() or {}
if 'locationtype' in data and data['locationtype'] != t.locationtype:
if LocationType.query.filter_by(locationtype=data['locationtype']).first():
return error_response(ErrorCodes.CONFLICT,
f"Location type '{data['locationtype']}' already exists", http_code=409)
for key in ('locationtype', 'description', 'color', 'isactive'):
if key in data:
setattr(t, key, data[key])
db.session.commit()
return success_response(_loc_type_dict(t), message='Location type updated')
@locations_bp.route('/types/<int:type_id>', methods=['DELETE'])
@jwt_required()
@require_role('admin')
def delete_location_type(type_id):
t = LocationType.query.get(type_id)
if not t:
return error_response(ErrorCodes.NOT_FOUND, 'Location type not found', http_code=404)
inuse = Location.query.filter_by(locationtypeid=type_id).count()
if inuse:
return error_response(ErrorCodes.CONFLICT,
f"Cannot delete: {inuse} location(s) still use this type", http_code=409)
db.session.delete(t)
db.session.commit()
return success_response(message='Location type deleted')
@locations_bp.route('', methods=['GET'])
@@ -74,6 +144,7 @@ def get_location(location_id: int):
@locations_bp.route('', methods=['POST'])
@jwt_required()
@require_role('admin')
def create_location():
"""Create a new location."""
data = request.get_json()
@@ -109,6 +180,7 @@ def create_location():
@locations_bp.route('/<int:location_id>', methods=['PUT'])
@jwt_required()
@require_role('admin')
def update_location(location_id: int):
"""Update a location."""
loc = Location.query.get(location_id)
@@ -144,6 +216,7 @@ def update_location(location_id: int):
@locations_bp.route('/<int:location_id>', methods=['DELETE'])
@jwt_required()
@require_role('admin')
def delete_location(location_id: int):
"""Delete (deactivate) a location."""
loc = Location.query.get(location_id)