@fleetbase/fleetops-engine 0.6.65 → 0.6.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE.md +11 -6
- package/addon/components/ai/create-order-preview.hbs +10 -5
- package/addon/components/asset/pill.hbs +24 -0
- package/addon/components/asset/summary.hbs +1 -0
- package/addon/components/asset-connection/pill.hbs +24 -0
- package/addon/components/asset-connection/summary.hbs +1 -0
- package/addon/components/attachable/pill.hbs +24 -0
- package/addon/components/attachable/summary.hbs +1 -0
- package/addon/components/cell/asset-connection-identity.hbs +1 -0
- package/addon/components/cell/asset-identity.hbs +1 -0
- package/addon/components/cell/attachable-identity.hbs +1 -0
- package/addon/components/cell/contact-identity.hbs +1 -0
- package/addon/components/cell/customer-identity.hbs +1 -0
- package/addon/components/cell/device-event-identity.hbs +1 -0
- package/addon/components/cell/device-identity.hbs +1 -24
- package/addon/components/cell/driver-identity.hbs +1 -33
- package/addon/components/cell/entity-identity.hbs +1 -0
- package/addon/components/cell/equipment-identity.hbs +1 -5
- package/addon/components/cell/facilitator-identity.hbs +1 -0
- package/addon/components/cell/fleet-driver-identity.hbs +1 -0
- package/addon/components/cell/fleet-identity.hbs +1 -0
- package/addon/components/cell/fuel-provider-connection-identity.hbs +1 -0
- package/addon/components/cell/fuel-provider-transaction-identity.hbs +1 -0
- package/addon/components/cell/fuel-report-identity.hbs +1 -0
- package/addon/components/cell/inspection-form-identity.hbs +1 -0
- package/addon/components/cell/inspection-item-result-identity.hbs +1 -0
- package/addon/components/cell/inspection-submission-identity.hbs +1 -0
- package/addon/components/cell/integrated-vendor-identity.hbs +1 -0
- package/addon/components/cell/issue-identity.hbs +1 -0
- package/addon/components/cell/maintenance-identity.hbs +1 -0
- package/addon/components/cell/maintenance-schedule-identity.hbs +1 -0
- package/addon/components/cell/maintenance-subject-identity.hbs +1 -0
- package/addon/components/cell/manifest-identity.hbs +1 -0
- package/addon/components/cell/manifest-stop-identity.hbs +1 -0
- package/addon/components/cell/order-config-identity.hbs +1 -0
- package/addon/components/cell/order-identity.hbs +1 -0
- package/addon/components/cell/part-identity.hbs +1 -5
- package/addon/components/cell/payload-identity.hbs +1 -0
- package/addon/components/cell/place-identity.hbs +1 -0
- package/addon/components/cell/position-identity.hbs +1 -0
- package/addon/components/cell/purchase-rate-identity.hbs +1 -0
- package/addon/components/cell/recurring-order-schedule-identity.hbs +1 -0
- package/addon/components/cell/resource-list.hbs +10 -0
- package/addon/components/cell/resource-list.js +28 -0
- package/addon/components/cell/route-identity.hbs +1 -0
- package/addon/components/cell/sensor-identity.hbs +1 -0
- package/addon/components/cell/service-area-identity.hbs +1 -0
- package/addon/components/cell/service-quote-identity.hbs +1 -0
- package/addon/components/cell/service-quote-item-identity.hbs +1 -0
- package/addon/components/cell/service-rate-fee-identity.hbs +1 -0
- package/addon/components/cell/service-rate-identity.hbs +1 -0
- package/addon/components/cell/service-rate-parcel-fee-identity.hbs +1 -0
- package/addon/components/cell/telematic-identity.hbs +1 -0
- package/addon/components/cell/tracking-number-identity.hbs +1 -0
- package/addon/components/cell/tracking-status-identity.hbs +1 -0
- package/addon/components/cell/trailer-identity.hbs +1 -0
- package/addon/components/cell/vehicle-device-identity.hbs +1 -0
- package/addon/components/cell/vehicle-identity.hbs +1 -33
- package/addon/components/cell/vendor-identity.hbs +1 -0
- package/addon/components/cell/warranty-identity.hbs +1 -0
- package/addon/components/cell/waypoint-identity.hbs +1 -0
- package/addon/components/cell/work-order-identity.hbs +1 -0
- package/addon/components/cell/zone-identity.hbs +1 -0
- package/addon/components/contact/form.hbs +2 -4
- package/addon/components/contact/pill.hbs +24 -0
- package/addon/components/contact/summary.hbs +1 -0
- package/addon/components/customer/create-order-form.hbs +8 -4
- package/addon/components/customer/form.hbs +2 -4
- package/addon/components/customer/order-form.hbs +10 -8
- package/addon/components/customer/pill.hbs +24 -0
- package/addon/components/customer/summary.hbs +1 -0
- package/addon/components/device/details.hbs +3 -1
- package/addon/components/device/form.hbs +4 -13
- package/addon/components/device/panel-header.hbs +3 -2
- package/addon/components/device/panel-header.js +1 -5
- package/addon/components/device/panel-tabs/vehicle.hbs +2 -2
- package/addon/components/device/pill.hbs +24 -16
- package/addon/components/device/summary.hbs +1 -0
- package/addon/components/device/telemetry.hbs +17 -0
- package/addon/components/device/telemetry.js +117 -0
- package/addon/components/device-event/details.hbs +6 -24
- package/addon/components/device-event/pill.hbs +24 -0
- package/addon/components/device-event/summary.hbs +1 -0
- package/addon/components/driver/details.hbs +9 -1
- package/addon/components/driver/form.hbs +6 -18
- package/addon/components/driver/panel-header.hbs +3 -4
- package/addon/components/driver/panel-header.js +8 -1
- package/addon/components/driver/pill.hbs +16 -8
- package/addon/components/driver/summary.hbs +1 -0
- package/addon/components/entity/pill.hbs +24 -0
- package/addon/components/entity/summary.hbs +1 -0
- package/addon/components/equipment/details.hbs +6 -2
- package/addon/components/equipment/form.hbs +10 -4
- package/addon/components/equipment/pill.hbs +24 -20
- package/addon/components/equipment/summary.hbs +1 -0
- package/addon/components/facilitator/pill.hbs +24 -0
- package/addon/components/facilitator/summary.hbs +1 -0
- package/addon/components/fleet/details.hbs +6 -2
- package/addon/components/fleet/driver-listing.hbs +3 -12
- package/addon/components/fleet/form.hbs +8 -4
- package/addon/components/fleet/pill.hbs +24 -0
- package/addon/components/fleet/summary.hbs +1 -0
- package/addon/components/fleet/vehicle-listing.hbs +3 -12
- package/addon/components/fleet-driver/pill.hbs +24 -0
- package/addon/components/fleet-driver/summary.hbs +1 -0
- package/addon/components/fleet-driver-listing.hbs +2 -1
- package/addon/components/fleet-panel/details.hbs +6 -2
- package/addon/components/fleet-panel/driver-listing.hbs +2 -1
- package/addon/components/fleet-panel/vehicle-listing.hbs +2 -1
- package/addon/components/fleet-vehicle-listing.hbs +2 -1
- package/addon/components/fuel-integration/form.hbs +125 -25
- package/addon/components/fuel-integration/form.js +74 -19
- package/addon/components/fuel-integration/hub.hbs +68 -65
- package/addon/components/fuel-integration/hub.js +15 -19
- package/addon/components/fuel-provider-connection/pill.hbs +24 -0
- package/addon/components/fuel-provider-connection/summary.hbs +1 -0
- package/addon/components/fuel-provider-transaction/pill.hbs +24 -0
- package/addon/components/fuel-provider-transaction/summary.hbs +1 -0
- package/addon/components/fuel-report/details.hbs +9 -3
- package/addon/components/fuel-report/form.hbs +6 -3
- package/addon/components/fuel-report/pill.hbs +24 -0
- package/addon/components/fuel-report/summary.hbs +1 -0
- package/addon/components/fuel-transaction-status.hbs +1 -0
- package/addon/components/fuel-transaction-status.js +8 -0
- package/addon/components/geofence-map.hbs +19 -0
- package/addon/components/geofence-map.js +83 -0
- package/addon/components/inspection-field/form.hbs +103 -0
- package/addon/components/inspection-field/form.js +211 -0
- package/addon/components/inspection-field/input.hbs +270 -0
- package/addon/components/inspection-field/input.js +472 -0
- package/addon/components/inspection-field/value.hbs +90 -0
- package/addon/components/inspection-field/value.js +158 -0
- package/addon/components/inspection-flyout.hbs +34 -0
- package/addon/components/inspection-flyout.js +66 -0
- package/addon/components/inspection-form/builder.hbs +88 -0
- package/addon/components/inspection-form/builder.js +211 -0
- package/addon/components/inspection-form/details/submissions.hbs +48 -0
- package/addon/components/inspection-form/details/submissions.js +42 -0
- package/addon/components/inspection-form/details.hbs +97 -0
- package/addon/components/inspection-form/details.js +57 -0
- package/addon/components/inspection-form/form.hbs +93 -0
- package/addon/components/inspection-form/form.js +79 -0
- package/addon/components/inspection-form/pill.hbs +24 -0
- package/addon/components/inspection-form/summary.hbs +1 -0
- package/addon/components/inspection-item-result/pill.hbs +24 -0
- package/addon/components/inspection-item-result/summary.hbs +1 -0
- package/addon/components/inspection-link/list.hbs +94 -0
- package/addon/components/inspection-link/list.js +129 -0
- package/addon/components/inspection-sheet/group.hbs +45 -0
- package/addon/components/inspection-sheet/group.js +75 -0
- package/addon/components/inspection-sheet.hbs +77 -0
- package/addon/components/inspection-sheet.js +152 -0
- package/addon/components/inspection-submission/details.hbs +149 -0
- package/addon/components/inspection-submission/details.js +130 -0
- package/addon/components/inspection-submission/form.hbs +114 -0
- package/addon/components/inspection-submission/form.js +129 -0
- package/addon/components/inspection-submission/photos.hbs +20 -0
- package/addon/components/inspection-submission/photos.js +57 -0
- package/addon/components/inspection-submission/pill.hbs +24 -0
- package/addon/components/inspection-submission/summary.hbs +1 -0
- package/addon/components/integrated-vendor/pill.hbs +24 -0
- package/addon/components/integrated-vendor/summary.hbs +1 -0
- package/addon/components/issue/details.hbs +12 -0
- package/addon/components/issue/details.js +36 -0
- package/addon/components/issue/form.hbs +10 -5
- package/addon/components/issue/pill.hbs +24 -0
- package/addon/components/issue/summary.hbs +1 -0
- package/addon/components/layout/fleet-ops-sidebar.js +14 -3
- package/addon/components/maintenance/details.hbs +9 -3
- package/addon/components/maintenance/form.hbs +22 -3
- package/addon/components/maintenance/form.js +4 -4
- package/addon/components/maintenance/panel-header.hbs +14 -12
- package/addon/components/maintenance/pill.hbs +24 -0
- package/addon/components/maintenance/summary.hbs +1 -0
- package/addon/components/maintenance-schedule/details.hbs +7 -3
- package/addon/components/maintenance-schedule/form.hbs +20 -2
- package/addon/components/maintenance-schedule/form.js +6 -6
- package/addon/components/maintenance-schedule/pill.hbs +24 -0
- package/addon/components/maintenance-schedule/summary.hbs +1 -0
- package/addon/components/maintenance-schedule/work-orders.hbs +39 -0
- package/addon/components/maintenance-schedule/work-orders.js +37 -0
- package/addon/components/maintenance-subject/pill.hbs +24 -0
- package/addon/components/maintenance-subject/summary.hbs +1 -0
- package/addon/components/manifest/pill.hbs +24 -0
- package/addon/components/manifest/summary.hbs +1 -0
- package/addon/components/manifest-stop/pill.hbs +24 -0
- package/addon/components/manifest-stop/summary.hbs +1 -0
- package/addon/components/map/drawer/device-event-listing.hbs +4 -14
- package/addon/components/map/drawer/device-event-listing.js +3 -1
- package/addon/components/map/drawer/driver-listing.js +6 -2
- package/addon/components/map/drawer/position-listing.hbs +2 -16
- package/addon/components/map/drawer/vehicle-listing.js +1 -2
- package/addon/components/modals/add-driver-shift.hbs +2 -1
- package/addon/components/modals/assign-driver.hbs +2 -16
- package/addon/components/modals/attach-device.hbs +2 -1
- package/addon/components/modals/attach-equipment.hbs +2 -4
- package/addon/components/modals/attach-telematic-device.hbs +8 -1
- package/addon/components/modals/attach-trailer.hbs +2 -1
- package/addon/components/modals/bulk-assign-driver.hbs +2 -9
- package/addon/components/modals/bulk-assign-orders.hbs +2 -9
- package/addon/components/modals/driver-assign-order.hbs +2 -6
- package/addon/components/modals/driver-assign-vehicle.hbs +4 -12
- package/addon/components/modals/driver-assign-vehicle.js +30 -0
- package/addon/components/modals/driver-assign-vendor.hbs +2 -1
- package/addon/components/modals/driver-form.hbs +4 -2
- package/addon/components/modals/fleet-assign-driver.hbs +2 -1
- package/addon/components/modals/fleet-assign-vehicle.hbs +2 -1
- package/addon/components/modals/fleet-form.hbs +4 -2
- package/addon/components/modals/fuel-connection-diagnostics.hbs +35 -0
- package/addon/components/modals/fuel-connection-diagnostics.js +87 -0
- package/addon/components/modals/fuel-report-form.hbs +4 -2
- package/addon/components/modals/fuel-transaction-action.hbs +48 -0
- package/addon/components/modals/fuel-transaction-action.js +98 -0
- package/addon/components/modals/group-form.hbs +2 -1
- package/addon/components/modals/inspection-follow-up.hbs +31 -0
- package/addon/components/modals/inspection-follow-up.js +39 -0
- package/addon/components/modals/inspection-link.hbs +100 -0
- package/addon/components/modals/inspection-link.js +83 -0
- package/addon/components/modals/issue-assign.hbs +2 -1
- package/addon/components/modals/issue-from.hbs +8 -4
- package/addon/components/modals/map-layer-form.hbs +2 -1
- package/addon/components/modals/order-assign-driver.hbs +2 -16
- package/addon/components/modals/order-form.hbs +8 -46
- package/addon/components/modals/order-route-form.hbs +8 -4
- package/addon/components/modals/place-assign-vendor.hbs +3 -2
- package/addon/components/modals/place-details.hbs +1 -1
- package/addon/components/modals/point-map.hbs +1 -1
- package/addon/components/modals/radar-notice.hbs +24 -0
- package/addon/components/modals/radar-notice.js +8 -0
- package/addon/components/modals/radar-save-view.hbs +7 -0
- package/addon/components/modals/radar-select-resource.hbs +35 -0
- package/addon/components/modals/radar-send-pin.hbs +20 -0
- package/addon/components/modals/radar-send-pin.js +8 -0
- package/addon/components/modals/select-trailer.hbs +2 -4
- package/addon/components/modals/vehicle-form.hbs +2 -1
- package/addon/components/modals/vendor-form.hbs +2 -3
- package/addon/components/order/details/activity.js +9 -0
- package/addon/components/order/details/detail.hbs +2 -32
- package/addon/components/order/form/details.hbs +10 -48
- package/addon/components/order/form/route.hbs +10 -12
- package/addon/components/order/form/service-rate.hbs +2 -3
- package/addon/components/order/pill.hbs +24 -34
- package/addon/components/order/route-editor.hbs +8 -4
- package/addon/components/order/schedule-card.hbs +2 -1
- package/addon/components/order/summary.hbs +1 -0
- package/addon/components/order-config/pill.hbs +24 -0
- package/addon/components/order-config/summary.hbs +1 -0
- package/addon/components/part/details.hbs +15 -3
- package/addon/components/part/details.js +37 -1
- package/addon/components/part/form.hbs +12 -5
- package/addon/components/part/pill.hbs +24 -0
- package/addon/components/part/summary.hbs +1 -0
- package/addon/components/payload/pill.hbs +24 -0
- package/addon/components/payload/summary.hbs +1 -0
- package/addon/components/place/details.hbs +1 -1
- package/addon/components/place/pill.hbs +24 -0
- package/addon/components/place/summary.hbs +1 -0
- package/addon/components/position/pill.hbs +24 -0
- package/addon/components/position/summary.hbs +1 -0
- package/addon/components/positions-replay.hbs +2 -4
- package/addon/components/public-inspection.hbs +174 -0
- package/addon/components/public-inspection.js +279 -0
- package/addon/components/purchase-rate/pill.hbs +24 -0
- package/addon/components/purchase-rate/summary.hbs +1 -0
- package/addon/components/radar/agenda/entry.hbs +17 -0
- package/addon/components/radar/agenda/entry.js +26 -0
- package/addon/components/radar/agenda/lane.hbs +33 -0
- package/addon/components/radar/agenda/lane.js +80 -0
- package/addon/components/radar/agenda.hbs +69 -0
- package/addon/components/radar/agenda.js +29 -0
- package/addon/components/radar/briefing.hbs +108 -0
- package/addon/components/radar/briefing.js +43 -0
- package/addon/components/radar/bulk-bar.hbs +41 -0
- package/addon/components/radar/bulk-bar.js +32 -0
- package/addon/components/radar/decision-card.hbs +28 -0
- package/addon/components/radar/decision-card.js +7 -0
- package/addon/components/radar/empty-state.hbs +30 -0
- package/addon/components/radar/empty-state.js +27 -0
- package/addon/components/radar/filter-pills.hbs +22 -0
- package/addon/components/radar/filter-pills.js +3 -0
- package/addon/components/radar/handover-card.hbs +62 -0
- package/addon/components/radar/handover-card.js +14 -0
- package/addon/components/radar/header.hbs +28 -0
- package/addon/components/radar/header.js +12 -0
- package/addon/components/radar/item-drawer.hbs +92 -0
- package/addon/components/radar/item-drawer.js +37 -0
- package/addon/components/radar/item-list.hbs +20 -0
- package/addon/components/radar/item-list.js +3 -0
- package/addon/components/radar/item-row.hbs +90 -0
- package/addon/components/radar/item-row.js +43 -0
- package/addon/components/radar/keyboard-hints.hbs +8 -0
- package/addon/components/radar/keyboard-hints.js +3 -0
- package/addon/components/radar/subject.hbs +14 -0
- package/addon/components/radar/subject.js +26 -0
- package/addon/components/radar/view-bar.hbs +27 -0
- package/addon/components/radar/view-bar.js +16 -0
- package/addon/components/recurring-order-schedule/pill.hbs +24 -0
- package/addon/components/recurring-order-schedule/summary.hbs +1 -0
- package/addon/components/resource-activity.hbs +1 -0
- package/addon/components/resource-activity.js +4 -0
- package/addon/components/route/pill.hbs +24 -0
- package/addon/components/route/summary.hbs +1 -0
- package/addon/components/select-option/asset-connection.hbs +12 -0
- package/addon/components/select-option/asset.hbs +12 -0
- package/addon/components/select-option/attachable.hbs +12 -0
- package/addon/components/select-option/contact.hbs +12 -0
- package/addon/components/select-option/customer.hbs +12 -0
- package/addon/components/select-option/device-event.hbs +12 -0
- package/addon/components/select-option/device.hbs +12 -0
- package/addon/components/select-option/driver.hbs +12 -0
- package/addon/components/select-option/entity.hbs +12 -0
- package/addon/components/select-option/equipment.hbs +12 -0
- package/addon/components/select-option/facilitator.hbs +12 -0
- package/addon/components/select-option/fleet-driver.hbs +12 -0
- package/addon/components/select-option/fleet.hbs +12 -0
- package/addon/components/select-option/fuel-provider-connection.hbs +12 -0
- package/addon/components/select-option/fuel-provider-transaction.hbs +12 -0
- package/addon/components/select-option/fuel-report.hbs +12 -0
- package/addon/components/select-option/inspection-form.hbs +12 -0
- package/addon/components/select-option/inspection-item-result.hbs +12 -0
- package/addon/components/select-option/inspection-submission.hbs +12 -0
- package/addon/components/select-option/integrated-vendor.hbs +12 -0
- package/addon/components/select-option/issue.hbs +12 -0
- package/addon/components/select-option/maintenance-schedule.hbs +12 -0
- package/addon/components/select-option/maintenance-subject.hbs +12 -0
- package/addon/components/select-option/maintenance.hbs +12 -0
- package/addon/components/select-option/manifest-stop.hbs +12 -0
- package/addon/components/select-option/manifest.hbs +12 -0
- package/addon/components/select-option/order-config.hbs +12 -0
- package/addon/components/select-option/order.hbs +12 -0
- package/addon/components/select-option/part.hbs +12 -0
- package/addon/components/select-option/payload.hbs +12 -0
- package/addon/components/select-option/place.hbs +12 -0
- package/addon/components/select-option/position.hbs +12 -0
- package/addon/components/select-option/purchase-rate.hbs +12 -0
- package/addon/components/select-option/recurring-order-schedule.hbs +12 -0
- package/addon/components/select-option/route.hbs +12 -0
- package/addon/components/select-option/sensor.hbs +12 -0
- package/addon/components/select-option/service-area.hbs +12 -0
- package/addon/components/select-option/service-quote-item.hbs +12 -0
- package/addon/components/select-option/service-quote.hbs +12 -0
- package/addon/components/select-option/service-rate-fee.hbs +12 -0
- package/addon/components/select-option/service-rate-parcel-fee.hbs +12 -0
- package/addon/components/select-option/service-rate.hbs +12 -0
- package/addon/components/select-option/telematic.hbs +12 -0
- package/addon/components/select-option/trackable.hbs +8 -0
- package/addon/components/select-option/tracking-number.hbs +12 -0
- package/addon/components/select-option/tracking-status.hbs +12 -0
- package/addon/components/select-option/trailer.hbs +12 -0
- package/addon/components/select-option/vehicle-device.hbs +12 -0
- package/addon/components/select-option/vehicle.hbs +12 -0
- package/addon/components/select-option/vendor.hbs +12 -0
- package/addon/components/select-option/warranty.hbs +12 -0
- package/addon/components/select-option/waypoint.hbs +12 -0
- package/addon/components/select-option/work-order.hbs +12 -0
- package/addon/components/select-option/zone.hbs +12 -0
- package/addon/components/sensor/details.hbs +6 -2
- package/addon/components/sensor/form.hbs +6 -17
- package/addon/components/sensor/panel-header.hbs +1 -1
- package/addon/components/sensor/pill.hbs +24 -0
- package/addon/components/sensor/summary.hbs +1 -0
- package/addon/components/service-area/details.hbs +1 -20
- package/addon/components/service-area/pill.hbs +24 -0
- package/addon/components/service-area/summary.hbs +1 -0
- package/addon/components/service-quote/pill.hbs +24 -0
- package/addon/components/service-quote/summary.hbs +1 -0
- package/addon/components/service-quote-item/pill.hbs +24 -0
- package/addon/components/service-quote-item/summary.hbs +1 -0
- package/addon/components/service-rate/details.hbs +12 -6
- package/addon/components/service-rate/form.hbs +10 -8
- package/addon/components/service-rate/pill.hbs +24 -0
- package/addon/components/service-rate/summary.hbs +1 -0
- package/addon/components/service-rate-fee/pill.hbs +24 -0
- package/addon/components/service-rate-fee/summary.hbs +1 -0
- package/addon/components/service-rate-parcel-fee/pill.hbs +24 -0
- package/addon/components/service-rate-parcel-fee/summary.hbs +1 -0
- package/addon/components/table/cell/fleet-ops-option.hbs +20 -0
- package/addon/components/telematic/details.hbs +4 -1
- package/addon/components/telematic/details.js +1 -0
- package/addon/components/telematic/form.hbs +6 -1
- package/addon/components/telematic/form.js +1 -0
- package/addon/components/telematic/pill.hbs +24 -0
- package/addon/components/telematic/settings.hbs +6 -1
- package/addon/components/telematic/settings.js +1 -0
- package/addon/components/telematic/summary.hbs +1 -0
- package/addon/components/telematic/telemetry-status.hbs +43 -0
- package/addon/components/telematic/telemetry-status.js +95 -0
- package/addon/components/tracking-number/pill.hbs +24 -0
- package/addon/components/tracking-number/summary.hbs +1 -0
- package/addon/components/tracking-status/pill.hbs +24 -0
- package/addon/components/tracking-status/summary.hbs +1 -0
- package/addon/components/trailer/card.hbs +2 -5
- package/addon/components/trailer/details.hbs +11 -5
- package/addon/components/trailer/details.js +4 -0
- package/addon/components/trailer/form.hbs +6 -3
- package/addon/components/trailer/pill.hbs +24 -21
- package/addon/components/trailer/summary.hbs +1 -0
- package/addon/components/vehicle/card.hbs +4 -8
- package/addon/components/vehicle/details/inspections.hbs +49 -0
- package/addon/components/vehicle/details/inspections.js +44 -0
- package/addon/components/vehicle/details/maintenance-history.hbs +1 -1
- package/addon/components/vehicle/details/schedules.hbs +2 -2
- package/addon/components/vehicle/details/work-orders.hbs +1 -1
- package/addon/components/vehicle/details.hbs +18 -1
- package/addon/components/vehicle/form.hbs +2 -1
- package/addon/components/vehicle/panel-header.hbs +3 -4
- package/addon/components/vehicle/panel-header.js +8 -1
- package/addon/components/vehicle/pill.hbs +15 -24
- package/addon/components/vehicle/summary.hbs +1 -0
- package/addon/components/vehicle-device/pill.hbs +24 -0
- package/addon/components/vehicle-device/summary.hbs +1 -0
- package/addon/components/vendor/form.hbs +2 -4
- package/addon/components/vendor/personnel-manager.hbs +2 -9
- package/addon/components/vendor/personnel-tab.hbs +1 -0
- package/addon/components/vendor/personnel-tab.js +4 -0
- package/addon/components/vendor/pill.hbs +24 -0
- package/addon/components/vendor/summary.hbs +1 -0
- package/addon/components/warranty/details.hbs +3 -1
- package/addon/components/warranty/form.hbs +2 -1
- package/addon/components/warranty/pill.hbs +24 -0
- package/addon/components/warranty/summary.hbs +1 -0
- package/addon/components/waypoint/pill.hbs +24 -0
- package/addon/components/waypoint/summary.hbs +1 -0
- package/addon/components/widget/radar.hbs +28 -0
- package/addon/components/widget/radar.js +44 -0
- package/addon/components/work-order/details.hbs +20 -4
- package/addon/components/work-order/details.js +64 -1
- package/addon/components/work-order/form.hbs +20 -2
- package/addon/components/work-order/form.js +10 -10
- package/addon/components/work-order/panel-header.hbs +15 -13
- package/addon/components/work-order/pill.hbs +24 -0
- package/addon/components/work-order/summary.hbs +1 -0
- package/addon/components/zone/details.hbs +2 -21
- package/addon/components/zone/pill.hbs +24 -0
- package/addon/components/zone/summary.hbs +1 -0
- package/addon/controllers/connectivity/devices/index/details/sensors.js +4 -0
- package/addon/controllers/connectivity/devices/index/details.js +1 -18
- package/addon/controllers/connectivity/events/index.js +1 -4
- package/addon/controllers/connectivity/fuel-providers/details/index.js +6 -0
- package/addon/controllers/connectivity/fuel-providers/details/matching.js +13 -0
- package/addon/controllers/connectivity/fuel-providers/details/sync.js +21 -10
- package/addon/controllers/connectivity/fuel-providers/details/transactions.js +5 -16
- package/addon/controllers/connectivity/fuel-providers/details.js +76 -13
- package/addon/controllers/connectivity/fuel-providers/index.js +22 -17
- package/addon/controllers/connectivity/sensors/index.js +1 -3
- package/addon/controllers/connectivity/telematics/details/events.js +8 -0
- package/addon/controllers/connectivity/telematics/details/sensors.js +3 -2
- package/addon/controllers/connectivity/telematics/index.js +3 -1
- package/addon/controllers/maintenance/inspection-forms/index/details.js +29 -0
- package/addon/controllers/maintenance/inspection-forms/index/edit.js +39 -0
- package/addon/controllers/maintenance/inspection-forms/index/new.js +48 -0
- package/addon/controllers/maintenance/inspection-forms/index.js +90 -0
- package/addon/controllers/maintenance/inspection-submissions/index/details.js +53 -0
- package/addon/controllers/maintenance/inspection-submissions/index/edit.js +39 -0
- package/addon/controllers/maintenance/inspection-submissions/index/new.js +48 -0
- package/addon/controllers/maintenance/inspection-submissions/index.js +142 -0
- package/addon/controllers/maintenance/maintenances/index.js +6 -2
- package/addon/controllers/maintenance/schedules/index/details.js +4 -86
- package/addon/controllers/maintenance/schedules/index.js +15 -0
- package/addon/controllers/maintenance/work-orders/index.js +19 -1
- package/addon/controllers/management/contacts/customers.js +6 -4
- package/addon/controllers/management/contacts/index.js +6 -3
- package/addon/controllers/management/drivers/index/details.js +1 -66
- package/addon/controllers/management/drivers/index.js +9 -34
- package/addon/controllers/management/fleets/index/details.js +2 -15
- package/addon/controllers/management/fleets/index.js +12 -20
- package/addon/controllers/management/fuel-reports/index.js +9 -59
- package/addon/controllers/management/fuel-transactions/index/details.js +51 -48
- package/addon/controllers/management/fuel-transactions/index.js +32 -32
- package/addon/controllers/management/index.js +1367 -49
- package/addon/controllers/management/issues/index/details.js +1 -33
- package/addon/controllers/management/issues/index.js +10 -59
- package/addon/controllers/management/trailers/index/details.js +4 -78
- package/addon/controllers/management/trailers/index.js +20 -22
- package/addon/controllers/management/vehicles/index/details.js +9 -77
- package/addon/controllers/management/vehicles/index.js +50 -72
- package/addon/controllers/management/vendors/index.js +6 -3
- package/addon/controllers/operations/orders/index.js +38 -11
- package/addon/controllers/operations/service-rates/index.js +10 -2
- package/addon/controllers/settings/payments/index.js +11 -2
- package/addon/extension.js +36 -0
- package/addon/helpers/initials.js +6 -0
- package/addon/helpers/leaflet-tile-url.js +6 -1
- package/addon/instance-initializers/register-fleetops-resource-descriptors.js +29 -0
- package/addon/modifiers/inspection-flyout.js +237 -0
- package/addon/modifiers/radar-keyboard.js +78 -0
- package/addon/modifiers/sync-value.js +26 -0
- package/addon/modifiers/when-changed.js +25 -0
- package/addon/routes/connectivity/fuel-providers/details/settings.js +5 -2
- package/addon/routes/connectivity/fuel-providers/details/sync.js +6 -13
- package/addon/routes/connectivity/fuel-providers/details/transactions.js +8 -7
- package/addon/routes/connectivity/fuel-providers/details.js +15 -2
- package/addon/routes/connectivity/fuel-providers/edit.js +2 -1
- package/addon/routes/connectivity/fuel-providers/index.js +5 -0
- package/addon/routes/maintenance/inspection-forms/index/details/index.js +3 -0
- package/addon/routes/maintenance/inspection-forms/index/details/submissions.js +3 -0
- package/addon/routes/maintenance/inspection-forms/index/details.js +18 -0
- package/addon/routes/maintenance/inspection-forms/index/edit.js +18 -0
- package/addon/routes/maintenance/inspection-forms/index/new.js +3 -0
- package/addon/routes/maintenance/inspection-forms/index.js +22 -0
- package/addon/routes/maintenance/inspection-forms.js +3 -0
- package/addon/routes/maintenance/inspection-submissions/index/details/audit.js +8 -0
- package/addon/routes/maintenance/inspection-submissions/index/details/index.js +3 -0
- package/addon/routes/maintenance/inspection-submissions/index/details/photos.js +8 -0
- package/addon/routes/maintenance/inspection-submissions/index/details.js +18 -0
- package/addon/routes/maintenance/inspection-submissions/index/edit.js +18 -0
- package/addon/routes/maintenance/inspection-submissions/index/new.js +3 -0
- package/addon/routes/maintenance/inspection-submissions/index.js +25 -0
- package/addon/routes/maintenance/inspection-submissions.js +3 -0
- package/addon/routes/management/fuel-transactions/index/details.js +12 -2
- package/addon/routes/management/fuel-transactions/index.js +6 -0
- package/addon/routes/management/index.js +17 -1
- package/addon/routes/management/vehicles/index/details/inspections.js +3 -0
- package/addon/routes/management/vehicles/index.js +2 -2
- package/addon/routes.js +24 -0
- package/addon/services/contact-actions.js +22 -4
- package/addon/services/customer-actions.js +7 -4
- package/addon/services/device-actions.js +28 -0
- package/addon/services/driver-actions.js +79 -16
- package/addon/services/equipment-actions.js +15 -6
- package/addon/services/fleet-actions.js +20 -4
- package/addon/services/fuel-report-actions.js +7 -7
- package/addon/services/inspection-form-actions.js +236 -0
- package/addon/services/inspection-submission-actions.js +273 -0
- package/addon/services/issue-actions.js +58 -7
- package/addon/services/maintenance-actions.js +22 -3
- package/addon/services/maintenance-schedule-actions.js +70 -5
- package/addon/services/movement-tracker.js +52 -1
- package/addon/services/part-actions.js +13 -7
- package/addon/services/place-actions.js +8 -7
- package/addon/services/service-area-actions.js +27 -4
- package/addon/services/trailer-actions.js +60 -7
- package/addon/services/vehicle-actions.js +58 -3
- package/addon/services/vendor-actions.js +8 -7
- package/addon/services/work-order-actions.js +14 -5
- package/addon/services/zone-actions.js +27 -4
- package/addon/styles/fleetops-engine.css +3621 -75
- package/addon/templates/connectivity/devices/index/details/vehicle.hbs +2 -2
- package/addon/templates/connectivity/events/details.hbs +2 -2
- package/addon/templates/connectivity/fuel-providers/details/index.hbs +65 -35
- package/addon/templates/connectivity/fuel-providers/details/matching.hbs +2 -2
- package/addon/templates/connectivity/fuel-providers/details/sync.hbs +54 -43
- package/addon/templates/connectivity/fuel-providers/details/transactions.hbs +10 -5
- package/addon/templates/connectivity/fuel-providers/details.hbs +38 -13
- package/addon/templates/connectivity/fuel-providers/edit.hbs +1 -0
- package/addon/templates/connectivity/fuel-providers/index.hbs +2 -1
- package/addon/templates/connectivity/fuel-providers/new.hbs +1 -1
- package/addon/templates/connectivity/telematics/details/attachments.hbs +2 -1
- package/addon/templates/maintenance/inspection-forms/index/details/index.hbs +1 -0
- package/addon/templates/maintenance/inspection-forms/index/details/submissions.hbs +2 -0
- package/addon/templates/maintenance/inspection-forms/index/details.hbs +14 -0
- package/addon/templates/maintenance/inspection-forms/index/edit.hbs +11 -0
- package/addon/templates/maintenance/inspection-forms/index/new.hbs +11 -0
- package/addon/templates/maintenance/inspection-forms/index.hbs +28 -0
- package/addon/templates/maintenance/inspection-forms.hbs +1 -0
- package/addon/templates/maintenance/inspection-submissions/index/details/audit.hbs +1 -0
- package/addon/templates/maintenance/inspection-submissions/index/details/index.hbs +1 -0
- package/addon/templates/maintenance/inspection-submissions/index/details/photos.hbs +1 -0
- package/addon/templates/maintenance/inspection-submissions/index/details.hbs +14 -0
- package/addon/templates/maintenance/inspection-submissions/index/edit.hbs +11 -0
- package/addon/templates/maintenance/inspection-submissions/index/new.hbs +11 -0
- package/addon/templates/maintenance/inspection-submissions/index.hbs +28 -0
- package/addon/templates/maintenance/inspection-submissions.hbs +1 -0
- package/addon/templates/management/fuel-transactions/index/details.hbs +64 -62
- package/addon/templates/management/fuel-transactions/index.hbs +9 -31
- package/addon/templates/management/index.hbs +110 -102
- package/addon/templates/management/vehicles/index/details/inspections.hbs +2 -0
- package/addon/templates/operations/orders/index.hbs +2 -4
- package/addon/utils/context-panel.js +34 -0
- package/addon/utils/device-table-columns.js +18 -27
- package/addon/utils/fleet-ops-options.js +40 -0
- package/addon/utils/fuel-integration-format.js +43 -0
- package/addon/utils/fuel-transaction.js +115 -0
- package/addon/utils/identity-cell-resource.js +56 -0
- package/addon/utils/inspection-answers.js +283 -0
- package/addon/utils/inspection-field-types.js +74 -0
- package/addon/utils/inspection-form-structure.js +161 -0
- package/addon/utils/radar.js +212 -0
- package/addon/utils/relation-value.js +37 -0
- package/addon/utils/resource-descriptors/assets.js +246 -0
- package/addon/utils/resource-descriptors/connectivity.js +146 -0
- package/addon/utils/resource-descriptors/fuel.js +75 -0
- package/addon/utils/resource-descriptors/helpers.js +191 -0
- package/addon/utils/resource-descriptors/index.js +35 -0
- package/addon/utils/resource-descriptors/maintenance.js +175 -0
- package/addon/utils/resource-descriptors/operations.js +215 -0
- package/addon/utils/resource-descriptors/people.js +173 -0
- package/addon/utils/resource-descriptors/polymorphic.js +123 -0
- package/addon/utils/resource-descriptors/sub-records.js +297 -0
- package/addon/utils/telemetry-timestamp.js +6 -0
- package/app/components/asset/pill.js +1 -0
- package/app/components/asset/summary.js +1 -0
- package/app/components/asset-connection/pill.js +1 -0
- package/app/components/asset-connection/summary.js +1 -0
- package/app/components/attachable/pill.js +1 -0
- package/app/components/attachable/summary.js +1 -0
- package/app/components/cell/asset-connection-identity.js +1 -0
- package/app/components/cell/{attached-vehicle.js → asset-identity.js} +1 -1
- package/app/components/cell/attachable-identity.js +1 -0
- package/app/components/cell/{telematic-device.js → contact-identity.js} +1 -1
- package/app/components/cell/customer-identity.js +1 -0
- package/app/components/cell/device-event-identity.js +1 -0
- package/app/components/cell/entity-identity.js +1 -0
- package/app/components/cell/facilitator-identity.js +1 -0
- package/app/components/cell/fleet-driver-identity.js +1 -0
- package/app/components/cell/fleet-identity.js +1 -0
- package/app/components/cell/fuel-provider-connection-identity.js +1 -0
- package/app/components/cell/fuel-provider-transaction-identity.js +1 -0
- package/app/components/cell/fuel-report-identity.js +1 -0
- package/app/components/cell/inspection-form-identity.js +1 -0
- package/app/components/cell/inspection-item-result-identity.js +1 -0
- package/app/components/cell/inspection-submission-identity.js +1 -0
- package/app/components/cell/integrated-vendor-identity.js +1 -0
- package/app/components/cell/issue-identity.js +1 -0
- package/app/components/cell/maintenance-identity.js +1 -0
- package/app/components/cell/maintenance-schedule-identity.js +1 -0
- package/app/components/cell/maintenance-subject-identity.js +1 -0
- package/app/components/cell/manifest-identity.js +1 -0
- package/app/components/cell/manifest-stop-identity.js +1 -0
- package/app/components/cell/order-config-identity.js +1 -0
- package/app/components/cell/order-identity.js +1 -0
- package/app/components/cell/payload-identity.js +1 -0
- package/app/components/cell/place-identity.js +1 -0
- package/app/components/cell/position-identity.js +1 -0
- package/app/components/cell/purchase-rate-identity.js +1 -0
- package/app/components/cell/recurring-order-schedule-identity.js +1 -0
- package/app/components/cell/resource-list.js +1 -0
- package/app/components/cell/route-identity.js +1 -0
- package/app/components/cell/sensor-identity.js +1 -0
- package/app/components/cell/service-area-identity.js +1 -0
- package/app/components/cell/service-quote-identity.js +1 -0
- package/app/components/cell/service-quote-item-identity.js +1 -0
- package/app/components/cell/service-rate-fee-identity.js +1 -0
- package/app/components/cell/service-rate-identity.js +1 -0
- package/app/components/cell/service-rate-parcel-fee-identity.js +1 -0
- package/app/components/cell/{telematic-provider.js → telematic-identity.js} +1 -1
- package/app/components/cell/tracking-number-identity.js +1 -0
- package/app/components/cell/tracking-status-identity.js +1 -0
- package/app/components/cell/trailer-identity.js +1 -0
- package/app/components/cell/vehicle-device-identity.js +1 -0
- package/app/components/cell/vendor-identity.js +1 -0
- package/app/components/cell/warranty-identity.js +1 -0
- package/app/components/cell/waypoint-identity.js +1 -0
- package/app/components/cell/work-order-identity.js +1 -0
- package/app/components/cell/zone-identity.js +1 -0
- package/app/components/{cell/driver-name.js → contact/pill.js} +1 -1
- package/app/components/{cell/vehicle-name.js → contact/summary.js} +1 -1
- package/app/components/customer/pill.js +1 -0
- package/app/components/customer/summary.js +1 -0
- package/app/components/device/summary.js +1 -0
- package/app/components/device/telemetry.js +1 -0
- package/app/components/device-event/pill.js +1 -0
- package/app/components/device-event/summary.js +1 -0
- package/app/components/driver/summary.js +1 -0
- package/app/components/entity/pill.js +1 -0
- package/app/components/entity/summary.js +1 -0
- package/app/components/equipment/card.js +1 -0
- package/app/components/equipment/panel-header.js +1 -0
- package/app/components/equipment/summary.js +1 -0
- package/app/components/{filter/multi-model.js → facilitator/pill.js} +1 -1
- package/app/components/facilitator/summary.js +1 -0
- package/app/components/fleet/pill.js +1 -0
- package/app/components/fleet/summary.js +1 -0
- package/app/components/fleet-driver/pill.js +1 -0
- package/app/components/fleet-driver/summary.js +1 -0
- package/app/components/fuel-provider-connection/pill.js +1 -0
- package/app/components/fuel-provider-connection/summary.js +1 -0
- package/app/components/fuel-provider-transaction/pill.js +1 -0
- package/app/components/fuel-provider-transaction/summary.js +1 -0
- package/app/components/fuel-report/pill.js +1 -0
- package/app/components/fuel-report/summary.js +1 -0
- package/app/components/fuel-transaction-status.js +1 -0
- package/app/components/geofence-map.js +1 -0
- package/app/components/inspection-field/form.js +1 -0
- package/app/components/inspection-field/input.js +1 -0
- package/app/components/inspection-field/value.js +1 -0
- package/app/components/inspection-flyout.js +1 -0
- package/app/components/inspection-form/builder.js +1 -0
- package/app/components/inspection-form/details/submissions.js +1 -0
- package/app/components/inspection-form/details.js +1 -0
- package/app/components/inspection-form/form.js +1 -0
- package/app/components/inspection-form/pill.js +1 -0
- package/app/components/inspection-form/summary.js +1 -0
- package/app/components/inspection-item-result/pill.js +1 -0
- package/app/components/inspection-item-result/summary.js +1 -0
- package/app/components/inspection-link/list.js +1 -0
- package/app/components/inspection-sheet/group.js +1 -0
- package/app/components/inspection-sheet.js +1 -0
- package/app/components/inspection-submission/details.js +1 -0
- package/app/components/inspection-submission/form.js +1 -0
- package/app/components/inspection-submission/photos.js +1 -0
- package/app/components/inspection-submission/pill.js +1 -0
- package/app/components/inspection-submission/summary.js +1 -0
- package/app/components/integrated-vendor/pill.js +1 -0
- package/app/components/integrated-vendor/summary.js +1 -0
- package/app/components/issue/pill.js +1 -0
- package/app/components/issue/summary.js +1 -0
- package/app/components/issue/timeline.js +1 -0
- package/app/components/layout/fleet-ops-sidebar/operations-monitor.js +1 -0
- package/app/components/maintenance/pill.js +1 -0
- package/app/components/maintenance/summary.js +1 -0
- package/app/components/maintenance-schedule/pill.js +1 -0
- package/app/components/maintenance-schedule/summary.js +1 -0
- package/app/components/maintenance-schedule/work-orders.js +1 -0
- package/app/components/maintenance-subject/pill.js +1 -0
- package/app/components/maintenance-subject/summary.js +1 -0
- package/app/components/manifest/pill.js +1 -0
- package/app/components/manifest/summary.js +1 -0
- package/app/components/manifest-stop/pill.js +1 -0
- package/app/components/manifest-stop/summary.js +1 -0
- package/app/components/modals/fuel-connection-diagnostics.js +1 -0
- package/app/components/modals/fuel-transaction-action.js +1 -0
- package/app/components/modals/inspection-follow-up.js +1 -0
- package/app/components/modals/inspection-link.js +1 -0
- package/app/components/modals/radar-notice.js +1 -0
- package/app/components/modals/radar-save-view.js +1 -0
- package/app/components/modals/radar-select-resource.js +1 -0
- package/app/components/modals/radar-send-pin.js +1 -0
- package/app/components/order/summary.js +1 -0
- package/app/components/order-config/pill.js +1 -0
- package/app/components/order-config/summary.js +1 -0
- package/app/components/part/card.js +1 -0
- package/app/components/part/panel-header.js +1 -0
- package/app/components/part/pill.js +1 -0
- package/app/components/part/summary.js +1 -0
- package/app/components/payload/pill.js +1 -0
- package/app/components/payload/summary.js +1 -0
- package/app/components/place/pill.js +1 -0
- package/app/components/place/summary.js +1 -0
- package/app/components/position/pill.js +1 -0
- package/app/components/position/summary.js +1 -0
- package/app/components/public-inspection.js +1 -0
- package/app/components/purchase-rate/pill.js +1 -0
- package/app/components/purchase-rate/summary.js +1 -0
- package/app/components/radar/agenda/entry.js +1 -0
- package/app/components/radar/agenda/lane.js +1 -0
- package/app/components/radar/agenda.js +1 -0
- package/app/components/radar/briefing.js +1 -0
- package/app/components/radar/bulk-bar.js +1 -0
- package/app/components/radar/decision-card.js +1 -0
- package/app/components/radar/empty-state.js +1 -0
- package/app/components/radar/filter-pills.js +1 -0
- package/app/components/radar/handover-card.js +1 -0
- package/app/components/radar/header.js +1 -0
- package/app/components/radar/item-drawer.js +1 -0
- package/app/components/radar/item-list.js +1 -0
- package/app/components/radar/item-row.js +1 -0
- package/app/components/radar/keyboard-hints.js +1 -0
- package/app/components/radar/subject.js +1 -0
- package/app/components/radar/view-bar.js +1 -0
- package/app/components/recurring-order-schedule/pill.js +1 -0
- package/app/components/recurring-order-schedule/summary.js +1 -0
- package/app/components/resource-activity.js +1 -0
- package/app/components/route/pill.js +1 -0
- package/app/components/route/summary.js +1 -0
- package/app/components/select-option/asset-connection.js +1 -0
- package/app/components/select-option/asset.js +1 -0
- package/app/components/select-option/attachable.js +1 -0
- package/app/components/select-option/contact.js +1 -0
- package/app/components/select-option/customer.js +1 -0
- package/app/components/select-option/device-event.js +1 -0
- package/app/components/select-option/device.js +1 -0
- package/app/components/select-option/driver.js +1 -0
- package/app/components/select-option/entity.js +1 -0
- package/app/components/select-option/equipment.js +1 -0
- package/app/components/select-option/facilitator.js +1 -0
- package/app/components/select-option/fleet-driver.js +1 -0
- package/app/components/select-option/fleet.js +1 -0
- package/app/components/select-option/fuel-provider-connection.js +1 -0
- package/app/components/select-option/fuel-provider-transaction.js +1 -0
- package/app/components/select-option/fuel-report.js +1 -0
- package/app/components/select-option/inspection-form.js +1 -0
- package/app/components/select-option/inspection-item-result.js +1 -0
- package/app/components/select-option/inspection-submission.js +1 -0
- package/app/components/select-option/integrated-vendor.js +1 -0
- package/app/components/select-option/issue.js +1 -0
- package/app/components/select-option/maintenance-schedule.js +1 -0
- package/app/components/select-option/maintenance-subject.js +1 -0
- package/app/components/select-option/maintenance.js +1 -0
- package/app/components/select-option/manifest-stop.js +1 -0
- package/app/components/select-option/manifest.js +1 -0
- package/app/components/select-option/order-config.js +1 -0
- package/app/components/select-option/order.js +1 -0
- package/app/components/select-option/part.js +1 -0
- package/app/components/select-option/payload.js +1 -0
- package/app/components/select-option/place.js +1 -0
- package/app/components/select-option/position.js +1 -0
- package/app/components/select-option/purchase-rate.js +1 -0
- package/app/components/select-option/recurring-order-schedule.js +1 -0
- package/app/components/select-option/route.js +1 -0
- package/app/components/select-option/sensor.js +1 -0
- package/app/components/select-option/service-area.js +1 -0
- package/app/components/select-option/service-quote-item.js +1 -0
- package/app/components/select-option/service-quote.js +1 -0
- package/app/components/select-option/service-rate-fee.js +1 -0
- package/app/components/select-option/service-rate-parcel-fee.js +1 -0
- package/app/components/select-option/service-rate.js +1 -0
- package/app/components/select-option/telematic.js +1 -0
- package/app/components/select-option/trackable.js +1 -0
- package/app/components/select-option/tracking-number.js +1 -0
- package/app/components/select-option/tracking-status.js +1 -0
- package/app/components/select-option/trailer.js +1 -0
- package/app/components/select-option/vehicle-device.js +1 -0
- package/app/components/select-option/vehicle.js +1 -0
- package/app/components/select-option/vendor.js +1 -0
- package/app/components/select-option/warranty.js +1 -0
- package/app/components/select-option/waypoint.js +1 -0
- package/app/components/select-option/work-order.js +1 -0
- package/app/components/select-option/zone.js +1 -0
- package/app/components/sensor/pill.js +1 -0
- package/app/components/sensor/summary.js +1 -0
- package/app/components/service-area/pill.js +1 -0
- package/app/components/service-area/summary.js +1 -0
- package/app/components/service-quote/pill.js +1 -0
- package/app/components/service-quote/summary.js +1 -0
- package/app/components/service-quote-item/pill.js +1 -0
- package/app/components/service-quote-item/summary.js +1 -0
- package/app/components/service-rate/pill.js +1 -0
- package/app/components/service-rate/summary.js +1 -0
- package/app/components/service-rate-fee/pill.js +1 -0
- package/app/components/service-rate-fee/summary.js +1 -0
- package/app/components/service-rate-parcel-fee/pill.js +1 -0
- package/app/components/service-rate-parcel-fee/summary.js +1 -0
- package/app/components/table/cell/fleet-ops-option.js +1 -0
- package/app/components/telematic/pill.js +1 -0
- package/app/components/telematic/summary.js +1 -0
- package/app/components/telematic/telemetry-status.js +1 -0
- package/app/components/tracking-number/pill.js +1 -0
- package/app/components/tracking-number/summary.js +1 -0
- package/app/components/tracking-status/pill.js +1 -0
- package/app/components/tracking-status/summary.js +1 -0
- package/app/components/trailer/summary.js +1 -0
- package/app/components/vehicle/details/inspections.js +1 -0
- package/app/components/vehicle/summary.js +1 -0
- package/app/components/vehicle-device/pill.js +1 -0
- package/app/components/vehicle-device/summary.js +1 -0
- package/app/components/vendor/personnel-tab.js +1 -0
- package/app/components/vendor/pill.js +1 -0
- package/app/components/vendor/summary.js +1 -0
- package/app/components/warranty/pill.js +1 -0
- package/app/components/warranty/summary.js +1 -0
- package/app/components/waypoint/pill.js +1 -0
- package/app/components/waypoint/summary.js +1 -0
- package/app/components/widget/radar.js +1 -0
- package/app/components/work-order/panel-header.js +1 -0
- package/app/components/work-order/pill.js +1 -0
- package/app/components/work-order/summary.js +1 -0
- package/app/components/zone/pill.js +1 -0
- package/app/components/zone/summary.js +1 -0
- package/app/controllers/maintenance/inspection-forms/index/details.js +1 -0
- package/app/controllers/maintenance/inspection-forms/index/edit.js +1 -0
- package/app/controllers/maintenance/inspection-forms/index/new.js +1 -0
- package/app/controllers/maintenance/inspection-forms/index.js +1 -0
- package/app/controllers/maintenance/inspection-submissions/index/details.js +1 -0
- package/app/controllers/maintenance/inspection-submissions/index/edit.js +1 -0
- package/app/controllers/maintenance/inspection-submissions/index/new.js +1 -0
- package/app/controllers/maintenance/inspection-submissions/index.js +1 -0
- package/app/helpers/initials.js +1 -0
- package/app/modifiers/inspection-flyout.js +1 -0
- package/app/modifiers/radar-keyboard.js +1 -0
- package/app/modifiers/sync-value.js +1 -0
- package/app/modifiers/when-changed.js +1 -0
- package/app/routes/maintenance/inspection-forms/index/details/index.js +1 -0
- package/app/routes/maintenance/inspection-forms/index/details/submissions.js +1 -0
- package/app/routes/maintenance/inspection-forms/index/details.js +1 -0
- package/app/routes/maintenance/inspection-forms/index/edit.js +1 -0
- package/app/routes/maintenance/inspection-forms/index/new.js +1 -0
- package/app/routes/maintenance/inspection-forms/index.js +1 -0
- package/app/routes/maintenance/inspection-forms.js +1 -0
- package/app/routes/maintenance/inspection-submissions/index/details/audit.js +1 -0
- package/app/routes/maintenance/inspection-submissions/index/details/index.js +1 -0
- package/app/routes/maintenance/inspection-submissions/index/details/photos.js +1 -0
- package/app/routes/maintenance/inspection-submissions/index/details.js +1 -0
- package/app/routes/maintenance/inspection-submissions/index/edit.js +1 -0
- package/app/routes/maintenance/inspection-submissions/index/new.js +1 -0
- package/app/routes/maintenance/inspection-submissions/index.js +1 -0
- package/app/routes/maintenance/inspection-submissions.js +1 -0
- package/app/routes/management/vehicles/index/details/inspections.js +1 -0
- package/app/services/inspection-form-actions.js +1 -0
- package/app/services/inspection-submission-actions.js +1 -0
- package/app/templates/maintenance/inspection-forms/index/details/index.js +1 -0
- package/app/templates/maintenance/inspection-forms/index/details/submissions.js +1 -0
- package/app/templates/maintenance/inspection-forms/index/details.js +1 -0
- package/app/templates/maintenance/inspection-forms/index/edit.js +1 -0
- package/app/templates/maintenance/inspection-forms/index/new.js +1 -0
- package/app/templates/maintenance/inspection-forms/index.js +1 -0
- package/app/templates/maintenance/inspection-forms.js +1 -0
- package/app/templates/maintenance/inspection-submissions/index/details/audit.js +1 -0
- package/app/templates/maintenance/inspection-submissions/index/details/index.js +1 -0
- package/app/templates/maintenance/inspection-submissions/index/details/photos.js +1 -0
- package/app/templates/maintenance/inspection-submissions/index/details.js +1 -0
- package/app/templates/maintenance/inspection-submissions/index/edit.js +1 -0
- package/app/templates/maintenance/inspection-submissions/index/new.js +1 -0
- package/app/templates/maintenance/inspection-submissions/index.js +1 -0
- package/app/templates/maintenance/inspection-submissions.js +1 -0
- package/app/templates/management/vehicles/index/details/inspections.js +1 -0
- package/app/utils/inspection-field-types.js +2 -0
- package/app/utils/inspection-form-structure.js +1 -0
- package/app/utils/radar.js +1 -0
- package/composer.json +1 -1
- package/docs/AFAQY.md +91 -0
- package/docs/TELEMETRY_ARCHITECTURE.md +115 -0
- package/extension.json +1 -1
- package/package.json +3 -3
- package/scripts/coverage-summary.php +11 -0
- package/scripts/pest-bootstrap.php +1 -1
- package/server/config/afaqy.php +8 -0
- package/server/config/fuel-providers.php +28 -7
- package/server/config/telematics.php +8 -1
- package/server/config/telemetry.php +17 -0
- package/server/migrations/2026_09_09_000001_create_inspection_tables.php +152 -0
- package/server/migrations/2026_09_10_000001_convert_inspection_form_items_to_field_groups.php +44 -0
- package/server/migrations/2026_09_10_000002_add_token_to_inspection_links.php +39 -0
- package/server/migrations/2026_09_11_000001_add_assignee_and_pin_to_inspection_links.php +39 -0
- package/server/migrations/2026_09_15_000001_create_telematic_telemetry_tables.php +62 -0
- package/server/migrations/2026_09_15_000002_scope_fuel_transactions_to_connection.php +25 -0
- package/server/migrations/2026_09_16_000001_add_public_id_to_alerts_table.php +45 -0
- package/server/resources/views/mail/inspection-link-pin.blade.php +34 -0
- package/server/src/Auth/Schemas/FleetOps.php +12 -0
- package/server/src/Console/Commands/DrainTelematicInbox.php +82 -0
- package/server/src/Console/Commands/ProcessMaintenanceTriggers.php +4 -1
- package/server/src/Console/Commands/SyncTelematics.php +32 -2
- package/server/src/Contracts/TelemetryProviderInterface.php +27 -0
- package/server/src/Events/DeviceTelemetryUpdated.php +37 -0
- package/server/src/Events/VehicleLocationChanged.php +8 -4
- package/server/src/Exports/InspectionExport.php +125 -0
- package/server/src/Http/Controllers/Api/v1/GeofenceController.php +1 -1
- package/server/src/Http/Controllers/Api/v1/InspectionController.php +300 -0
- package/server/src/Http/Controllers/Internal/v1/FuelProviderConnectionController.php +40 -8
- package/server/src/Http/Controllers/Internal/v1/HubController.php +36 -11
- package/server/src/Http/Controllers/Internal/v1/InspectionFormController.php +326 -0
- package/server/src/Http/Controllers/Internal/v1/InspectionSubmissionController.php +229 -0
- package/server/src/Http/Controllers/Internal/v1/RadarController.php +1117 -0
- package/server/src/Http/Controllers/Internal/v1/TelematicController.php +67 -0
- package/server/src/Http/Controllers/Public/PublicInspectionController.php +243 -0
- package/server/src/Http/Controllers/TelematicPositionWebhookController.php +60 -0
- package/server/src/Http/Controllers/TelematicWebhookController.php +3 -0
- package/server/src/Http/Filter/FuelProviderConnectionFilter.php +1 -1
- package/server/src/Http/Middleware/ForceJsonResponse.php +25 -0
- package/server/src/Http/Resources/v1/InspectionForm.php +153 -0
- package/server/src/Http/Resources/v1/InspectionItemResult.php +77 -0
- package/server/src/Http/Resources/v1/InspectionLink.php +84 -0
- package/server/src/Http/Resources/v1/InspectionSubmission.php +173 -0
- package/server/src/Jobs/PollTelematicTelemetry.php +118 -0
- package/server/src/Jobs/ProcessTelematicDelivery.php +122 -0
- package/server/src/Jobs/SyncFuelProviderTransactionsJob.php +21 -4
- package/server/src/Mail/InspectionLinkPinMail.php +57 -0
- package/server/src/Models/Driver.php +8 -2
- package/server/src/Models/FuelProviderTransaction.php +1 -0
- package/server/src/Models/InspectionForm.php +240 -0
- package/server/src/Models/InspectionItemResult.php +90 -0
- package/server/src/Models/InspectionLink.php +284 -0
- package/server/src/Models/InspectionSubmission.php +440 -0
- package/server/src/Models/Part.php +9 -2
- package/server/src/Models/WorkOrder.php +3 -0
- package/server/src/Observers/WorkOrderObserver.php +1 -1
- package/server/src/Providers/FleetOpsServiceProvider.php +9 -0
- package/server/src/Rules/Base64OrUrl.php +54 -0
- package/server/src/Support/FuelProviders/FuelProviderService.php +64 -27
- package/server/src/Support/FuelProviders/Providers/PetroAppFuelProvider.php +81 -15
- package/server/src/Support/InspectionFileStore.php +268 -0
- package/server/src/Support/InspectionFormSync.php +231 -0
- package/server/src/Support/InspectionLinkPin.php +150 -0
- package/server/src/Support/InspectionSubmitter.php +297 -0
- package/server/src/Support/Radar/RadarAgenda.php +375 -0
- package/server/src/Support/Radar/RadarBriefing.php +504 -0
- package/server/src/Support/Radar/RadarItemState.php +435 -0
- package/server/src/Support/Radar/RadarRules.php +1424 -0
- package/server/src/Support/Reporting/FleetOpsReportSchema.php +178 -0
- package/server/src/Support/Telematics/Afaqy/Payload.php +49 -0
- package/server/src/Support/Telematics/Providers/AfaqyProvider.php +179 -61
- package/server/src/Support/Telematics/TelematicService.php +37 -6
- package/server/src/Support/Telematics/Telemetry/Configuration.php +30 -0
- package/server/src/Support/Telematics/Telemetry/Inbox.php +61 -0
- package/server/src/Support/Telematics/Telemetry/Ingestor.php +112 -0
- package/server/src/Support/Telematics/Telemetry/Queue.php +28 -0
- package/server/src/Support/Telematics/Telemetry/Sample.php +54 -0
- package/server/src/routes.php +76 -0
- package/server/tests/ApiManifestControllerContractsTest.php +9 -9
- package/server/tests/ControllerFilterContractsTest.php +1 -1
- package/server/tests/EventContractsTest.php +2 -1
- package/server/tests/Feature/Http/AfaqyRealtimeIngestionTest.php +792 -0
- package/server/tests/Feature/Http/Api/GeofenceControllerContractsTest.php +4 -4
- package/server/tests/Feature/Http/Api/TrailerControllerLifecycleTest.php +1 -1
- package/server/tests/Feature/Http/Internal/DriverControllerCreateRecordTest.php +1 -1
- package/server/tests/Feature/Http/Internal/DriverControllerExistingUserAdoptionTest.php +1 -1
- package/server/tests/Feature/Http/Internal/HubControllerTest.php +28 -2
- package/server/tests/Feature/Http/Internal/OrderControllerCreateRecordTest.php +1 -1
- package/server/tests/Feature/Http/Internal/RadarControllerDatabaseTest.php +415 -0
- package/server/tests/Feature/Http/Internal/RadarControllerTest.php +594 -0
- package/server/tests/FuelProviderConnectionControllerContractsTest.php +83 -3
- package/server/tests/FuelProviderImplementationTest.php +10 -2
- package/server/tests/HubAndGettingStartedContractsTest.php +26 -3
- package/server/tests/InspectionControllerContractsTest.php +1329 -0
- package/server/tests/InspectionFieldContractsTest.php +1019 -0
- package/server/tests/InspectionModelContractsTest.php +728 -0
- package/server/tests/InspectionSubmitterRulesTest.php +47 -0
- package/server/tests/ObserverContractsTest.php +1 -1
- package/server/tests/QueueJobContractsTest.php +3 -4
- package/server/tests/RadarRoutesTest.php +35 -0
- package/server/tests/ReportSchemaContractsTest.php +15 -1
- package/server/tests/RouteRegistrationExecutionTest.php +109 -18
- package/server/tests/Support/AfaqyTestCrypto.php +27 -0
- package/server/tests/Support/ExampleTelemetryProvider.php +82 -0
- package/server/tests/Support/TelemetryTestEnvironment.php +53 -0
- package/server/tests/TelematicsHardeningTest.php +17 -17
- package/server/tests/TrailerSupportCoverageTest.php +1 -1
- package/server/tests/Unit/Http/Resources/ManifestResourceTest.php +3 -3
- package/server/tests/Unit/Support/FuelProviderServiceMatchingTest.php +127 -0
- package/server/tests/Unit/Support/PetroAppFuelProviderTest.php +126 -1
- package/server/tests/Unit/Support/RadarAgendaTest.php +200 -0
- package/server/tests/Unit/Support/RadarBriefingTest.php +214 -0
- package/server/tests/Unit/Support/RadarItemStateTest.php +260 -0
- package/server/tests/Unit/Support/RadarRulesTest.php +523 -0
- package/server/tests/Unit/Support/Telematics/Providers/AfaqyProviderTest.php +9 -1
- package/server/tests/Unit/Support/Telematics/Providers/AfaqyProviderTransportTest.php +8 -0
- package/server/tests/Unit/Support/Telematics/Providers/AfaqyRealtimeContractTest.php +188 -0
- package/server/tests/Unit/Support/Telematics/TelematicServiceTelemetryTest.php +1 -0
- package/translations/ar-ae.yml +3 -1
- package/translations/bg-bg.yaml +3 -1
- package/translations/en-us.yaml +738 -15
- package/translations/es-pa.yaml +3 -1
- package/translations/fr-fr.yaml +3 -1
- package/translations/mn-mn.yaml +3 -1
- package/translations/pt-br.yaml +3 -1
- package/translations/ru-ru.yaml +3 -1
- package/translations/vi-vn.yaml +3 -1
- package/addon/components/cell/attached-vehicle.hbs +0 -10
- package/addon/components/cell/attached-vehicle.js +0 -58
- package/addon/components/cell/device-identity.js +0 -129
- package/addon/components/cell/driver-identity.js +0 -143
- package/addon/components/cell/driver-name.hbs +0 -26
- package/addon/components/cell/driver-name.js +0 -30
- package/addon/components/cell/equipment-identity.js +0 -48
- package/addon/components/cell/part-identity.js +0 -63
- package/addon/components/cell/telematic-device.hbs +0 -38
- package/addon/components/cell/telematic-device.js +0 -44
- package/addon/components/cell/telematic-provider.hbs +0 -33
- package/addon/components/cell/telematic-provider.js +0 -78
- package/addon/components/cell/vehicle-identity.js +0 -138
- package/addon/components/cell/vehicle-name.hbs +0 -23
- package/addon/components/cell/vehicle-name.js +0 -3
- package/addon/components/device/pill.js +0 -3
- package/addon/components/driver/pill.js +0 -7
- package/addon/components/equipment/pill.js +0 -3
- package/addon/components/filter/multi-model.hbs +0 -19
- package/addon/components/filter/multi-model.js +0 -90
- package/addon/components/order/pill.js +0 -3
- package/addon/components/trailer/pill.js +0 -3
- package/addon/components/vehicle/pill.js +0 -7
- package/addon/templates/connectivity/fuel-providers/details/settings.hbs +0 -11
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Support;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Models\InspectionForm;
|
|
6
|
+
use Fleetbase\Models\Category;
|
|
7
|
+
use Fleetbase\Models\CustomField;
|
|
8
|
+
use Illuminate\Support\Arr;
|
|
9
|
+
use Illuminate\Support\Collection;
|
|
10
|
+
use Illuminate\Support\Facades\DB;
|
|
11
|
+
use Illuminate\Support\Str;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Writes a form's structure — groups of typed fields — from the shape the
|
|
15
|
+
* console builder holds it in, and converts the first cut's checklist into
|
|
16
|
+
* that structure.
|
|
17
|
+
*
|
|
18
|
+
* The console builder lets a form be laid out before the form record exists,
|
|
19
|
+
* so the whole draft arrives with the first save and has to be written in one
|
|
20
|
+
* go: groups become platform categories owned by the form, fields become
|
|
21
|
+
* platform custom fields whose subject is the form. Rows are matched on their
|
|
22
|
+
* uuid so a second post updates rather than duplicates; rows the post no
|
|
23
|
+
* longer mentions are pruned only when asked, because a partial post is the
|
|
24
|
+
* common case and losing fields is not.
|
|
25
|
+
*/
|
|
26
|
+
class InspectionFormSync
|
|
27
|
+
{
|
|
28
|
+
/** The group columns the builder is allowed to write. */
|
|
29
|
+
public const GROUP_COLUMNS = ['name', 'description', 'meta', 'order', 'icon', 'icon_color', 'translations', 'tags'];
|
|
30
|
+
|
|
31
|
+
/** The field columns the builder is allowed to write. */
|
|
32
|
+
public const FIELD_COLUMNS = ['name', 'label', 'type', 'component', 'options', 'required', 'editable', 'default_value', 'validation_rules', 'meta', 'description', 'help_text', 'order', 'for'];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param InspectionForm $form the form the structure belongs to
|
|
36
|
+
* @param array $draft groups, each with its fields under `fields` or `customFields`
|
|
37
|
+
* @param bool $pruneMissing drop groups and fields the draft no longer lists
|
|
38
|
+
* @param string $primaryKey the key rows are matched on, `uuid` or `id`
|
|
39
|
+
*
|
|
40
|
+
* @return array{groups: Category[], fields: CustomField[]}
|
|
41
|
+
*/
|
|
42
|
+
public static function sync(InspectionForm $form, array $draft, bool $pruneMissing = false, string $primaryKey = 'uuid'): array
|
|
43
|
+
{
|
|
44
|
+
$existingGroups = Category::query()
|
|
45
|
+
->where(['owner_uuid' => $form->uuid, 'for' => InspectionForm::GROUP_FOR])
|
|
46
|
+
->get()
|
|
47
|
+
->keyBy('uuid');
|
|
48
|
+
// Only the fields a driver answers. A custom field the console's
|
|
49
|
+
// generic panel added to the form *record* has the same subject and
|
|
50
|
+
// would otherwise be pruned as a field the builder no longer lists.
|
|
51
|
+
$existingFields = CustomField::query()
|
|
52
|
+
->where(['subject_uuid' => $form->uuid, 'for' => InspectionForm::FIELD_FOR])
|
|
53
|
+
->get()
|
|
54
|
+
->keyBy('uuid');
|
|
55
|
+
|
|
56
|
+
$keptGroups = [];
|
|
57
|
+
$keptFields = [];
|
|
58
|
+
$now = now();
|
|
59
|
+
|
|
60
|
+
foreach (array_values($draft) as $groupIndex => $groupData) {
|
|
61
|
+
$groupUuid = Arr::get($groupData, $primaryKey);
|
|
62
|
+
$group = $groupUuid ? $existingGroups->get($groupUuid) : null;
|
|
63
|
+
$groupUuid = $group?->uuid ?? ($groupUuid ?: (string) Str::uuid());
|
|
64
|
+
$groupAttrs = static::normalizeRow(Arr::only($groupData, static::GROUP_COLUMNS), $groupIndex);
|
|
65
|
+
|
|
66
|
+
if ($group) {
|
|
67
|
+
DB::table('categories')->where('uuid', $groupUuid)->update(array_merge($groupAttrs, ['updated_at' => $now]));
|
|
68
|
+
} else {
|
|
69
|
+
DB::table('categories')->insert(array_merge($groupAttrs, [
|
|
70
|
+
'uuid' => $groupUuid,
|
|
71
|
+
'public_id' => 'category_' . Str::lower(Str::random(14)),
|
|
72
|
+
'company_uuid' => $form->company_uuid,
|
|
73
|
+
'owner_uuid' => $form->uuid,
|
|
74
|
+
'owner_type' => $form->getMorphClass(),
|
|
75
|
+
'for' => InspectionForm::GROUP_FOR,
|
|
76
|
+
'slug' => Str::slug((string) ($groupAttrs['name'] ?? 'group')),
|
|
77
|
+
'created_at' => $now,
|
|
78
|
+
'updated_at' => $now,
|
|
79
|
+
]));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
$keptGroups[] = $groupUuid;
|
|
83
|
+
|
|
84
|
+
$fields = Arr::get($groupData, 'fields', Arr::get($groupData, 'customFields', []));
|
|
85
|
+
foreach (array_values(is_array($fields) ? $fields : []) as $fieldIndex => $fieldData) {
|
|
86
|
+
$fieldUuid = Arr::get($fieldData, $primaryKey);
|
|
87
|
+
$field = $fieldUuid ? $existingFields->get($fieldUuid) : null;
|
|
88
|
+
$fieldUuid = $field?->uuid ?? ($fieldUuid ?: (string) Str::uuid());
|
|
89
|
+
$fieldAttrs = static::normalizeField(Arr::only($fieldData, static::FIELD_COLUMNS), $fieldIndex);
|
|
90
|
+
|
|
91
|
+
if ($field) {
|
|
92
|
+
DB::table('custom_fields')->where('uuid', $fieldUuid)->update(array_merge($fieldAttrs, ['category_uuid' => $groupUuid, 'updated_at' => $now]));
|
|
93
|
+
} else {
|
|
94
|
+
DB::table('custom_fields')->insert(array_merge($fieldAttrs, [
|
|
95
|
+
'uuid' => $fieldUuid,
|
|
96
|
+
'company_uuid' => $form->company_uuid,
|
|
97
|
+
'category_uuid' => $groupUuid,
|
|
98
|
+
'subject_uuid' => $form->uuid,
|
|
99
|
+
'subject_type' => $form->getMorphClass(),
|
|
100
|
+
'created_at' => $now,
|
|
101
|
+
'updated_at' => $now,
|
|
102
|
+
]));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
$keptFields[] = $fieldUuid;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if ($pruneMissing) {
|
|
110
|
+
static::prune($form, $existingGroups, $keptGroups, $existingFields, $keptFields);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
$form->unsetRelation('fieldGroups');
|
|
114
|
+
$form->unsetRelation('fields');
|
|
115
|
+
$form->load(['fieldGroups', 'fields']);
|
|
116
|
+
|
|
117
|
+
return ['groups' => $form->fieldGroups->all(), 'fields' => $form->fields->all()];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Converts the first cut's `items` checklist into a "Checklist" group of
|
|
122
|
+
* pass-fail fields. Skips forms that have already been built with fields,
|
|
123
|
+
* and forms with nothing to convert, so it can be run any number of times.
|
|
124
|
+
*
|
|
125
|
+
* @return int the number of fields written
|
|
126
|
+
*/
|
|
127
|
+
public static function convertLegacyItems(InspectionForm $form): int
|
|
128
|
+
{
|
|
129
|
+
$items = array_values(array_filter(is_array($form->items) ? $form->items : [], 'is_array'));
|
|
130
|
+
if (empty($items) || $form->fields()->count() > 0) {
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
$fields = [];
|
|
135
|
+
foreach ($items as $index => $item) {
|
|
136
|
+
$label = trim((string) ($item['label'] ?? $item['title'] ?? ''));
|
|
137
|
+
$label = $label === '' ? 'Item ' . ($index + 1) : $label;
|
|
138
|
+
$fields[] = [
|
|
139
|
+
'label' => $label,
|
|
140
|
+
'name' => Str::slug((string) ($item['key'] ?? $label)),
|
|
141
|
+
'type' => 'pass-fail',
|
|
142
|
+
'required' => (bool) ($item['required'] ?? true),
|
|
143
|
+
'description' => $item['description'] ?? null,
|
|
144
|
+
'order' => $index + 1,
|
|
145
|
+
'meta' => [
|
|
146
|
+
'severity' => $item['severity'] ?? 'medium',
|
|
147
|
+
'category' => $item['category'] ?? null,
|
|
148
|
+
'require_photo_on_fail' => false,
|
|
149
|
+
'require_comment_on_fail' => false,
|
|
150
|
+
'unsafe_on_fail' => ($item['severity'] ?? null) === 'critical',
|
|
151
|
+
],
|
|
152
|
+
];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
$synced = static::sync($form, [[
|
|
156
|
+
'name' => 'Checklist',
|
|
157
|
+
'order' => 1,
|
|
158
|
+
'meta' => ['grid_size' => 1, 'converted_from_items' => true],
|
|
159
|
+
'fields' => $fields,
|
|
160
|
+
]]);
|
|
161
|
+
|
|
162
|
+
return count($synced['fields']);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** Group attributes as the categories table stores them. */
|
|
166
|
+
protected static function normalizeRow(array $attributes, int $index): array
|
|
167
|
+
{
|
|
168
|
+
if (!array_key_exists('order', $attributes) || $attributes['order'] === null) {
|
|
169
|
+
$attributes['order'] = $index + 1;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
foreach ($attributes as $key => $value) {
|
|
173
|
+
if (is_array($value) || is_object($value)) {
|
|
174
|
+
$attributes[$key] = json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return $attributes;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** Field attributes as the custom_fields table stores them. */
|
|
182
|
+
protected static function normalizeField(array $attributes, int $index): array
|
|
183
|
+
{
|
|
184
|
+
$label = trim((string) ($attributes['label'] ?? ''));
|
|
185
|
+
if ($label === '') {
|
|
186
|
+
$label = 'Untitled field';
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
$attributes['label'] = $label;
|
|
190
|
+
$attributes['name'] = Str::slug((string) (($attributes['name'] ?? '') ?: $label));
|
|
191
|
+
$attributes['type'] = in_array($attributes['type'] ?? null, InspectionForm::FIELD_TYPES, true) ? $attributes['type'] : 'input';
|
|
192
|
+
$attributes['for'] = InspectionForm::FIELD_FOR;
|
|
193
|
+
|
|
194
|
+
if (empty($attributes['component'])) {
|
|
195
|
+
$attributes['component'] = static::componentFor($attributes['type']);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
foreach (['required', 'editable'] as $flag) {
|
|
199
|
+
$attributes[$flag] = (int) filter_var($attributes[$flag] ?? ($flag === 'editable'), FILTER_VALIDATE_BOOLEAN);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return static::normalizeRow($attributes, $index);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The console component that edits a field type. The platform's own
|
|
207
|
+
* types keep the platform's components; the inspection-only types are
|
|
208
|
+
* rendered by FleetOps and named after themselves.
|
|
209
|
+
*/
|
|
210
|
+
public static function componentFor(string $type): string
|
|
211
|
+
{
|
|
212
|
+
return $type === 'radio-button' ? 'radio-button-select' : $type;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
protected static function prune(InspectionForm $form, Collection $existingGroups, array $keptGroups, Collection $existingFields, array $keptFields): void
|
|
216
|
+
{
|
|
217
|
+
$groupsToDelete = $existingGroups->keys()->diff($keptGroups)->values();
|
|
218
|
+
if ($groupsToDelete->isNotEmpty()) {
|
|
219
|
+
CustomField::query()
|
|
220
|
+
->where(['subject_uuid' => $form->uuid, 'for' => InspectionForm::FIELD_FOR])
|
|
221
|
+
->whereIn('category_uuid', $groupsToDelete)
|
|
222
|
+
->delete();
|
|
223
|
+
Category::query()->whereIn('uuid', $groupsToDelete)->delete();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
$fieldsToDelete = $existingFields->keys()->diff($keptFields)->values();
|
|
227
|
+
if ($fieldsToDelete->isNotEmpty()) {
|
|
228
|
+
CustomField::query()->whereIn('uuid', $fieldsToDelete)->delete();
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Support;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Mail\InspectionLinkPinMail;
|
|
6
|
+
use Fleetbase\FleetOps\Models\InspectionLink;
|
|
7
|
+
use Fleetbase\Models\Company;
|
|
8
|
+
use Fleetbase\Models\User;
|
|
9
|
+
use Fleetbase\Services\SmsService;
|
|
10
|
+
use Fleetbase\Support\Utils;
|
|
11
|
+
use Illuminate\Support\Facades\Mail;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Sends an inspection link and its PIN to whoever the link is for.
|
|
15
|
+
*
|
|
16
|
+
* The message carries both, so the recipient can open the inspection straight
|
|
17
|
+
* from it. The PIN still stops anyone who has only the link, such as a link
|
|
18
|
+
* copied or forwarded on its own, and it locks the link after a few wrong
|
|
19
|
+
* guesses.
|
|
20
|
+
*/
|
|
21
|
+
class InspectionLinkPin
|
|
22
|
+
{
|
|
23
|
+
public const VIA = ['email', 'sms'];
|
|
24
|
+
|
|
25
|
+
/** Who a link's PIN goes to: the assignee, or failing that the driver's account. */
|
|
26
|
+
public static function recipientFor(InspectionLink $link): ?User
|
|
27
|
+
{
|
|
28
|
+
return $link->assignee ?? $link->driver?->user;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Why a PIN cannot go to this person this way, or null when it can. */
|
|
32
|
+
public static function unavailableReason(?User $recipient, string $via): ?string
|
|
33
|
+
{
|
|
34
|
+
if (!$recipient) {
|
|
35
|
+
return 'Assign the link to someone, or pick a driver, to send the PIN to.';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if ($via === 'sms' && !filled($recipient->phone)) {
|
|
39
|
+
return ($recipient->name ?: 'This person') . ' has no phone number to text the PIN to.';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if ($via === 'email' && !filled($recipient->email)) {
|
|
43
|
+
return ($recipient->name ?: 'This person') . ' has no email address to send the PIN to.';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Send the link's PIN. Never throws: a failed delivery is reported in the
|
|
51
|
+
* result, so minting a link does not fail because a mailer is misconfigured.
|
|
52
|
+
*
|
|
53
|
+
* @return array{sent: bool, via: string, to: ?string, error: ?string}
|
|
54
|
+
*/
|
|
55
|
+
public static function send(InspectionLink $link, string $via): array
|
|
56
|
+
{
|
|
57
|
+
$recipient = static::recipientFor($link);
|
|
58
|
+
$reason = static::unavailableReason($recipient, $via);
|
|
59
|
+
|
|
60
|
+
if (!$link->pin) {
|
|
61
|
+
$reason = 'This link has no PIN to send.';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if ($reason) {
|
|
65
|
+
return ['sent' => false, 'via' => $via, 'to' => null, 'error' => $reason];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
if ($via === 'sms') {
|
|
70
|
+
// Resolved from the container rather than built here, so the
|
|
71
|
+
// provider can be swapped out without touching this class.
|
|
72
|
+
$result = app(SmsService::class)->send($recipient->phone, static::smsText($link, $link->pin, static::urlFor($link)), static::smsOptions($link));
|
|
73
|
+
|
|
74
|
+
if (is_array($result) && array_key_exists('success', $result) && !$result['success']) {
|
|
75
|
+
return ['sent' => false, 'via' => $via, 'to' => null, 'error' => 'The PIN could not be texted: ' . ($result['error'] ?? $result['message'] ?? 'the SMS provider refused it.')];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
$to = static::maskPhone($recipient->phone);
|
|
79
|
+
} else {
|
|
80
|
+
Mail::to($recipient)->send(new InspectionLinkPinMail($link, $link->pin, $recipient, static::urlFor($link)));
|
|
81
|
+
$to = static::maskEmail($recipient->email);
|
|
82
|
+
}
|
|
83
|
+
} catch (\Throwable $e) {
|
|
84
|
+
report($e);
|
|
85
|
+
|
|
86
|
+
return ['sent' => false, 'via' => $via, 'to' => null, 'error' => 'The PIN could not be sent: ' . $e->getMessage()];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
$link->forceFill(['pin_sent_via' => $via, 'pin_sent_at' => now()])->save();
|
|
90
|
+
|
|
91
|
+
return ['sent' => true, 'via' => $via, 'to' => $to, 'error' => null];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The link as the recipient opens it, on the console's own host. Null for a
|
|
96
|
+
* link minted before tokens were kept, whose URL cannot be rebuilt.
|
|
97
|
+
*/
|
|
98
|
+
public static function urlFor(InspectionLink $link): ?string
|
|
99
|
+
{
|
|
100
|
+
$path = $link->path;
|
|
101
|
+
|
|
102
|
+
return $path ? Utils::consoleUrl($path) : null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Naming the organisation so it is recognised, and short enough to read at a glance. */
|
|
106
|
+
public static function smsText(InspectionLink $link, string $pin, ?string $url = null): string
|
|
107
|
+
{
|
|
108
|
+
$company = Company::select(['uuid', 'name'])->find($link->company_uuid)?->name ?? config('app.name');
|
|
109
|
+
$form = $link->form?->name ?? 'inspection';
|
|
110
|
+
|
|
111
|
+
if ($url) {
|
|
112
|
+
return "{$company}: complete the {$form} inspection at {$url} using PIN {$pin}. Do not share this PIN.";
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return "{$company}: your PIN for the {$form} inspection is {$pin}. Do not share this PIN.";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The organisation's alphanumeric sender ID, when it has one, the same way
|
|
120
|
+
* the platform's own verification texts use it: as a Twilio-only option,
|
|
121
|
+
* so other providers are not handed a sender they would reject.
|
|
122
|
+
*/
|
|
123
|
+
protected static function smsOptions(InspectionLink $link): array
|
|
124
|
+
{
|
|
125
|
+
$company = Company::select(['uuid', 'options'])->find($link->company_uuid);
|
|
126
|
+
|
|
127
|
+
if (!$company) {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
$enabled = Utils::castBoolean($company->getOption('alpha_numeric_sender_id_enabled'));
|
|
132
|
+
$senderId = $company->getOption('alpha_numeric_sender_id');
|
|
133
|
+
|
|
134
|
+
return $enabled && $senderId ? ['twilioParams' => ['from' => $senderId]] : [];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** "r•••@fleetbase.io": enough to recognise, not enough to copy. */
|
|
138
|
+
public static function maskEmail(string $email): string
|
|
139
|
+
{
|
|
140
|
+
[$local, $domain] = array_pad(explode('@', $email, 2), 2, '');
|
|
141
|
+
|
|
142
|
+
return mb_substr($local, 0, 1) . '•••@' . $domain;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** "•••1969": the last four digits. */
|
|
146
|
+
public static function maskPhone(string $phone): string
|
|
147
|
+
{
|
|
148
|
+
return '•••' . substr(preg_replace('/\D/', '', $phone), -4);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Support;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Models\InspectionForm;
|
|
6
|
+
use Fleetbase\FleetOps\Models\InspectionItemResult;
|
|
7
|
+
use Fleetbase\FleetOps\Models\InspectionSubmission;
|
|
8
|
+
use Fleetbase\FleetOps\Rules\Base64OrUrl;
|
|
9
|
+
use Fleetbase\Models\CustomField;
|
|
10
|
+
use Illuminate\Support\Arr;
|
|
11
|
+
use Illuminate\Support\Collection;
|
|
12
|
+
use Illuminate\Support\Str;
|
|
13
|
+
use Illuminate\Validation\ValidationException;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Records an inspection against a published form.
|
|
17
|
+
*
|
|
18
|
+
* Two doors lead here — the tokenised public link and the driver API — and
|
|
19
|
+
* they must agree on what a submission is: one row, the answers, the pass/fail
|
|
20
|
+
* counts, and whatever follow-up the form's settings ask for. The doors differ
|
|
21
|
+
* only in who they say submitted it, which is what the `$attributes` argument
|
|
22
|
+
* carries.
|
|
23
|
+
*
|
|
24
|
+
* A form built from fields is answered with `custom_field_values`: one value
|
|
25
|
+
* per field, stored through the platform's custom-field values, with every
|
|
26
|
+
* `pass-fail` answer mirrored into an item result. The first cut's
|
|
27
|
+
* `item_results` body is still accepted for the public link and older app
|
|
28
|
+
* builds; when both arrive the field values win and the duplicated results
|
|
29
|
+
* are ignored.
|
|
30
|
+
*/
|
|
31
|
+
class InspectionSubmitter
|
|
32
|
+
{
|
|
33
|
+
/**
|
|
34
|
+
* The body of a submit, as both doors accept it.
|
|
35
|
+
*/
|
|
36
|
+
public static function rules(): array
|
|
37
|
+
{
|
|
38
|
+
return [
|
|
39
|
+
'odometer' => 'nullable|integer|min:0',
|
|
40
|
+
'engine_hours' => 'nullable|integer|min:0',
|
|
41
|
+
// Every key of an answer needs a rule of its own. validate() returns
|
|
42
|
+
// only keys that have one, and with nested rules present an array's
|
|
43
|
+
// other keys are dropped: without these, `value` never reached the
|
|
44
|
+
// submitter, so every answer arrived empty and a failed check
|
|
45
|
+
// carrying its photo was refused for having none.
|
|
46
|
+
'answers' => 'required_without_all:item_results,custom_field_values|array',
|
|
47
|
+
'answers.*.field' => 'required_without:answers.*.custom_field|string|max:191',
|
|
48
|
+
'answers.*.custom_field' => 'nullable|string|max:191',
|
|
49
|
+
'answers.*.value' => 'nullable',
|
|
50
|
+
'answers.*.value_type' => 'nullable|string|max:50',
|
|
51
|
+
'custom_field_values' => 'required_without_all:item_results,answers|array',
|
|
52
|
+
'custom_field_values.*.custom_field' => 'required_without:custom_field_values.*.custom_field_uuid|string|max:191',
|
|
53
|
+
'custom_field_values.*.custom_field_uuid' => 'nullable|string|max:191',
|
|
54
|
+
'custom_field_values.*.value' => 'nullable',
|
|
55
|
+
'custom_field_values.*.value_type' => 'nullable|string|max:50',
|
|
56
|
+
'item_results' => 'required_without_all:custom_field_values,answers|array',
|
|
57
|
+
'item_results.*.item_key' => 'nullable|string|max:191',
|
|
58
|
+
'item_results.*.label' => 'required|string|max:255',
|
|
59
|
+
'item_results.*.category' => 'nullable|string|max:191',
|
|
60
|
+
'item_results.*.status' => 'nullable|string|max:50',
|
|
61
|
+
'item_results.*.severity' => 'nullable|string|max:50',
|
|
62
|
+
'item_results.*.passed' => 'required|boolean',
|
|
63
|
+
'item_results.*.comments' => 'nullable|string|max:2000',
|
|
64
|
+
'item_results.*.photos' => 'nullable|array',
|
|
65
|
+
'item_results.*.photos.*' => ['string', new Base64OrUrl()],
|
|
66
|
+
'location' => 'nullable|array',
|
|
67
|
+
'signature' => 'nullable|array',
|
|
68
|
+
'attachments' => 'nullable|array',
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param array $validated the request body, already validated against rules()
|
|
74
|
+
* @param array $attributes columns the door owns: vehicle_uuid, driver_uuid,
|
|
75
|
+
* submitted_by_uuid, source, started_at, meta
|
|
76
|
+
*/
|
|
77
|
+
public static function submit(InspectionForm $form, array $validated, array $attributes = []): InspectionSubmission
|
|
78
|
+
{
|
|
79
|
+
$submission = InspectionSubmission::create(array_merge([
|
|
80
|
+
'company_uuid' => $form->company_uuid,
|
|
81
|
+
'inspection_form_uuid' => $form->uuid,
|
|
82
|
+
'type' => $form->type ?? 'dvir',
|
|
83
|
+
'status' => 'submitted',
|
|
84
|
+
'odometer' => data_get($validated, 'odometer'),
|
|
85
|
+
'engine_hours' => data_get($validated, 'engine_hours'),
|
|
86
|
+
'started_at' => now(),
|
|
87
|
+
'submitted_at' => now(),
|
|
88
|
+
'location' => data_get($validated, 'location'),
|
|
89
|
+
'signature' => data_get($validated, 'signature'),
|
|
90
|
+
'attachments' => data_get($validated, 'attachments'),
|
|
91
|
+
], $attributes));
|
|
92
|
+
|
|
93
|
+
// `answers` is what the API documents; `custom_field_values` is what
|
|
94
|
+
// the first cut shipped and the console still sends.
|
|
95
|
+
$values = data_get($validated, 'answers') ?: data_get($validated, 'custom_field_values');
|
|
96
|
+
$under = data_get($validated, 'answers') ? 'answers' : 'custom_field_values';
|
|
97
|
+
if (is_array($values) && !empty($values)) {
|
|
98
|
+
static::applyCustomFieldValues($submission, $values, $submission->submitted_by_uuid, $under);
|
|
99
|
+
} else {
|
|
100
|
+
foreach ((array) data_get($validated, 'item_results', []) as $item) {
|
|
101
|
+
InspectionItemResult::create([
|
|
102
|
+
'company_uuid' => $form->company_uuid,
|
|
103
|
+
'inspection_submission_uuid' => $submission->uuid,
|
|
104
|
+
'item_key' => data_get($item, 'item_key'),
|
|
105
|
+
'label' => data_get($item, 'label'),
|
|
106
|
+
'category' => data_get($item, 'category'),
|
|
107
|
+
'status' => data_get($item, 'status', data_get($item, 'passed') ? 'passed' : 'failed'),
|
|
108
|
+
'severity' => data_get($item, 'severity'),
|
|
109
|
+
'passed' => (bool) data_get($item, 'passed'),
|
|
110
|
+
'comments' => data_get($item, 'comments'),
|
|
111
|
+
'photos' => data_get($item, 'photos'),
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
$submission->syncResultCounts();
|
|
117
|
+
|
|
118
|
+
if (data_get($form->settings, 'create_issue_on_failure') && $submission->has_failures) {
|
|
119
|
+
$submission->createIssueFromFailures();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (data_get($form->settings, 'create_work_order_on_failure') && $submission->has_failures) {
|
|
123
|
+
$submission->createWorkOrderFromFailures();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return $submission;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Stores a set of answers against the submission's form.
|
|
131
|
+
*
|
|
132
|
+
* Each row names a field of the form by uuid (or name), carries a value
|
|
133
|
+
* and, optionally, a value type. A field that does not belong to the form,
|
|
134
|
+
* or a failed pass-fail answer missing the comment or photo the field
|
|
135
|
+
* insists on, refuses the whole set with a 422 so nothing half-filled is
|
|
136
|
+
* written. Base64 photos and signatures become platform files on the way
|
|
137
|
+
* in; when the answers are in, the item results and the counts follow.
|
|
138
|
+
*
|
|
139
|
+
* @param array $rows [{custom_field|custom_field_uuid, value, value_type}]
|
|
140
|
+
* @param string|null $uploaderUuid the user a stored photo or signature is credited to
|
|
141
|
+
* @param string $under the body key the rows arrived under, which the
|
|
142
|
+
* 422 paths are reported against
|
|
143
|
+
*
|
|
144
|
+
* @throws ValidationException
|
|
145
|
+
*/
|
|
146
|
+
public static function applyCustomFieldValues(InspectionSubmission $submission, array $rows, ?string $uploaderUuid = null, string $under = 'custom_field_values'): array
|
|
147
|
+
{
|
|
148
|
+
$fields = CustomField::query()->where('subject_uuid', $submission->inspection_form_uuid)->where('for', InspectionForm::FIELD_FOR)->get();
|
|
149
|
+
$payload = [];
|
|
150
|
+
$errors = [];
|
|
151
|
+
|
|
152
|
+
foreach (array_values($rows) as $index => $row) {
|
|
153
|
+
$key = Arr::get($row, 'field', Arr::get($row, 'custom_field', Arr::get($row, 'custom_field_uuid')));
|
|
154
|
+
$field = static::findField($fields, $key);
|
|
155
|
+
if (!$field) {
|
|
156
|
+
$errors["{$under}.{$index}." . ($under === 'answers' ? 'field' : 'custom_field')] = ['The field "' . (is_scalar($key) ? $key : '?') . '" does not belong to this inspection form.'];
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
[$value, $valueType, $fieldErrors] = static::normalizeValue($field, Arr::get($row, 'value'), Arr::get($row, 'value_type'), $submission, $uploaderUuid);
|
|
161
|
+
foreach ($fieldErrors as $message) {
|
|
162
|
+
$errors["{$under}.{$index}.value"][] = $message;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
$payload[] = [
|
|
166
|
+
'custom_field_uuid' => $field->uuid,
|
|
167
|
+
'value' => $value,
|
|
168
|
+
'value_type' => $valueType,
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!empty($errors)) {
|
|
173
|
+
throw ValidationException::withMessages($errors);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// `custom_field_values.value` is a NOT NULL column, so an answer that
|
|
177
|
+
// is nothing is not an answer: it clears whatever was there instead.
|
|
178
|
+
$summary = $submission->syncCustomFieldValues($payload, ['treat_null_as_delete' => true]);
|
|
179
|
+
$submission->syncItemResultsFromCustomFieldValues();
|
|
180
|
+
$submission->syncResultCounts();
|
|
181
|
+
|
|
182
|
+
return $summary;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Finds a field of the form by uuid or, failing that, by its name. */
|
|
186
|
+
protected static function findField(Collection $fields, mixed $key): ?CustomField
|
|
187
|
+
{
|
|
188
|
+
if (!is_string($key) || $key === '') {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return $fields->first(fn (CustomField $field) => $field->uuid === $key)
|
|
193
|
+
?? $fields->first(fn (CustomField $field) => $field->public_id === $key)
|
|
194
|
+
?? $fields->first(fn (CustomField $field) => $field->name === $key);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The value as it is stored, its type, and anything wrong with it.
|
|
199
|
+
*
|
|
200
|
+
* @return array{0: mixed, 1: string, 2: string[]}
|
|
201
|
+
*/
|
|
202
|
+
protected static function normalizeValue(CustomField $field, mixed $value, mixed $valueType, InspectionSubmission $submission, ?string $uploaderUuid): array
|
|
203
|
+
{
|
|
204
|
+
$errors = [];
|
|
205
|
+
|
|
206
|
+
switch ($field->type) {
|
|
207
|
+
case 'pass-fail':
|
|
208
|
+
$answer = static::passFailAnswer($value);
|
|
209
|
+
$failed = !$answer['not_applicable'] && !filter_var($answer['passed'], FILTER_VALIDATE_BOOLEAN);
|
|
210
|
+
$meta = is_array($field->meta) ? $field->meta : [];
|
|
211
|
+
$photos = array_values(array_filter($answer['photos'], 'is_string'));
|
|
212
|
+
|
|
213
|
+
// What the field insists on is checked before anything is
|
|
214
|
+
// stored, so a refused answer leaves no orphan photo behind.
|
|
215
|
+
if ($failed) {
|
|
216
|
+
if (data_get($meta, 'require_comment_on_fail') && trim((string) $answer['comments']) === '') {
|
|
217
|
+
$errors[] = 'A comment is required when "' . $field->label . '" fails.';
|
|
218
|
+
}
|
|
219
|
+
if (data_get($meta, 'require_photo_on_fail') && empty($photos)) {
|
|
220
|
+
$errors[] = 'A photo is required when "' . $field->label . '" fails.';
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (!empty($errors)) {
|
|
225
|
+
return [$answer, 'object', $errors];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
$answer['photos'] = array_values(array_map(
|
|
229
|
+
fn ($photo) => InspectionFileStore::normalize($photo, $submission, InspectionFileStore::TYPE_PHOTO, $uploaderUuid),
|
|
230
|
+
$photos
|
|
231
|
+
));
|
|
232
|
+
|
|
233
|
+
if ($failed) {
|
|
234
|
+
$answer['severity'] = $answer['severity'] ?? data_get($meta, 'severity');
|
|
235
|
+
$answer['unsafe'] = filter_var($answer['unsafe'] ?? data_get($meta, 'unsafe_on_fail', false), FILTER_VALIDATE_BOOLEAN);
|
|
236
|
+
} else {
|
|
237
|
+
$answer['severity'] = null;
|
|
238
|
+
$answer['unsafe'] = false;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return [$answer, 'object', $errors];
|
|
242
|
+
|
|
243
|
+
case 'file-upload':
|
|
244
|
+
case 'signature':
|
|
245
|
+
$type = $field->type === 'signature' ? InspectionFileStore::TYPE_SIGNATURE : InspectionFileStore::TYPE_PHOTO;
|
|
246
|
+
|
|
247
|
+
return [InspectionFileStore::normalize($value, $submission, $type, $uploaderUuid), 'file', $errors];
|
|
248
|
+
|
|
249
|
+
case 'number':
|
|
250
|
+
return [$value === null || $value === '' ? null : (is_numeric($value) ? $value + 0 : $value), 'number', $errors];
|
|
251
|
+
|
|
252
|
+
case 'boolean':
|
|
253
|
+
return [filter_var($value, FILTER_VALIDATE_BOOLEAN), 'boolean', $errors];
|
|
254
|
+
|
|
255
|
+
default:
|
|
256
|
+
if (is_array($value)) {
|
|
257
|
+
return [$value, 'array', $errors];
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return [$value, is_string($valueType) && $valueType !== '' ? $valueType : 'text', $errors];
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* A pass-fail answer in one shape, whatever the client sent: an object,
|
|
266
|
+
* its JSON, a bare boolean, or the words "pass" / "fail".
|
|
267
|
+
*
|
|
268
|
+
* "Not applicable" is an answer of its own — the app sends it as
|
|
269
|
+
* `passed: true, not_applicable: true`, and it must not read as a pass
|
|
270
|
+
* once it is a result row, or a tail lift a rigid does not have would
|
|
271
|
+
* count towards the vehicle's clean record.
|
|
272
|
+
*/
|
|
273
|
+
public static function passFailAnswer(mixed $value): array
|
|
274
|
+
{
|
|
275
|
+
if (is_string($value) && Str::startsWith(trim($value), '{')) {
|
|
276
|
+
$decoded = json_decode($value, true);
|
|
277
|
+
$value = is_array($decoded) ? $decoded : $value;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (!is_array($value)) {
|
|
281
|
+
$passed = is_string($value) ? !in_array(Str::lower(trim($value)), ['fail', 'failed', 'false', '0', 'no'], true) : (bool) $value;
|
|
282
|
+
$value = ['passed' => $passed];
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
$notApplicable = filter_var($value['not_applicable'] ?? $value['na'] ?? false, FILTER_VALIDATE_BOOLEAN)
|
|
286
|
+
|| (array_key_exists('passed', $value) && $value['passed'] === null);
|
|
287
|
+
|
|
288
|
+
return [
|
|
289
|
+
'passed' => $notApplicable ? true : filter_var($value['passed'] ?? $value['pass'] ?? true, FILTER_VALIDATE_BOOLEAN),
|
|
290
|
+
'not_applicable' => $notApplicable,
|
|
291
|
+
'severity' => isset($value['severity']) ? (Str::slug((string) $value['severity']) ?: null) : null,
|
|
292
|
+
'comments' => isset($value['comments']) ? (string) $value['comments'] : null,
|
|
293
|
+
'photos' => is_array($value['photos'] ?? null) ? $value['photos'] : [],
|
|
294
|
+
'unsafe' => $value['unsafe'] ?? null,
|
|
295
|
+
];
|
|
296
|
+
}
|
|
297
|
+
}
|