@fleetbase/fleetops-engine 0.6.36 → 0.6.38
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/addon/controllers/operations/orders/index/details.js +5 -0
- package/addon/extension.js +55 -1
- package/addon/routes/operations/orders/index/details/virtual.js +23 -0
- package/addon/routes.js +2 -0
- package/addon/templates/operations/orders/index/details/virtual.hbs +1 -0
- package/app/routes/operations/orders/index/details/virtual.js +1 -0
- package/app/templates/operations/orders/index/details/virtual.js +1 -0
- package/composer.json +1 -1
- package/extension.json +1 -1
- package/package.json +3 -3
- package/server/src/Http/Controllers/Internal/v1/DriverController.php +22 -0
- package/server/src/Http/Requests/Internal/CreateDriverRequest.php +2 -1
- package/server/src/Rules/ResolvableVehicle.php +90 -0
|
@@ -2,10 +2,12 @@ import Controller, { inject as controller } from '@ember/controller';
|
|
|
2
2
|
import { tracked } from '@glimmer/tracking';
|
|
3
3
|
import { inject as service } from '@ember/service';
|
|
4
4
|
import { action } from '@ember/object';
|
|
5
|
+
import { isArray } from '@ember/array';
|
|
5
6
|
import { task } from 'ember-concurrency';
|
|
6
7
|
|
|
7
8
|
export default class OperationsOrdersIndexDetailsController extends Controller {
|
|
8
9
|
@controller('operations.orders.index') index;
|
|
10
|
+
@service('universe/menu-service') menuService;
|
|
9
11
|
@service orderActions;
|
|
10
12
|
@service orderSocketEvents;
|
|
11
13
|
@service leafletMapManager;
|
|
@@ -16,11 +18,14 @@ export default class OperationsOrdersIndexDetailsController extends Controller {
|
|
|
16
18
|
@tracked routingControl;
|
|
17
19
|
|
|
18
20
|
get tabs() {
|
|
21
|
+
const registeredTabs = this.menuService.getMenuItems('fleet-ops:component:order:details');
|
|
19
22
|
return [
|
|
20
23
|
{
|
|
21
24
|
route: 'operations.orders.index.details.index',
|
|
22
25
|
label: 'Overview',
|
|
26
|
+
icon: 'folder-open',
|
|
23
27
|
},
|
|
28
|
+
...(isArray(registeredTabs) ? registeredTabs : []),
|
|
24
29
|
];
|
|
25
30
|
}
|
|
26
31
|
|
package/addon/extension.js
CHANGED
|
@@ -7,7 +7,61 @@ export default {
|
|
|
7
7
|
const widgetService = universe.getService('widget');
|
|
8
8
|
|
|
9
9
|
// Register header navigation
|
|
10
|
-
menuService.registerHeaderMenuItem('Fleet-Ops', 'console.fleet-ops', {
|
|
10
|
+
menuService.registerHeaderMenuItem('Fleet-Ops', 'console.fleet-ops', {
|
|
11
|
+
icon: 'route',
|
|
12
|
+
priority: 0,
|
|
13
|
+
description: 'Dispatch, fleet management, driver tracking, and logistics operations.',
|
|
14
|
+
shortcuts: [
|
|
15
|
+
{
|
|
16
|
+
title: 'Orders',
|
|
17
|
+
description: 'Create, dispatch, and track delivery orders in real time.',
|
|
18
|
+
icon: 'boxes-stacked',
|
|
19
|
+
route: 'console.fleet-ops.operations.orders',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
title: 'Places',
|
|
23
|
+
description: 'Manage saved locations, addresses, and points of interest.',
|
|
24
|
+
icon: 'location-dot',
|
|
25
|
+
route: 'console.fleet-ops.management.places',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
title: 'Drivers',
|
|
29
|
+
description: 'Manage driver profiles, assignments, and live locations.',
|
|
30
|
+
icon: 'id-card',
|
|
31
|
+
route: 'console.fleet-ops.management.drivers',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
title: 'Vehicles',
|
|
35
|
+
description: 'View and manage your vehicle fleet and telematics.',
|
|
36
|
+
icon: 'truck',
|
|
37
|
+
route: 'console.fleet-ops.management.vehicles',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: 'Fleets',
|
|
41
|
+
description: 'Organise drivers and vehicles into operational fleets.',
|
|
42
|
+
icon: 'layer-group',
|
|
43
|
+
route: 'console.fleet-ops.management.fleets',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: 'Service Rates',
|
|
47
|
+
description: 'Configure pricing rules and service rate cards.',
|
|
48
|
+
icon: 'tags',
|
|
49
|
+
route: 'console.fleet-ops.operations.service-rates',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
title: 'Devices',
|
|
53
|
+
description: 'Manage connected telematics devices and their sensor data.',
|
|
54
|
+
icon: 'microchip',
|
|
55
|
+
route: 'console.fleet-ops.connectivity.devices',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
title: 'Reports',
|
|
59
|
+
description: 'Generate and review operational analytics reports.',
|
|
60
|
+
icon: 'chart-bar',
|
|
61
|
+
route: 'console.fleet-ops.analytics.reports',
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
});
|
|
11
65
|
|
|
12
66
|
// Register admin sections
|
|
13
67
|
menuService.registerAdminMenuPanel(
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Route from '@ember/routing/route';
|
|
2
|
+
import { inject as service } from '@ember/service';
|
|
3
|
+
|
|
4
|
+
export default class OperationsOrdersIndexDetailsVirtualRoute extends Route {
|
|
5
|
+
@service universe;
|
|
6
|
+
@service('universe/menu-service') menuService;
|
|
7
|
+
|
|
8
|
+
queryParams = {
|
|
9
|
+
view: {
|
|
10
|
+
refreshModel: true,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
model({ section = null, slug }, transition) {
|
|
15
|
+
const view = this.universe.getViewFromTransition(transition);
|
|
16
|
+
return this.menuService.lookupMenuItem('fleet-ops:component:order:details', slug, view, section);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
setupController(controller) {
|
|
20
|
+
super.setupController(...arguments);
|
|
21
|
+
controller.resource = this.modelFor('operations.orders.index.details');
|
|
22
|
+
}
|
|
23
|
+
}
|
package/addon/routes.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable ember/no-shadow-route-definition */
|
|
1
2
|
import buildRoutes from 'ember-engines/routes';
|
|
2
3
|
|
|
3
4
|
export default buildRoutes(function () {
|
|
@@ -19,6 +20,7 @@ export default buildRoutes(function () {
|
|
|
19
20
|
this.route('new');
|
|
20
21
|
this.route('details', { path: '/:public_id' }, function () {
|
|
21
22
|
this.route('index', { path: '/' });
|
|
23
|
+
this.route('virtual', { path: '/:slug' });
|
|
22
24
|
});
|
|
23
25
|
});
|
|
24
26
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{{component (lazy-engine-component @model.component) resource=this.resource order=this.resource params=@model.componentParams}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/routes/operations/orders/index/details/virtual';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/templates/operations/orders/index/details/virtual';
|
package/composer.json
CHANGED
package/extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetbase/fleetops-engine",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.38",
|
|
4
4
|
"description": "Fleet & Transport Management Extension for Fleetbase",
|
|
5
5
|
"fleetbase": {
|
|
6
6
|
"route": "fleet-ops"
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/core": "^7.23.2",
|
|
45
|
-
"@fleetbase/ember-core": "^0.3.
|
|
46
|
-
"@fleetbase/ember-ui": "^0.3.
|
|
45
|
+
"@fleetbase/ember-core": "^0.3.17",
|
|
46
|
+
"@fleetbase/ember-ui": "^0.3.25",
|
|
47
47
|
"@fleetbase/fleetops-data": "^0.1.25",
|
|
48
48
|
"@fleetbase/leaflet-routing-machine": "^3.2.17",
|
|
49
49
|
"@fortawesome/ember-fontawesome": "^2.0.0",
|
|
@@ -45,6 +45,17 @@ class DriverController extends FleetOpsController
|
|
|
45
45
|
{
|
|
46
46
|
$input = $request->input('driver');
|
|
47
47
|
|
|
48
|
+
// Normalize vehicle field - the frontend may send the full vehicle object,
|
|
49
|
+
// a UUID string, or a public_id string. Normalize to a single identifier
|
|
50
|
+
// so the ResolvableVehicle rule can validate it correctly.
|
|
51
|
+
if (isset($input['vehicle']) && is_array($input['vehicle'])) {
|
|
52
|
+
$input['vehicle'] = data_get($input['vehicle'], 'id')
|
|
53
|
+
?? data_get($input['vehicle'], 'public_id')
|
|
54
|
+
?? data_get($input['vehicle'], 'uuid')
|
|
55
|
+
?? null;
|
|
56
|
+
$request->merge(['driver' => $input]);
|
|
57
|
+
}
|
|
58
|
+
|
|
48
59
|
// create validation request
|
|
49
60
|
$createDriverRequest = CreateDriverRequest::createFrom($request);
|
|
50
61
|
$rules = $createDriverRequest->rules();
|
|
@@ -262,6 +273,17 @@ class DriverController extends FleetOpsController
|
|
|
262
273
|
// get input data
|
|
263
274
|
$input = $request->input('driver');
|
|
264
275
|
|
|
276
|
+
// Normalize vehicle field - the frontend may send the full vehicle object,
|
|
277
|
+
// a UUID string, or a public_id string. Normalize to a single identifier
|
|
278
|
+
// so the ResolvableVehicle rule can validate it correctly.
|
|
279
|
+
if (isset($input['vehicle']) && is_array($input['vehicle'])) {
|
|
280
|
+
$input['vehicle'] = data_get($input['vehicle'], 'id')
|
|
281
|
+
?? data_get($input['vehicle'], 'public_id')
|
|
282
|
+
?? data_get($input['vehicle'], 'uuid')
|
|
283
|
+
?? null;
|
|
284
|
+
$request->merge(['driver' => $input]);
|
|
285
|
+
}
|
|
286
|
+
|
|
265
287
|
// create validation request
|
|
266
288
|
$updateDriverRequest = UpdateDriverRequest::createFrom($request);
|
|
267
289
|
$rules = $updateDriverRequest->rules();
|
|
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Http\Requests\Internal;
|
|
|
4
4
|
|
|
5
5
|
use Fleetbase\FleetOps\Http\Requests\CreateDriverRequest as CreateDriverApiRequest;
|
|
6
6
|
use Fleetbase\FleetOps\Rules\ResolvablePoint;
|
|
7
|
+
use Fleetbase\FleetOps\Rules\ResolvableVehicle;
|
|
7
8
|
use Fleetbase\Support\Auth;
|
|
8
9
|
use Illuminate\Validation\Rule;
|
|
9
10
|
|
|
@@ -49,7 +50,7 @@ class CreateDriverRequest extends CreateDriverApiRequest
|
|
|
49
50
|
'internal_id' => 'nullable|string|max:255',
|
|
50
51
|
'country' => 'nullable|string|size:2',
|
|
51
52
|
'city' => 'nullable|string|max:255',
|
|
52
|
-
'vehicle' => 'nullable
|
|
53
|
+
'vehicle' => ['nullable', new ResolvableVehicle()],
|
|
53
54
|
'status' => 'nullable|string|in:active,inactive',
|
|
54
55
|
'vendor' => 'nullable|exists:vendors,public_id',
|
|
55
56
|
'job' => 'nullable|exists:orders,public_id',
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Fleetbase\FleetOps\Rules;
|
|
4
|
+
|
|
5
|
+
use Fleetbase\FleetOps\Models\Vehicle;
|
|
6
|
+
use Illuminate\Contracts\Validation\Rule;
|
|
7
|
+
use Illuminate\Support\Str;
|
|
8
|
+
|
|
9
|
+
class ResolvableVehicle implements Rule
|
|
10
|
+
{
|
|
11
|
+
/**
|
|
12
|
+
* The resolved vehicle instance, if found.
|
|
13
|
+
*/
|
|
14
|
+
protected ?Vehicle $resolved = null;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Determine if the validation rule passes.
|
|
18
|
+
*
|
|
19
|
+
* Accepts:
|
|
20
|
+
* - A public_id string (e.g. "vehicle_abc123")
|
|
21
|
+
* - A UUID string (e.g. "550e8400-e29b-41d4-a716-446655440000")
|
|
22
|
+
* - An array/object containing an "id", "public_id", or "uuid" key
|
|
23
|
+
*
|
|
24
|
+
* @param string $attribute
|
|
25
|
+
*
|
|
26
|
+
* @return bool
|
|
27
|
+
*/
|
|
28
|
+
public function passes($attribute, $value)
|
|
29
|
+
{
|
|
30
|
+
$identifier = $this->extractIdentifier($value);
|
|
31
|
+
|
|
32
|
+
if (empty($identifier)) {
|
|
33
|
+
return true; // nullable — let the nullable rule handle empty values
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (Str::isUuid($identifier)) {
|
|
37
|
+
$this->resolved = Vehicle::where('uuid', $identifier)->first();
|
|
38
|
+
} else {
|
|
39
|
+
$this->resolved = Vehicle::where('public_id', $identifier)->first();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return $this->resolved !== null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get the validation error message.
|
|
47
|
+
*
|
|
48
|
+
* @return string
|
|
49
|
+
*/
|
|
50
|
+
public function message()
|
|
51
|
+
{
|
|
52
|
+
return 'The :attribute must be a valid vehicle public ID, UUID, or vehicle object.';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Extract a string identifier from the given value.
|
|
57
|
+
*
|
|
58
|
+
* Handles a plain string, an associative array, or a stdClass object.
|
|
59
|
+
*/
|
|
60
|
+
protected function extractIdentifier($value): ?string
|
|
61
|
+
{
|
|
62
|
+
if (is_string($value)) {
|
|
63
|
+
return $value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (is_array($value)) {
|
|
67
|
+
return data_get($value, 'id')
|
|
68
|
+
?? data_get($value, 'public_id')
|
|
69
|
+
?? data_get($value, 'uuid')
|
|
70
|
+
?? null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (is_object($value)) {
|
|
74
|
+
return data_get($value, 'id')
|
|
75
|
+
?? data_get($value, 'public_id')
|
|
76
|
+
?? data_get($value, 'uuid')
|
|
77
|
+
?? null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get the resolved Vehicle model instance after validation passes.
|
|
85
|
+
*/
|
|
86
|
+
public function getResolved(): ?Vehicle
|
|
87
|
+
{
|
|
88
|
+
return $this->resolved;
|
|
89
|
+
}
|
|
90
|
+
}
|