Skip to content

feat(maintenance): Complete maintenance module — Maintenances, Work Orders, Equipment & Parts#215

Open
roncodes wants to merge 7 commits intomainfrom
feat/complete-maintenance-module
Open

feat(maintenance): Complete maintenance module — Maintenances, Work Orders, Equipment & Parts#215
roncodes wants to merge 7 commits intomainfrom
feat/complete-maintenance-module

Conversation

@roncodes
Copy link
Copy Markdown
Member

Overview

This PR completes the existing but stub-only maintenance section in FleetOps. All four maintenance resources — Maintenances, Work Orders, Equipment, and Parts — now have fully functional CRUD flows, following the same conventions used throughout the rest of the extension (e.g. the connectivity section with Layout::Resource::Panel, TabNavigation, and panel-header components).

The sidebar maintenance panel is also uncommented and activated.


Frontend Changes

Sidebar (fleet-ops-sidebar.js)

  • Uncommented and activated the maintenance sidebar panel
  • Added Maintenances as the first item (wrench icon) pointing to maintenance.maintenances
  • All four resources now appear under the Maintenance panel with correct permission guards

Routes (routes.js + new route files)

  • Added maintenances route block (index / new / edit / details / details.index)
  • Fixed work-orders, equipment, and parts details + edit routes: added model() hook and permission guard (were empty stubs)

Controllers

  • Newmaintenances/index: full columns (summary, type, status, priority, scheduled_at, total_cost, created_at), action buttons, bulk delete, query params
  • Newmaintenances/index/new: save task with event tracking and form reset
  • Newmaintenances/index/edit: save task, unsaved-changes guard, cancel/view actions
  • Newmaintenances/index/details: tabs (Overview + registered extension tabs via menuService.getMenuItems), edit/delete action buttons
  • Completedwork-orders/index, equipment/index, parts/index: full column definitions, action buttons, bulk actions
  • Completed — all new/edit/details controllers for work-orders, equipment, parts

Components

  • New work-order/panel-header — displays code/subject, status badge, priority, assigned driver
  • New maintenance/panel-header — displays summary, status badge, type, scheduled_at
  • New equipment/panel-header — displays photo, name, status badge, type, serial number
  • New part/panel-header — displays photo, name, status badge, type, part number

Templates

  • Fixed all new.hbs files: corrected @resource={{this.place}} bug → correct resource binding
  • Fixed all details.hbs files: added @headerComponent (panel-header), TabNavigation with {{outlet}}
  • Fixed all edit.hbs files: added @headerTitle with resource name
  • Fixed all details/index.hbs files: wired to correct ::Details component
  • New — full template tree for maintenances (parent, index, new, edit, details, details/index)

Extension Registries (extension.js)

Added 12 new Universe registries enabling downstream extensions to inject custom tabs and form sections:

fleet-ops:component:maintenance:form
fleet-ops:component:maintenance:form:details
fleet-ops:component:maintenance:details
fleet-ops:component:work-order:form
fleet-ops:component:work-order:form:details
fleet-ops:component:work-order:details
fleet-ops:component:equipment:form
fleet-ops:component:equipment:form:details
fleet-ops:component:equipment:details
fleet-ops:component:part:form
fleet-ops:component:part:form:details
fleet-ops:component:part:details

Services

  • maintenance-actions.js: fixed maintenance.namemaintenance.summary in panel/modal titles

Backend Changes

Auth Schema (server/src/Auth/Schemas/FleetOps.php)

  • Added 4 new resources: maintenance, work-order, equipment, part (each with standard CRUD + export/import actions)
  • Added MaintenanceManager policy: full CRUD on all four resources
  • Updated OperationsAdmin policy: includes all four maintenance resources
  • Added Maintenance Technician role: uses the MaintenanceManager policy

Console Command (server/src/Console/Commands/ProcessMaintenanceTriggers.php)

New artisan command: fleetops:process-maintenance-triggers

  • Time-based triggers: finds scheduled maintenances whose scheduled_at has arrived and transitions them to in_progress
  • Threshold triggers: compares vehicle odometer and engine_hours against next_service_odometer / next_service_engine_hours on scheduled maintenance records
  • Dispatches maintenance.triggered event for downstream extension hooks (no hard-coded foreign keys to external modules)
  • Supports --sandbox and --dry-run flags

Service Provider (server/src/Providers/FleetOpsServiceProvider.php)

  • Registered ProcessMaintenanceTriggers in $commands array
  • Scheduled fleetops:process-maintenance-triggers to run daily

Extensibility Design

All integration points are designed to be consumed by downstream extensions without modifying FleetOps core:

  • The meta JSON column on all maintenance models accepts arbitrary key-value data
  • The Universe registry namespaces allow external extensions to inject tabs, form sections, and context menus
  • The maintenance.triggered event can be listened to by any extension's EventServiceProvider

Testing Checklist

  • Maintenance sidebar panel appears and all four items are visible
  • Maintenances index loads with correct columns and filters
  • Create / Edit / Delete a Maintenance record
  • Create / Edit / Delete a Work Order
  • Create / Edit / Delete an Equipment record
  • Create / Edit / Delete a Part
  • Details panel shows panel-header and Overview tab
  • Permission guards block access for users without the correct policy
  • php artisan fleetops:process-maintenance-triggers --dry-run reports triggers without modifying records
  • php artisan fleetops:process-maintenance-triggers transitions due maintenances to in_progress

Fleetbase Dev and others added 7 commits March 30, 2026 04:11
…k orders, equipment & parts

Completes the existing but incomplete maintenance section in FleetOps,
enabling full CRUD for all four maintenance resources: Maintenances,
Work Orders, Equipment, and Parts.

Frontend:
- Uncomment and activate the maintenance sidebar panel (fleet-ops-sidebar.js)
- Add Maintenances as first sidebar item with wrench icon
- Add maintenances route block to routes.js
- New route files for maintenances (index, new, edit, details, details/index)
- Fix all work-orders/equipment/parts details+edit routes: add model hook and permission guard
- New controllers for maintenances (index, new, edit, details, details/index)
- Complete controllers for work-orders, equipment, parts (full columns, save tasks, tabs, action buttons)
- New panel-header components for all four resources (HBS + JS)
- Fix all new.hbs templates: correct @resource binding (was this.place bug)
- Fix all details.hbs: add @headerComponent, TabNavigation with outlet
- Fix all edit.hbs: add @headerTitle with resource name
- New maintenances templates (maintenances.hbs, index, new, edit, details, details/index)
- Add 12 new Universe registries in extension.js for maintenance/work-order/equipment/part
- Fix maintenance-actions.js: use maintenance.summary instead of maintenance.name

Backend:
- Add maintenance, work-order, equipment, part resources to FleetOps auth schema
- Add MaintenanceManager policy with full CRUD on all four resources
- Update OperationsAdmin policy to include all four maintenance resources
- Add Maintenance Technician role
- New ProcessMaintenanceTriggers artisan command (time-based + odometer/engine-hour triggers)
- Register command and daily schedule in FleetOpsServiceProvider
… sections

- work-order/form: split into Identification, Assignment (polymorphic
  target + assignee with type-driven ModelSelect), Scheduling, and
  Instructions panels. Added targetTypeOptions, assigneeTypeOptions,
  onTargetTypeChange, onAssigneeTypeChange, assignTarget, assignAssignee
  actions. Removed hardcoded 'user' model assumption.

- maintenance/form: split into Identification, Asset & Work Order
  (polymorphic maintainable + performed-by), Scheduling & Readings
  (odometer, engine_hours, scheduled_at, started_at, completed_at),
  Costs (MoneyInput for labor_cost, parts_cost, tax, total_cost), and
  Notes panels. Added full polymorphic type handlers.

- equipment/form: split into Photo, Identification (name, code,
  serial_number, manufacturer, model, type, status), Assignment
  (polymorphic equipable), and Purchase & Warranty panels. Fixed photo
  upload to use fetch.uploadFile.perform pattern. Added
  onEquipableTypeChange / assignEquipable actions.

- part/form: split into Photo, Identification (name, sku, serial_number,
  barcode, manufacturer, model, type, status, description), Inventory
  (quantity_on_hand, unit_cost, msrp with MoneyInput), Compatibility
  (polymorphic asset), and Vendor & Warranty panels. Fixed photo upload
  to use fetch.uploadFile.perform pattern. Added onAssetTypeChange /
  assignAsset actions.

All forms: added MetadataEditor panel, RegistryYield hooks, and
CustomField::Yield. All option arrays cross-checked against PHP model
fillable arrays and fleetops-data Ember models.
… and part forms, fix all ContentPanel wrapperClass

- equipment/form.hbs: remove standalone Photo ContentPanel; photo block
  (Image + UploadButton, matching vehicle/form structure) is now the
  first child of the Identification ContentPanel before the field grid.
- part/form.hbs: same restructure as equipment.
- All four forms (work-order, maintenance, equipment, part): every
  ContentPanel now carries @wrapperclass="bordered-top", including the
  first panel. Previously work-order and maintenance first panels had no
  wrapperClass at all.
- equipment/form.js: equipableTypeOptions converted to { value, label }
  objects; added @Tracked selectedEquipableType; onEquipableTypeChange
  now receives option object and reads option.value.
- part/form.js: assetTypeOptions converted to { value, label } objects;
  added @Tracked selectedAssetType; onAssetTypeChange updated similarly.
- Both HBS files updated to bind @selected to the tracked option object
  and render {{option.label}} in the PowerSelect block.
…d-by type selectors

- maintainableTypeOptions: plain strings -> { value, label } objects
  (Vehicle, Equipment)
- performedByTypeOptions: plain strings -> { value, label } objects
  (Vendor, Driver, User) — added Vendor as a valid performer type
- Added selectedMaintainableType and selectedPerformedByType tracked
  properties so the PowerSelect trigger shows the human-readable label
- Both onChange actions now receive the full option object and write
  option.value to the model attribute
- Updated TYPE_TO_MODEL to include fleet-ops:vendor -> vendor
- HBS PowerSelect @selected bindings updated to use the tracked option
  objects; block params renamed from |type| to |option| with {{option.label}}
…ems panel

- Add migration to add public_id column to maintenances, work_orders,
  equipment, and parts tables (fixes SQLSTATE[42S22] unknown column error)
- Replace flat cost ContentPanel with new Maintenance::CostPanel component
  - Invoice-style line items table with description, qty, unit cost, line total
  - Inline add/edit/remove rows with optimistic UI updates
  - Labour and Tax inputs remain as direct MoneyInput fields
  - Computed totals summary (Labour + Parts + Tax = Total)
  - All mutations hit dedicated API endpoints and reflect server-recomputed totals
- Add addLineItem / updateLineItem / removeLineItem endpoints to MaintenanceController
- Register POST/PUT/DELETE line-item sub-routes in routes.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant