@fleetbase/fleetops-engine 0.6.64 → 0.6.65
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 +7 -5
- package/addon/components/attachment-list.hbs +65 -0
- package/addon/components/attachment-list.js +8 -0
- package/addon/components/cell/attached-vehicle.hbs +1 -1
- package/addon/components/cell/attached-vehicle.js +3 -3
- package/addon/components/cell/driver-identity.js +4 -4
- package/addon/components/cell/driver-name.hbs +1 -1
- package/addon/components/cell/translated-value.hbs +9 -0
- package/addon/components/cell/translated-value.js +57 -0
- package/addon/components/contact/card.hbs +58 -0
- package/addon/components/contact/card.js +19 -0
- package/addon/components/contact/form.hbs +1 -1
- package/addon/components/contact/panel-header.hbs +1 -1
- package/addon/components/customer/form.hbs +2 -2
- package/addon/components/device/manager.hbs +26 -28
- package/addon/components/device/manager.js +28 -2
- package/addon/components/device/panel-tabs/vehicle.hbs +13 -13
- package/addon/components/device/panel-tabs/vehicle.js +8 -0
- package/addon/components/driver/card.hbs +24 -13
- package/addon/components/driver/card.js +20 -6
- package/addon/components/driver/form.hbs +3 -3
- package/addon/components/driver/panel-header.hbs +2 -2
- package/addon/components/driver/pill.hbs +2 -2
- package/addon/components/equipment/form.js +11 -4
- package/addon/components/equipment/pill.hbs +20 -0
- package/addon/components/equipment/pill.js +3 -0
- package/addon/components/filter/multi-model.hbs +19 -0
- package/addon/components/filter/multi-model.js +90 -0
- package/addon/components/fleet/driver-listing.hbs +1 -1
- package/addon/components/fleet/vehicle-listing.hbs +1 -1
- package/addon/components/fleet-panel/driver-listing.hbs +1 -1
- package/addon/components/fleet-panel/vehicle-listing.hbs +1 -1
- package/addon/components/layout/fleet-ops-sidebar.js +9 -7
- package/addon/components/maintenance/form.js +12 -4
- package/addon/components/maintenance-schedule/form.js +13 -7
- package/addon/components/map/leaflet-live-map.hbs +52 -0
- package/addon/components/map/order-list-overlay/order.hbs +4 -4
- package/addon/components/modals/attach-equipment.hbs +22 -0
- package/addon/components/modals/attach-equipment.js +3 -0
- package/addon/components/modals/attach-telematic-device.hbs +13 -8
- package/addon/components/modals/attach-telematic-device.js +11 -1
- package/addon/components/modals/attach-trailer.hbs +30 -0
- package/addon/components/modals/attach-trailer.js +3 -0
- package/addon/components/modals/contact-form.hbs +2 -2
- package/addon/components/modals/convert-customer-to-vendor.hbs +1 -1
- package/addon/components/modals/driver-form.hbs +2 -2
- package/addon/components/modals/select-trailer.hbs +35 -0
- package/addon/components/modals/select-trailer.js +3 -0
- package/addon/components/modals/vehicle-form.hbs +2 -2
- package/addon/components/orchestrator/resource-panel.hbs +2 -2
- package/addon/components/order/customer-avatar-stack.hbs +2 -2
- package/addon/components/order/details/detail.hbs +4 -4
- package/addon/components/order/details/payload.hbs +2 -2
- package/addon/components/order/kanban-card.hbs +4 -4
- package/addon/components/order-list-overlay/order.hbs +4 -4
- package/addon/components/trailer/card.hbs +68 -0
- package/addon/components/trailer/card.js +22 -0
- package/addon/components/trailer/details/connections.hbs +57 -0
- package/addon/components/trailer/details/connections.js +59 -0
- package/addon/components/trailer/details/equipment.hbs +25 -0
- package/addon/components/trailer/details/equipment.js +52 -0
- package/addon/components/trailer/details/maintenance-history.hbs +47 -0
- package/addon/components/trailer/details/maintenance-history.js +40 -0
- package/addon/components/trailer/details/schedules.hbs +45 -0
- package/addon/components/trailer/details/schedules.js +40 -0
- package/addon/components/trailer/details/work-orders.hbs +47 -0
- package/addon/components/trailer/details/work-orders.js +40 -0
- package/addon/components/trailer/details.hbs +399 -0
- package/addon/components/trailer/details.js +118 -0
- package/addon/components/trailer/form.hbs +447 -0
- package/addon/components/trailer/form.js +165 -0
- package/addon/components/trailer/panel-header.hbs +45 -0
- package/addon/components/trailer/panel-header.js +3 -0
- package/addon/components/trailer/pill.hbs +21 -0
- package/addon/components/trailer/pill.js +3 -0
- package/addon/components/vehicle/card.hbs +42 -11
- package/addon/components/vehicle/card.js +31 -0
- package/addon/components/vehicle/details/equipment.hbs +25 -0
- package/addon/components/vehicle/details/equipment.js +55 -0
- package/addon/components/vehicle/details/trailers.hbs +35 -0
- package/addon/components/vehicle/details/trailers.js +55 -0
- package/addon/components/vehicle/form.hbs +2 -2
- package/addon/components/vehicle/panel-header.hbs +2 -2
- package/addon/components/vehicle/pill.hbs +2 -2
- package/addon/components/vendor/card.hbs +58 -0
- package/addon/components/vendor/card.js +6 -0
- package/addon/components/vendor/panel-header.hbs +2 -2
- package/addon/components/vendor/personnel-manager.hbs +2 -2
- package/addon/components/work-order/form.js +12 -4
- package/addon/controllers/connectivity/devices/index/details/vehicle.js +11 -0
- package/addon/controllers/connectivity/devices/index/details.js +3 -3
- package/addon/controllers/connectivity/devices/index.js +1 -0
- package/addon/controllers/connectivity/telematics/details/attachments.js +28 -47
- package/addon/controllers/connectivity/telematics/details/devices.js +1 -0
- package/addon/controllers/management/contacts/customers.js +4 -0
- package/addon/controllers/management/contacts/index.js +32 -0
- package/addon/controllers/management/trailers/index/details.js +119 -0
- package/addon/controllers/management/trailers/index/edit.js +67 -0
- package/addon/controllers/management/trailers/index/new.js +43 -0
- package/addon/controllers/management/trailers/index.js +599 -0
- package/addon/controllers/management/vehicles/index/details.js +16 -0
- package/addon/controllers/management/vehicles/index.js +78 -4
- package/addon/controllers/management/vendors/index.js +32 -0
- package/addon/controllers/operations/orders/index.js +3 -1
- package/addon/controllers/settings/custom-fields.js +8 -0
- package/addon/extension.js +7 -0
- package/addon/helpers/placeholder-image.js +6 -0
- package/addon/helpers/resource-image.js +10 -0
- package/addon/helpers/trailer-placeholder-image.js +6 -0
- package/addon/routes/management/trailers/index/details/connections.js +2 -0
- package/addon/routes/management/trailers/index/details/devices.js +2 -0
- package/addon/routes/management/trailers/index/details/equipment.js +2 -0
- package/addon/routes/management/trailers/index/details/index.js +2 -0
- package/addon/routes/management/trailers/index/details/maintenance-history.js +2 -0
- package/addon/routes/management/trailers/index/details/positions.js +2 -0
- package/addon/routes/management/trailers/index/details/schedules.js +2 -0
- package/addon/routes/management/trailers/index/details/work-orders.js +2 -0
- package/addon/routes/management/trailers/index/details.js +30 -0
- package/addon/routes/management/trailers/index/edit.js +23 -0
- package/addon/routes/management/trailers/index/new.js +14 -0
- package/addon/routes/management/trailers/index.js +42 -0
- package/addon/routes/management/vehicles/index/details/trailers.js +2 -0
- package/addon/routes/management/vehicles/index.js +7 -1
- package/addon/routes.js +17 -0
- package/addon/services/device-actions.js +26 -16
- package/addon/services/trailer-actions.js +394 -0
- package/addon/services/vehicle-actions.js +111 -0
- package/addon/styles/fleetops-engine.css +349 -0
- package/addon/templates/connectivity/devices/index/details/vehicle.hbs +19 -19
- package/addon/templates/connectivity/telematics/details/attachments.hbs +15 -15
- package/addon/templates/management/contacts/customers.hbs +48 -29
- package/addon/templates/management/contacts/index.hbs +52 -33
- package/addon/templates/management/trailers/index/details/connections.hbs +1 -0
- package/addon/templates/management/trailers/index/details/devices.hbs +1 -0
- package/addon/templates/management/trailers/index/details/equipment.hbs +1 -0
- package/addon/templates/management/trailers/index/details/index.hbs +1 -0
- package/addon/templates/management/trailers/index/details/maintenance-history.hbs +1 -0
- package/addon/templates/management/trailers/index/details/positions.hbs +1 -0
- package/addon/templates/management/trailers/index/details/schedules.hbs +1 -0
- package/addon/templates/management/trailers/index/details/work-orders.hbs +1 -0
- package/addon/templates/management/trailers/index/details.hbs +15 -0
- package/addon/templates/management/trailers/index/edit.hbs +12 -0
- package/addon/templates/management/trailers/index/new.hbs +11 -0
- package/addon/templates/management/trailers/index.hbs +67 -0
- package/addon/templates/management/vehicles/index/details/equipment.hbs +1 -1
- package/addon/templates/management/vehicles/index/details/trailers.hbs +1 -0
- package/addon/templates/management/vehicles/index/details.hbs +1 -1
- package/addon/templates/management/vendors/index.hbs +66 -32
- package/addon/utils/device-table-columns.js +10 -6
- package/addon/utils/live-map-card-content.js +56 -0
- package/addon/utils/placeholder-images.js +71 -0
- package/addon/utils/trailer-placeholder-image.js +11 -0
- package/app/components/attachment-list.js +1 -0
- package/app/components/cell/translated-value.js +1 -0
- package/app/components/contact/card.js +1 -0
- package/app/components/equipment/pill.js +1 -0
- package/app/components/filter/multi-model.js +1 -0
- package/app/components/modals/attach-equipment.js +1 -0
- package/app/components/modals/attach-trailer.js +1 -0
- package/app/components/modals/select-trailer.js +1 -0
- package/app/components/trailer/card.js +1 -0
- package/app/components/trailer/details/connections.js +1 -0
- package/app/components/trailer/details/equipment.js +1 -0
- package/app/components/trailer/details/maintenance-history.js +1 -0
- package/app/components/trailer/details/schedules.js +1 -0
- package/app/components/trailer/details/work-orders.js +1 -0
- package/app/components/trailer/details.js +1 -0
- package/app/components/trailer/form.js +1 -0
- package/app/components/trailer/panel-header.js +1 -0
- package/app/components/trailer/pill.js +1 -0
- package/app/components/vehicle/details/equipment.js +1 -0
- package/app/components/vehicle/details/trailers.js +1 -0
- package/app/components/vendor/card.js +1 -0
- package/app/controllers/management/trailers/index/details.js +1 -0
- package/app/controllers/management/trailers/index/edit.js +1 -0
- package/app/controllers/management/trailers/index/new.js +1 -0
- package/app/controllers/management/trailers/index.js +1 -0
- package/app/helpers/placeholder-image.js +1 -0
- package/app/helpers/resource-image.js +1 -0
- package/app/helpers/trailer-placeholder-image.js +1 -0
- package/app/routes/management/trailers/index/details/connections.js +1 -0
- package/app/routes/management/trailers/index/details/devices.js +1 -0
- package/app/routes/management/trailers/index/details/equipment.js +1 -0
- package/app/routes/management/trailers/index/details/index.js +1 -0
- package/app/routes/management/trailers/index/details/maintenance-history.js +1 -0
- package/app/routes/management/trailers/index/details/positions.js +1 -0
- package/app/routes/management/trailers/index/details/schedules.js +1 -0
- package/app/routes/management/trailers/index/details/work-orders.js +1 -0
- package/app/routes/management/trailers/index/details.js +1 -0
- package/app/routes/management/trailers/index/edit.js +1 -0
- package/app/routes/management/trailers/index/new.js +1 -0
- package/app/routes/management/trailers/index.js +1 -0
- package/app/routes/management/vehicles/index/details/trailers.js +1 -0
- package/app/services/trailer-actions.js +1 -0
- package/app/templates/management/trailers/index/details/connections.js +1 -0
- package/app/templates/management/trailers/index/details/devices.js +1 -0
- package/app/templates/management/trailers/index/details/equipment.js +1 -0
- package/app/templates/management/trailers/index/details/index.js +1 -0
- package/app/templates/management/trailers/index/details/maintenance-history.js +1 -0
- package/app/templates/management/trailers/index/details/positions.js +1 -0
- package/app/templates/management/trailers/index/details/schedules.js +1 -0
- package/app/templates/management/trailers/index/details/work-orders.js +1 -0
- package/app/templates/management/trailers/index/details.js +1 -0
- package/app/templates/management/trailers/index/edit.js +1 -0
- package/app/templates/management/trailers/index/new.js +1 -0
- package/app/templates/management/trailers/index.js +1 -0
- package/app/templates/management/vehicles/index/details/trailers.js +1 -0
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +1 -1
- package/server/migrations/2026_09_03_000001_add_first_class_trailer_columns_to_assets_table.php +58 -0
- package/server/migrations/2026_09_03_000002_create_asset_connections_table.php +43 -0
- package/server/migrations/2026_09_03_000003_create_device_installations_table.php +33 -0
- package/server/src/Auth/Schemas/FleetOps.php +7 -0
- package/server/src/Events/TrailerLocationChanged.php +70 -0
- package/server/src/Exceptions/DeviceAlreadyAttachedException.php +18 -0
- package/server/src/Exports/TrailerExport.php +31 -0
- package/server/src/Http/Controllers/Api/v1/Concerns/ResolvesFleetOpsApiResources.php +8 -2
- package/server/src/Http/Controllers/Api/v1/DeviceController.php +22 -15
- package/server/src/Http/Controllers/Api/v1/EquipmentController.php +47 -0
- package/server/src/Http/Controllers/Api/v1/TrailerController.php +362 -0
- package/server/src/Http/Controllers/Api/v1/VehicleController.php +1 -0
- package/server/src/Http/Controllers/Internal/v1/DeviceController.php +3 -0
- package/server/src/Http/Controllers/Internal/v1/LiveController.php +1 -1
- package/server/src/Http/Controllers/Internal/v1/SearchController.php +16 -0
- package/server/src/Http/Controllers/Internal/v1/TrailerController.php +360 -0
- package/server/src/Http/Controllers/Internal/v1/VehicleController.php +74 -0
- package/server/src/Http/Filter/EquipmentFilter.php +51 -0
- package/server/src/Http/Filter/OrderFilter.php +15 -0
- package/server/src/Http/Filter/TrailerFilter.php +269 -0
- package/server/src/Http/Filter/VehicleFilter.php +70 -3
- package/server/src/Http/Requests/CreateDeviceRequest.php +1 -1
- package/server/src/Http/Requests/CreateEquipmentRequest.php +1 -1
- package/server/src/Http/Requests/CreateTrailerRequest.php +54 -0
- package/server/src/Http/Requests/UpdateTrailerRequest.php +7 -0
- package/server/src/Http/Resources/v1/AssetConnection.php +90 -0
- package/server/src/Http/Resources/v1/Device.php +3 -1
- package/server/src/Http/Resources/v1/Equipment.php +3 -1
- package/server/src/Http/Resources/v1/Index/Vehicle.php +10 -0
- package/server/src/Http/Resources/v1/Trailer.php +199 -0
- package/server/src/Http/Resources/v1/Vehicle.php +2 -0
- package/server/src/Http/Resources/v1/VehicleWithoutDriver.php +3 -0
- package/server/src/Imports/TrailerImport.php +33 -0
- package/server/src/Models/Asset.php +39 -10
- package/server/src/Models/AssetConnection.php +43 -0
- package/server/src/Models/Device.php +39 -8
- package/server/src/Models/DeviceInstallation.php +27 -0
- package/server/src/Models/Equipment.php +2 -0
- package/server/src/Models/Trailer.php +181 -0
- package/server/src/Models/Vehicle.php +13 -0
- package/server/src/Providers/FleetOpsServiceProvider.php +4 -2
- package/server/src/Support/Ai/FleetOpsAiQueryResources.php +22 -0
- package/server/src/Support/Reporting/FleetOpsReportSchema.php +38 -0
- package/server/src/Support/Telematics/TelematicService.php +35 -0
- package/server/src/Support/TrailerSummary.php +35 -0
- package/server/src/routes.php +29 -0
- package/server/tests/CompactResourceSerializationTest.php +36 -0
- package/server/tests/ControllerFilterContractsTest.php +29 -0
- package/server/tests/Feature/Http/Api/DeviceControllerContractsTest.php +30 -13
- package/server/tests/Feature/Http/Api/TrailerControllerLifecycleTest.php +640 -0
- package/server/tests/Feature/Http/Internal/DeviceControllerContractsTest.php +20 -5
- package/server/tests/Feature/Http/Internal/LiveControllerEndpointsTest.php +19 -0
- package/server/tests/ModelAccessorContractsTest.php +10 -0
- package/server/tests/OrderFilterExecutionTest.php +5 -0
- package/server/tests/PublicApiControllerInputContractsTest.php +11 -0
- package/server/tests/PublicFleetOpsRestEndpointsTest.php +15 -3
- package/server/tests/ReportSchemaContractsTest.php +4 -0
- package/server/tests/TelematicsHardeningTest.php +4 -2
- package/server/tests/TrailerSupportCoverageTest.php +524 -0
- package/server/tests/Unit/Http/Resources/IndexVehicleResourceTest.php +35 -0
- package/server/tests/Unit/Models/EquipmentTest.php +22 -0
- package/server/tests/Unit/Models/ModelLookupFallbackSeamsTest.php +7 -3
- package/server/tests/Unit/Models/TrailerTest.php +204 -0
- package/server/tests/Unit/Support/Telematics/TelematicServiceTelemetryTest.php +93 -0
- package/server/tests/VehicleControllerHelperContractsTest.php +14 -0
- package/translations/ar-ae.yml +396 -0
- package/translations/bg-bg.yaml +424 -0
- package/translations/en-us.yaml +423 -0
- package/translations/es-pa.yaml +425 -0
- package/translations/fr-fr.yaml +424 -0
- package/translations/mn-mn.yaml +424 -0
- package/translations/pt-br.yaml +424 -0
- package/translations/ru-ru.yaml +424 -0
- package/translations/vi-vn.yaml +435 -0
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import ResourceActionService, { inject as service } from '@fleetbase/ember-core/services/resource-action';
|
|
2
|
+
import leafletIcon from '@fleetbase/ember-core/utils/leaflet-icon';
|
|
3
|
+
import config from 'ember-get-config';
|
|
4
|
+
import { action } from '@ember/object';
|
|
5
|
+
import { isArray } from '@ember/array';
|
|
6
|
+
import { dasherize } from '@ember/string';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Trailer resource actions.
|
|
10
|
+
*
|
|
11
|
+
* Mirrors the Vehicle action service so Trailers behave like every other first-class
|
|
12
|
+
* Fleet-Ops resource: route transitions, context panels, modals, and the towing,
|
|
13
|
+
* device, equipment and maintenance actions that are specific to trailers.
|
|
14
|
+
*/
|
|
15
|
+
export default class TrailerActionsService extends ResourceActionService {
|
|
16
|
+
@service('universe/menu-service') menuService;
|
|
17
|
+
@service fetch;
|
|
18
|
+
@service maintenanceScheduleActions;
|
|
19
|
+
@service workOrderActions;
|
|
20
|
+
@service maintenanceActions;
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments);
|
|
24
|
+
this.initialize('trailer', {
|
|
25
|
+
defaultAttributes: {
|
|
26
|
+
status: 'available',
|
|
27
|
+
asset_class: 'trailer',
|
|
28
|
+
measurement_system: 'metric',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
get registeredTabs() {
|
|
34
|
+
const registeredTabs = this.menuService.getMenuItems('fleet-ops:component:trailer:details');
|
|
35
|
+
|
|
36
|
+
return (isArray(registeredTabs) ? registeredTabs : [])
|
|
37
|
+
.map((tab) => {
|
|
38
|
+
delete tab.route;
|
|
39
|
+
if (!tab.key) {
|
|
40
|
+
tab.key = tab.id ?? dasherize(tab.label ?? tab.title);
|
|
41
|
+
}
|
|
42
|
+
return tab;
|
|
43
|
+
})
|
|
44
|
+
.filter((tab) => !tab.component);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
get panelTabs() {
|
|
48
|
+
return [
|
|
49
|
+
{ key: 'overview', label: this.intl.t('trailer.tabs.overview'), component: 'trailer/details' },
|
|
50
|
+
{ key: 'positions', label: this.intl.t('trailer.tabs.positions'), component: 'positions-replay' },
|
|
51
|
+
{ key: 'devices', label: this.intl.t('trailer.tabs.devices'), component: 'device/manager' },
|
|
52
|
+
{ key: 'equipment', label: this.intl.t('trailer.tabs.equipment'), component: 'trailer/details/equipment' },
|
|
53
|
+
{ key: 'connections', label: this.intl.t('trailer.tabs.connections'), component: 'trailer/details/connections' },
|
|
54
|
+
{ key: 'schedules', label: this.intl.t('trailer.tabs.schedules'), component: 'trailer/details/schedules' },
|
|
55
|
+
{ key: 'work-orders', label: this.intl.t('trailer.tabs.work-orders'), component: 'trailer/details/work-orders' },
|
|
56
|
+
{ key: 'maintenance-history', label: this.intl.t('trailer.tabs.maintenance'), component: 'trailer/details/maintenance-history' },
|
|
57
|
+
...this.registeredTabs,
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async resolveTrailerResource(trailer) {
|
|
62
|
+
if (typeof trailer?.then === 'function') {
|
|
63
|
+
return await trailer;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (typeof trailer?.loadResource === 'function') {
|
|
67
|
+
return (await trailer.loadResource()) ?? trailer;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return trailer;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
trailerName(trailer) {
|
|
74
|
+
return trailer?.displayName ?? trailer?.display_name ?? trailer?.name ?? trailer?.public_id ?? this.intl.t('resource.trailer');
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
vehicleName(vehicle) {
|
|
78
|
+
return vehicle?.displayName ?? vehicle?.display_name ?? vehicle?.name ?? vehicle?.plate_number ?? this.intl.t('resource.vehicle');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
transition = {
|
|
82
|
+
view: (trailer) => this.transitionTo('management.trailers.index.details', trailer),
|
|
83
|
+
edit: (trailer) => this.transitionTo('management.trailers.index.edit', trailer),
|
|
84
|
+
create: () => this.transitionTo('management.trailers.index.new'),
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
panel = {
|
|
88
|
+
create: (attributes = {}, options = {}) => {
|
|
89
|
+
const trailer = this.createNewInstance(attributes);
|
|
90
|
+
|
|
91
|
+
return this.resourceContextPanel.open({
|
|
92
|
+
content: 'trailer/form',
|
|
93
|
+
title: this.intl.t('common.create-a-new-resource', { resource: this.intl.t('resource.trailer')?.toLowerCase() }),
|
|
94
|
+
saveOptions: { callback: this.refresh },
|
|
95
|
+
useDefaultSaveTask: true,
|
|
96
|
+
trailer,
|
|
97
|
+
...options,
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
edit: async (trailer, options = {}) => {
|
|
101
|
+
trailer = await this.resolveTrailerResource(trailer);
|
|
102
|
+
|
|
103
|
+
return this.resourceContextPanel.open({
|
|
104
|
+
content: 'trailer/form',
|
|
105
|
+
title: this.intl.t('common.edit-resource-name', { resourceName: this.trailerName(trailer) }),
|
|
106
|
+
actionButtons: [
|
|
107
|
+
{
|
|
108
|
+
icon: 'eye',
|
|
109
|
+
fn: async () => {
|
|
110
|
+
await this.resourceContextPanel.closeAll();
|
|
111
|
+
this.panel.view(trailer);
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
useDefaultSaveTask: true,
|
|
116
|
+
trailer,
|
|
117
|
+
...options,
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
view: async (trailer, options = {}) => {
|
|
121
|
+
trailer = await this.resolveTrailerResource(trailer);
|
|
122
|
+
|
|
123
|
+
return this.resourceContextPanel.open({
|
|
124
|
+
trailer,
|
|
125
|
+
header: 'trailer/panel-header',
|
|
126
|
+
actionButtons: [
|
|
127
|
+
{
|
|
128
|
+
icon: 'pencil',
|
|
129
|
+
fn: async () => {
|
|
130
|
+
await this.resourceContextPanel.closeAll();
|
|
131
|
+
this.panel.edit(trailer);
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
tabs: this.panelTabs,
|
|
136
|
+
...options,
|
|
137
|
+
});
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
modal = {
|
|
142
|
+
create: (attributes = {}, options = {}, saveOptions = {}) => {
|
|
143
|
+
const trailer = this.createNewInstance(attributes);
|
|
144
|
+
|
|
145
|
+
return this.modalsManager.show('modals/resource', {
|
|
146
|
+
resource: trailer,
|
|
147
|
+
title: this.intl.t('common.create-a-new-resource', { resource: this.intl.t('resource.trailer')?.toLowerCase() }),
|
|
148
|
+
acceptButtonText: this.intl.t('common.create-resource', { resource: this.intl.t('resource.trailer') }),
|
|
149
|
+
component: 'trailer/form',
|
|
150
|
+
confirm: (modal) => this.modalTask.perform(modal, 'saveTask', trailer, { refresh: true, ...saveOptions }),
|
|
151
|
+
...options,
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
edit: async (trailer, options = {}, saveOptions = {}) => {
|
|
155
|
+
trailer = await this.resolveTrailerResource(trailer);
|
|
156
|
+
|
|
157
|
+
return this.modalsManager.show('modals/resource', {
|
|
158
|
+
resource: trailer,
|
|
159
|
+
title: this.intl.t('common.edit-resource-name', { resourceName: this.trailerName(trailer) }),
|
|
160
|
+
acceptButtonText: this.intl.t('common.save-changes'),
|
|
161
|
+
saveButtonIcon: 'save',
|
|
162
|
+
component: 'trailer/form',
|
|
163
|
+
confirm: (modal) => this.modalTask.perform(modal, 'saveTask', trailer, { refresh: true, ...saveOptions }),
|
|
164
|
+
...options,
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
view: async (trailer, options = {}) => {
|
|
168
|
+
trailer = await this.resolveTrailerResource(trailer);
|
|
169
|
+
|
|
170
|
+
return this.modalsManager.show('modals/resource', {
|
|
171
|
+
resource: trailer,
|
|
172
|
+
title: this.trailerName(trailer),
|
|
173
|
+
component: 'trailer/details',
|
|
174
|
+
...options,
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Couple the trailer to a vehicle. The modal collects the vehicle and the towing
|
|
181
|
+
* position; the server enforces single-attachment and position conflicts.
|
|
182
|
+
*/
|
|
183
|
+
@action attachVehicle(trailer, options = {}) {
|
|
184
|
+
const trailerName = this.trailerName(trailer);
|
|
185
|
+
|
|
186
|
+
this.modalsManager.show('modals/attach-trailer', {
|
|
187
|
+
title: this.intl.t('trailer.prompts.attach-vehicle-title', { trailerName }),
|
|
188
|
+
acceptButtonText: this.intl.t('trailer.actions.attach-vehicle'),
|
|
189
|
+
acceptButtonIcon: 'link',
|
|
190
|
+
trailer,
|
|
191
|
+
selectedVehicle: null,
|
|
192
|
+
position: 1,
|
|
193
|
+
confirm: async (modal) => {
|
|
194
|
+
const vehicle = modal.getOption('selectedVehicle');
|
|
195
|
+
const position = Number(modal.getOption('position')) || 1;
|
|
196
|
+
|
|
197
|
+
if (!vehicle) {
|
|
198
|
+
return this.notifications.warning(this.intl.t('trailer.prompts.select-vehicle-warning'));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
modal.startLoading();
|
|
202
|
+
|
|
203
|
+
try {
|
|
204
|
+
await this.fetch.post(`trailers/${trailer.id}/attach`, { vehicle: vehicle.id, position });
|
|
205
|
+
await trailer.reload?.();
|
|
206
|
+
this.notifications.success(this.intl.t('trailer.prompts.attach-vehicle-success', { trailerName, vehicleName: this.vehicleName(vehicle) }));
|
|
207
|
+
modal.done();
|
|
208
|
+
this.refresh();
|
|
209
|
+
options.callback?.(trailer, vehicle);
|
|
210
|
+
} catch (error) {
|
|
211
|
+
this.notifications.serverError(error);
|
|
212
|
+
modal.stopLoading();
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
...options,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* End the active towing connection. History is preserved server-side.
|
|
221
|
+
*/
|
|
222
|
+
@action detachVehicle(trailer, options = {}) {
|
|
223
|
+
const trailerName = this.trailerName(trailer);
|
|
224
|
+
const vehicleName = trailer.current_vehicle_name ?? this.vehicleName(trailer.current_vehicle);
|
|
225
|
+
|
|
226
|
+
if (!trailer.isAttached && trailer.attachment_state !== 'attached') {
|
|
227
|
+
return this.notifications.warning(this.intl.t('trailer.prompts.not-attached-warning', { trailerName }));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return this.modalsManager.confirm({
|
|
231
|
+
title: this.intl.t('trailer.prompts.detach-vehicle-title', { trailerName }),
|
|
232
|
+
body: this.intl.t('trailer.prompts.detach-vehicle-body', { trailerName, vehicleName }),
|
|
233
|
+
acceptButtonText: this.intl.t('trailer.actions.detach-vehicle'),
|
|
234
|
+
acceptButtonIcon: 'unlink',
|
|
235
|
+
acceptButtonScheme: 'danger',
|
|
236
|
+
confirm: async (modal) => {
|
|
237
|
+
modal.startLoading();
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
await this.fetch.post(`trailers/${trailer.id}/detach`);
|
|
241
|
+
await trailer.reload?.();
|
|
242
|
+
this.notifications.success(this.intl.t('trailer.prompts.detach-vehicle-success', { trailerName, vehicleName }));
|
|
243
|
+
modal.done();
|
|
244
|
+
this.refresh();
|
|
245
|
+
options.callback?.(trailer);
|
|
246
|
+
} catch (error) {
|
|
247
|
+
this.notifications.serverError(error);
|
|
248
|
+
modal.stopLoading();
|
|
249
|
+
}
|
|
250
|
+
},
|
|
251
|
+
...options,
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
@action attachDevice(trailer, options = {}) {
|
|
256
|
+
const trailerName = this.trailerName(trailer);
|
|
257
|
+
|
|
258
|
+
this.modalsManager.show('modals/attach-device', {
|
|
259
|
+
title: this.intl.t('trailer.prompts.attach-device-title', { trailerName }),
|
|
260
|
+
acceptButtonText: this.intl.t('trailer.actions.attach-device'),
|
|
261
|
+
acceptButtonIcon: 'link',
|
|
262
|
+
selectedDevice: null,
|
|
263
|
+
trailer,
|
|
264
|
+
confirm: async (modal) => {
|
|
265
|
+
const selectedDevice = modal.getOption('selectedDevice');
|
|
266
|
+
|
|
267
|
+
if (!selectedDevice) {
|
|
268
|
+
return this.notifications.warning(this.intl.t('trailer.prompts.select-device-warning'));
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
modal.startLoading();
|
|
272
|
+
|
|
273
|
+
try {
|
|
274
|
+
await this.fetch.post(`trailers/${trailer.id}/attach-device`, { device: selectedDevice.id });
|
|
275
|
+
await trailer.reload?.();
|
|
276
|
+
this.notifications.success(this.intl.t('trailer.prompts.attach-device-success', { trailerName }));
|
|
277
|
+
modal.done();
|
|
278
|
+
this.refresh();
|
|
279
|
+
options.callback?.(trailer, selectedDevice);
|
|
280
|
+
} catch (error) {
|
|
281
|
+
this.notifications.serverError(error);
|
|
282
|
+
modal.stopLoading();
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
...options,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
@action attachEquipment(trailer, options = {}) {
|
|
290
|
+
const trailerName = this.trailerName(trailer);
|
|
291
|
+
|
|
292
|
+
this.modalsManager.show('modals/attach-equipment', {
|
|
293
|
+
title: this.intl.t('trailer.prompts.attach-equipment-title', { resourceName: trailerName }),
|
|
294
|
+
acceptButtonText: this.intl.t('trailer.actions.attach-equipment'),
|
|
295
|
+
acceptButtonIcon: 'link',
|
|
296
|
+
selectedEquipment: null,
|
|
297
|
+
trailer,
|
|
298
|
+
confirm: async (modal) => {
|
|
299
|
+
const equipment = modal.getOption('selectedEquipment');
|
|
300
|
+
|
|
301
|
+
if (!equipment) {
|
|
302
|
+
return this.notifications.warning(this.intl.t('trailer.prompts.select-equipment-warning'));
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
modal.startLoading();
|
|
306
|
+
|
|
307
|
+
try {
|
|
308
|
+
await this.fetch.post(`trailers/${trailer.id}/attach-equipment`, { equipment: equipment.id });
|
|
309
|
+
await trailer.reload?.();
|
|
310
|
+
this.notifications.success(this.intl.t('trailer.prompts.attach-equipment-success', { equipmentName: equipment.name, resourceName: trailerName }));
|
|
311
|
+
modal.done();
|
|
312
|
+
this.refresh();
|
|
313
|
+
options.callback?.(trailer, equipment);
|
|
314
|
+
} catch (error) {
|
|
315
|
+
this.notifications.serverError(error);
|
|
316
|
+
modal.stopLoading();
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
...options,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
@action detachEquipment(trailer, equipment, options = {}) {
|
|
324
|
+
const trailerName = this.trailerName(trailer);
|
|
325
|
+
const equipmentName = equipment?.name ?? equipment?.public_id ?? this.intl.t('resource.equipment');
|
|
326
|
+
|
|
327
|
+
return this.modalsManager.confirm({
|
|
328
|
+
title: this.intl.t('trailer.prompts.detach-equipment-title', { equipmentName }),
|
|
329
|
+
body: this.intl.t('trailer.prompts.detach-equipment-body', { equipmentName, resourceName: trailerName }),
|
|
330
|
+
acceptButtonText: this.intl.t('trailer.actions.detach-equipment'),
|
|
331
|
+
acceptButtonIcon: 'unlink',
|
|
332
|
+
acceptButtonScheme: 'danger',
|
|
333
|
+
confirm: async (modal) => {
|
|
334
|
+
modal.startLoading();
|
|
335
|
+
|
|
336
|
+
try {
|
|
337
|
+
await this.fetch.post(`trailers/${trailer.id}/detach-equipment`, { equipment: equipment.id });
|
|
338
|
+
await trailer.reload?.();
|
|
339
|
+
this.notifications.success(this.intl.t('trailer.prompts.detach-equipment-success', { equipmentName, resourceName: trailerName }));
|
|
340
|
+
modal.done();
|
|
341
|
+
this.refresh();
|
|
342
|
+
options.callback?.(trailer, equipment);
|
|
343
|
+
} catch (error) {
|
|
344
|
+
this.notifications.serverError(error);
|
|
345
|
+
modal.stopLoading();
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
...options,
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
@action locate(trailer, options = {}) {
|
|
353
|
+
const { latitude, longitude, location } = trailer;
|
|
354
|
+
const trailerName = this.trailerName(trailer);
|
|
355
|
+
|
|
356
|
+
if (!trailer.hasValidCoordinates) {
|
|
357
|
+
return this.notifications.warning(this.intl.t('trailer.prompts.no-location-warning', { trailerName }));
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
this.modalsManager.show('modals/point-map', {
|
|
361
|
+
title: this.intl.t('common.resource-location', { resource: trailerName }),
|
|
362
|
+
acceptButtonText: this.intl.t('common.done'),
|
|
363
|
+
hideDeclineButton: true,
|
|
364
|
+
resource: trailer,
|
|
365
|
+
popupText: `${trailerName} (${trailer.public_id})`,
|
|
366
|
+
icon: leafletIcon({
|
|
367
|
+
iconUrl: trailer.photo_url ?? config?.defaultValues?.vehicleAvatar,
|
|
368
|
+
iconSize: [40, 40],
|
|
369
|
+
}),
|
|
370
|
+
latitude,
|
|
371
|
+
longitude,
|
|
372
|
+
location,
|
|
373
|
+
...options,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
@action async scheduleMaintenance(trailer, options = {}, saveOptions = {}) {
|
|
378
|
+
trailer = await this.resolveTrailerResource(trailer);
|
|
379
|
+
|
|
380
|
+
return this.maintenanceScheduleActions.modal.create({ subject: trailer }, options, saveOptions);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
@action async createWorkOrder(trailer, options = {}, saveOptions = {}) {
|
|
384
|
+
trailer = await this.resolveTrailerResource(trailer);
|
|
385
|
+
|
|
386
|
+
return this.workOrderActions.modal.create({ target: trailer }, options, saveOptions);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
@action async logMaintenance(trailer, options = {}, saveOptions = {}) {
|
|
390
|
+
trailer = await this.resolveTrailerResource(trailer);
|
|
391
|
+
|
|
392
|
+
return this.maintenanceActions.modal.create({ maintainable: trailer }, options, saveOptions);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
@@ -42,6 +42,16 @@ export default class VehicleActionsService extends ResourceActionService {
|
|
|
42
42
|
label: 'Devices',
|
|
43
43
|
component: 'device/manager',
|
|
44
44
|
},
|
|
45
|
+
{
|
|
46
|
+
key: 'trailers',
|
|
47
|
+
label: this.intl.t('resource.trailers'),
|
|
48
|
+
component: 'vehicle/details/trailers',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
key: 'equipment',
|
|
52
|
+
label: this.intl.t('resource.equipment'),
|
|
53
|
+
component: 'vehicle/details/equipment',
|
|
54
|
+
},
|
|
45
55
|
{
|
|
46
56
|
key: 'schedules',
|
|
47
57
|
label: 'Schedules',
|
|
@@ -229,6 +239,107 @@ export default class VehicleActionsService extends ResourceActionService {
|
|
|
229
239
|
});
|
|
230
240
|
}
|
|
231
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Couple a detached trailer to this vehicle. Attachment is owned by the trailer
|
|
244
|
+
* endpoint so the single-attachment and towing-position rules apply uniformly.
|
|
245
|
+
*/
|
|
246
|
+
@action attachTrailer(vehicle, options = {}) {
|
|
247
|
+
const vehicleName = vehicle.displayName ?? vehicle.display_name ?? vehicle.name;
|
|
248
|
+
|
|
249
|
+
this.modalsManager.show('modals/select-trailer', {
|
|
250
|
+
title: this.intl.t('vehicle.prompts.attach-trailer-title', { vehicleName }),
|
|
251
|
+
acceptButtonText: this.intl.t('vehicle.actions.attach-trailer'),
|
|
252
|
+
acceptButtonIcon: 'link',
|
|
253
|
+
vehicle,
|
|
254
|
+
selectedTrailer: null,
|
|
255
|
+
position: 1,
|
|
256
|
+
confirm: async (modal) => {
|
|
257
|
+
const trailer = modal.getOption('selectedTrailer');
|
|
258
|
+
const position = Number(modal.getOption('position')) || 1;
|
|
259
|
+
|
|
260
|
+
if (!trailer) {
|
|
261
|
+
return this.notifications.warning(this.intl.t('vehicle.prompts.select-trailer-warning'));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
modal.startLoading();
|
|
265
|
+
|
|
266
|
+
try {
|
|
267
|
+
await this.fetch.post(`trailers/${trailer.id}/attach`, { vehicle: vehicle.id, position });
|
|
268
|
+
await trailer.reload?.();
|
|
269
|
+
this.notifications.success(this.intl.t('vehicle.prompts.attach-trailer-success', { trailerName: trailer.displayName ?? trailer.name, vehicleName }));
|
|
270
|
+
modal.done();
|
|
271
|
+
this.refresh();
|
|
272
|
+
options.callback?.(vehicle, trailer);
|
|
273
|
+
} catch (error) {
|
|
274
|
+
this.notifications.serverError(error);
|
|
275
|
+
modal.stopLoading();
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
...options,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@action attachEquipment(vehicle, options = {}) {
|
|
283
|
+
const vehicleName = vehicle.displayName ?? vehicle.display_name ?? vehicle.name;
|
|
284
|
+
|
|
285
|
+
this.modalsManager.show('modals/attach-equipment', {
|
|
286
|
+
title: this.intl.t('trailer.prompts.attach-equipment-title', { resourceName: vehicleName }),
|
|
287
|
+
acceptButtonText: this.intl.t('vehicle.actions.attach-equipment'),
|
|
288
|
+
acceptButtonIcon: 'link',
|
|
289
|
+
vehicle,
|
|
290
|
+
selectedEquipment: null,
|
|
291
|
+
confirm: async (modal) => {
|
|
292
|
+
const equipment = modal.getOption('selectedEquipment');
|
|
293
|
+
|
|
294
|
+
if (!equipment) {
|
|
295
|
+
return this.notifications.warning(this.intl.t('trailer.prompts.select-equipment-warning'));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
modal.startLoading();
|
|
299
|
+
|
|
300
|
+
try {
|
|
301
|
+
await this.fetch.post(`vehicles/${vehicle.id}/attach-equipment`, { equipment: equipment.id });
|
|
302
|
+
this.notifications.success(this.intl.t('trailer.prompts.attach-equipment-success', { equipmentName: equipment.name, resourceName: vehicleName }));
|
|
303
|
+
modal.done();
|
|
304
|
+
this.refresh();
|
|
305
|
+
options.callback?.(vehicle, equipment);
|
|
306
|
+
} catch (error) {
|
|
307
|
+
this.notifications.serverError(error);
|
|
308
|
+
modal.stopLoading();
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
...options,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
@action detachEquipment(vehicle, equipment, options = {}) {
|
|
316
|
+
const vehicleName = vehicle.displayName ?? vehicle.display_name ?? vehicle.name;
|
|
317
|
+
const equipmentName = equipment?.name ?? equipment?.public_id ?? this.intl.t('resource.equipment');
|
|
318
|
+
|
|
319
|
+
return this.modalsManager.confirm({
|
|
320
|
+
title: this.intl.t('trailer.prompts.detach-equipment-title', { equipmentName }),
|
|
321
|
+
body: this.intl.t('trailer.prompts.detach-equipment-body', { equipmentName, resourceName: vehicleName }),
|
|
322
|
+
acceptButtonText: this.intl.t('vehicle.actions.detach-equipment'),
|
|
323
|
+
acceptButtonIcon: 'unlink',
|
|
324
|
+
acceptButtonScheme: 'danger',
|
|
325
|
+
confirm: async (modal) => {
|
|
326
|
+
modal.startLoading();
|
|
327
|
+
|
|
328
|
+
try {
|
|
329
|
+
await this.fetch.post(`vehicles/${vehicle.id}/detach-equipment`, { equipment: equipment.id });
|
|
330
|
+
this.notifications.success(this.intl.t('trailer.prompts.detach-equipment-success', { equipmentName, resourceName: vehicleName }));
|
|
331
|
+
modal.done();
|
|
332
|
+
this.refresh();
|
|
333
|
+
options.callback?.(vehicle, equipment);
|
|
334
|
+
} catch (error) {
|
|
335
|
+
this.notifications.serverError(error);
|
|
336
|
+
modal.stopLoading();
|
|
337
|
+
}
|
|
338
|
+
},
|
|
339
|
+
...options,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
232
343
|
@action async unassignOrders(vehicle, options = {}) {
|
|
233
344
|
let response;
|
|
234
345
|
|