@fleetbase/fleetops-engine 0.1.7 → 0.1.9
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/components/live-map.js +4 -4
- package/addon/controllers/operations/orders/index/new.js +78 -11
- package/addon/controllers/operations/orders/index/view.js +39 -24
- package/addon/controllers/operations/orders/index.js +3 -3
- package/addon/engine.js +4 -0
- package/addon/routes/operations/orders/index/view.js +3 -1
- package/addon/templates/operations/orders/index/new.hbs +7 -7
- package/package.json +6 -8
- package/addon/services/engine-context.js +0 -17
- package/app/services/engine-context.js +0 -1
|
@@ -21,7 +21,7 @@ export default class LiveMapComponent extends Component {
|
|
|
21
21
|
@service notifications;
|
|
22
22
|
@service serviceAreas;
|
|
23
23
|
@service appCache;
|
|
24
|
-
@service
|
|
24
|
+
@service universe;
|
|
25
25
|
|
|
26
26
|
@tracked routes = [];
|
|
27
27
|
@tracked drivers = [];
|
|
@@ -80,7 +80,7 @@ export default class LiveMapComponent extends Component {
|
|
|
80
80
|
*/
|
|
81
81
|
@action async setupLiveMap() {
|
|
82
82
|
// trigger that initial coordinates have been set
|
|
83
|
-
this.
|
|
83
|
+
this.universe.trigger('livemap.loaded', this);
|
|
84
84
|
|
|
85
85
|
if (this.skipSetCoordinates === false) {
|
|
86
86
|
if (this.appCache.has(['map_latitude', 'map_longitude'])) {
|
|
@@ -101,7 +101,7 @@ export default class LiveMapComponent extends Component {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
// trigger that initial coordinates have been set
|
|
104
|
-
this.
|
|
104
|
+
this.universe.trigger('livemap.has_coordinates', { latitude: this.latitude, longitude: this.longitude });
|
|
105
105
|
|
|
106
106
|
this.routes = await this.fetchActiveRoutes();
|
|
107
107
|
this.drivers = await this.fetchActiveDrivers();
|
|
@@ -115,7 +115,7 @@ export default class LiveMapComponent extends Component {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// add context event
|
|
118
|
-
this.
|
|
118
|
+
this.universe.trigger('livemap.ready', this);
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
@action setMapReference(event) {
|
|
@@ -31,16 +31,81 @@ export default class OperationsOrdersIndexNewController extends Controller {
|
|
|
31
31
|
@controller('management.vendors.index') vendorsController;
|
|
32
32
|
@controller('operations.orders.index') ordersController;
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Inject the `modalsManager` service
|
|
36
|
+
*
|
|
37
|
+
* @var {Service}
|
|
38
|
+
*/
|
|
34
39
|
@service modalsManager;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Inject the `notifications` service
|
|
43
|
+
*
|
|
44
|
+
* @var {Service}
|
|
45
|
+
*/
|
|
35
46
|
@service notifications;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Inject the `loader` service
|
|
50
|
+
*
|
|
51
|
+
* @var {Service}
|
|
52
|
+
*/
|
|
36
53
|
@service loader;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Inject the `currentUser` service
|
|
57
|
+
*
|
|
58
|
+
* @var {Service}
|
|
59
|
+
*/
|
|
37
60
|
@service currentUser;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Inject the `hostRouter` service
|
|
64
|
+
*
|
|
65
|
+
* @var {Service}
|
|
66
|
+
*/
|
|
38
67
|
@service hostRouter;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Inject the `fileQueue` service
|
|
71
|
+
*
|
|
72
|
+
* @var {Service}
|
|
73
|
+
*/
|
|
39
74
|
@service fileQueue;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Inject the `fetch` service
|
|
78
|
+
*
|
|
79
|
+
* @var {Service}
|
|
80
|
+
*/
|
|
40
81
|
@service fetch;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Inject the `store` service
|
|
85
|
+
*
|
|
86
|
+
* @var {Service}
|
|
87
|
+
*/
|
|
41
88
|
@service store;
|
|
42
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Inject the `universe` service
|
|
92
|
+
*
|
|
93
|
+
* @var {Service}
|
|
94
|
+
*/
|
|
95
|
+
@service universe;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Create an OrderModel instance.
|
|
99
|
+
*
|
|
100
|
+
* @var {OrderModel}
|
|
101
|
+
*/
|
|
43
102
|
@tracked order = this.store.createRecord('order', { meta: [] });
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Create an PayloadModel instance.
|
|
106
|
+
*
|
|
107
|
+
* @var {OrderModel}
|
|
108
|
+
*/
|
|
44
109
|
@tracked payload = this.store.createRecord('payload');
|
|
45
110
|
@tracked driversQuery = {};
|
|
46
111
|
@tracked meta = [];
|
|
@@ -182,16 +247,6 @@ export default class OperationsOrdersIndexNewController extends Controller {
|
|
|
182
247
|
return groups;
|
|
183
248
|
}
|
|
184
249
|
|
|
185
|
-
@action dropdownAction(actionName, dd, ...params) {
|
|
186
|
-
if (typeof dd?.actions?.close === 'function') {
|
|
187
|
-
dd.actions.close();
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (typeof this[actionName] === 'function') {
|
|
191
|
-
this[actionName](...params);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
250
|
@action createOrder() {
|
|
196
251
|
if (!this.isValid) {
|
|
197
252
|
return;
|
|
@@ -223,12 +278,18 @@ export default class OperationsOrdersIndexNewController extends Controller {
|
|
|
223
278
|
return;
|
|
224
279
|
}
|
|
225
280
|
|
|
281
|
+
// send event that fleetops is `creating` an order
|
|
282
|
+
this.universe.trigger('fleet-ops.order.creating', order);
|
|
226
283
|
this.isCreatingOrder = true;
|
|
227
284
|
|
|
228
285
|
try {
|
|
229
286
|
return order
|
|
230
287
|
.save()
|
|
231
288
|
.then((order) => {
|
|
289
|
+
// trigger event that fleet-ops created an order
|
|
290
|
+
this.universe.trigger('fleet-ops.order.created', order);
|
|
291
|
+
|
|
292
|
+
// transition to order view
|
|
232
293
|
return this.transitionToRoute('operations.orders.index.view', order).then(() => {
|
|
233
294
|
this.notifications.success(`New Order ${order.public_id} Created`);
|
|
234
295
|
this.loader.removeLoader();
|
|
@@ -499,7 +560,7 @@ export default class OperationsOrdersIndexNewController extends Controller {
|
|
|
499
560
|
}
|
|
500
561
|
|
|
501
562
|
@action scheduleOrder(dateInstance) {
|
|
502
|
-
this.order.scheduled_at = dateInstance
|
|
563
|
+
this.order.scheduled_at = dateInstance;
|
|
503
564
|
}
|
|
504
565
|
|
|
505
566
|
@action setupInterface() {
|
|
@@ -890,6 +951,7 @@ export default class OperationsOrdersIndexNewController extends Controller {
|
|
|
890
951
|
|
|
891
952
|
@action setOrderFacilitator(model) {
|
|
892
953
|
this.order.set('facilitator', model);
|
|
954
|
+
// this.order.set('facilitator_type', `fleet-ops:${model.facilitator_type}`);
|
|
893
955
|
this.order.set('driver', null);
|
|
894
956
|
|
|
895
957
|
this.isUsingIntegratedVendor = model.isIntegratedVendor;
|
|
@@ -908,6 +970,11 @@ export default class OperationsOrdersIndexNewController extends Controller {
|
|
|
908
970
|
}
|
|
909
971
|
}
|
|
910
972
|
|
|
973
|
+
@action setOrderCustomer(model) {
|
|
974
|
+
this.order.set('customer', model);
|
|
975
|
+
// this.order.set('customer_type', `fleet-ops:${model.customer_type}`);
|
|
976
|
+
}
|
|
977
|
+
|
|
911
978
|
@action selectIntegratedServiceType(key) {
|
|
912
979
|
this.integratedVendorServiceType = key;
|
|
913
980
|
|
|
@@ -9,7 +9,6 @@ import { OSRMv1, Control as RoutingControl } from '@fleetbase/leaflet-routing-ma
|
|
|
9
9
|
import groupBy from '@fleetbase/ember-core/utils/macros/group-by';
|
|
10
10
|
import findClosestWaypoint from '@fleetbase/ember-core/utils/find-closest-waypoint';
|
|
11
11
|
import getRoutingHost from '@fleetbase/ember-core/utils/get-routing-host';
|
|
12
|
-
import extractCoordinates from '@fleetbase/ember-core/utils/extract-coordinates';
|
|
13
12
|
|
|
14
13
|
export default class OperationsOrdersIndexViewController extends Controller {
|
|
15
14
|
/**
|
|
@@ -83,11 +82,11 @@ export default class OperationsOrdersIndexViewController extends Controller {
|
|
|
83
82
|
@service hostRouter;
|
|
84
83
|
|
|
85
84
|
/**
|
|
86
|
-
* Inject the `
|
|
85
|
+
* Inject the `universe` service
|
|
87
86
|
*
|
|
88
87
|
* @var {Service}
|
|
89
88
|
*/
|
|
90
|
-
@service
|
|
89
|
+
@service universe;
|
|
91
90
|
|
|
92
91
|
@tracked isLoadingAdditionalData = false;
|
|
93
92
|
@tracked isWaypointsCollapsed;
|
|
@@ -169,38 +168,36 @@ export default class OperationsOrdersIndexViewController extends Controller {
|
|
|
169
168
|
|
|
170
169
|
@action removeRoutingControlPreview() {
|
|
171
170
|
const { leafletMap, routeControl } = this;
|
|
172
|
-
let removed = false;
|
|
173
171
|
|
|
174
172
|
if (routeControl instanceof RoutingControl) {
|
|
175
173
|
try {
|
|
176
174
|
routeControl.remove();
|
|
177
|
-
removed = true;
|
|
178
175
|
} catch (e) {
|
|
179
176
|
// silent
|
|
180
177
|
}
|
|
178
|
+
}
|
|
181
179
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
180
|
+
if (leafletMap instanceof L.Map) {
|
|
181
|
+
try {
|
|
182
|
+
leafletMap.removeControl(routeControl);
|
|
183
|
+
} catch (e) {
|
|
184
|
+
// silent
|
|
188
185
|
}
|
|
189
186
|
}
|
|
190
187
|
|
|
191
|
-
|
|
192
|
-
this.forceRemoveRoutePreview();
|
|
193
|
-
}
|
|
188
|
+
this.forceRemoveRoutePreview();
|
|
194
189
|
}
|
|
195
190
|
|
|
196
191
|
@action forceRemoveRoutePreview() {
|
|
197
192
|
const { leafletMap } = this;
|
|
198
193
|
|
|
199
|
-
leafletMap.
|
|
200
|
-
|
|
201
|
-
layer.
|
|
202
|
-
|
|
203
|
-
|
|
194
|
+
if (leafletMap instanceof L.Map) {
|
|
195
|
+
leafletMap.eachLayer((layer) => {
|
|
196
|
+
if (layer instanceof L.Polyline || layer instanceof L.Marker) {
|
|
197
|
+
layer.remove();
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
204
201
|
}
|
|
205
202
|
|
|
206
203
|
@action setupInterface() {
|
|
@@ -228,14 +225,14 @@ export default class OperationsOrdersIndexViewController extends Controller {
|
|
|
228
225
|
};
|
|
229
226
|
|
|
230
227
|
// re-display order routes when livemap has coordinates
|
|
231
|
-
this.
|
|
228
|
+
this.universe.on('livemap.has_coordinates', this, displayOrderRoute);
|
|
232
229
|
|
|
233
230
|
// when transitioning away kill event listener
|
|
234
231
|
this.hostRouter.on('routeWillChange', () => {
|
|
235
|
-
const isListening = this.
|
|
232
|
+
const isListening = this.universe.has('livemap.has_coordinates');
|
|
236
233
|
|
|
237
234
|
if (isListening) {
|
|
238
|
-
this.
|
|
235
|
+
this.universe.off('livemap.has_coordinates', this, displayOrderRoute);
|
|
239
236
|
}
|
|
240
237
|
});
|
|
241
238
|
|
|
@@ -243,10 +240,28 @@ export default class OperationsOrdersIndexViewController extends Controller {
|
|
|
243
240
|
setup();
|
|
244
241
|
}
|
|
245
242
|
|
|
243
|
+
@computed('model.payload.{dropoff,pickup,waypoints}') get routeWaypoints() {
|
|
244
|
+
const { payload } = this.model;
|
|
245
|
+
let waypoints = [];
|
|
246
|
+
let coordinates = [];
|
|
247
|
+
|
|
248
|
+
waypoints.pushObjects([payload.pickup, ...payload.waypoints.toArray(), payload.dropoff]);
|
|
249
|
+
waypoints.forEach((place) => {
|
|
250
|
+
if (place && place.get('longitude') && place.get('latitude')) {
|
|
251
|
+
if (place.hasInvalidCoordinates) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
coordinates.pushObject([place.get('latitude'), place.get('longitude')]);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
return coordinates;
|
|
260
|
+
}
|
|
261
|
+
|
|
246
262
|
@action displayOrderRoute() {
|
|
247
|
-
// map coordinates from lng, lat -> lat, lng
|
|
248
263
|
const payload = this.model.payload;
|
|
249
|
-
const waypoints =
|
|
264
|
+
const waypoints = this.routeWaypoints;
|
|
250
265
|
const leafletMap = this.leafletMap;
|
|
251
266
|
const routingHost = getRoutingHost(payload, payload?.waypoints?.toArray());
|
|
252
267
|
|
|
@@ -74,11 +74,11 @@ export default class OperationsOrdersIndexController extends Controller {
|
|
|
74
74
|
@service crud;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* Inject the `
|
|
77
|
+
* Inject the `universe` service
|
|
78
78
|
*
|
|
79
79
|
* @var {Service}
|
|
80
80
|
*/
|
|
81
|
-
@service
|
|
81
|
+
@service universe;
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Queryable parameters for this controller's model
|
|
@@ -528,7 +528,7 @@ export default class OperationsOrdersIndexController extends Controller {
|
|
|
528
528
|
this.isSearchVisible = false;
|
|
529
529
|
}
|
|
530
530
|
|
|
531
|
-
this.
|
|
531
|
+
this.universe.trigger('dashboard.layout.changed', mode);
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
@action setMapReference({ target }) {
|
package/addon/engine.js
CHANGED
|
@@ -14,6 +14,10 @@ export default class FleetOpsEngine extends Engine {
|
|
|
14
14
|
services,
|
|
15
15
|
externalRoutes,
|
|
16
16
|
};
|
|
17
|
+
setupExtension = function (app, engine, universe) {
|
|
18
|
+
// register menu item in header
|
|
19
|
+
universe.registerHeaderMenuItem('Fleet Ops', 'console.fleet-ops', { icon: 'route', priority: 0 });
|
|
20
|
+
};
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
loadInitializers(FleetOpsEngine, modulePrefix);
|
|
@@ -3,37 +3,37 @@
|
|
|
3
3
|
<DropdownButton @icon="ellipsis-h" @size="sm" @iconPrefix="fas" @triggerClass="mr-2 hidden md:flex" as |dd|>
|
|
4
4
|
<div class="next-dd-menu mt-1 mx-0" aria-orientation="vertical" aria-labelledby="user-menu">
|
|
5
5
|
<div class="p-1">
|
|
6
|
-
<a href="javascript:;" class="next-dd-item" {{on "click" (fn this.
|
|
6
|
+
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.newCustomer)}}>
|
|
7
7
|
<div class="w-6">
|
|
8
8
|
<FaIcon @icon="user-plus" />
|
|
9
9
|
</div>
|
|
10
10
|
<span>Create new customer</span>
|
|
11
11
|
</a>
|
|
12
|
-
<a href="javascript:;" class="next-dd-item" {{on "click" (fn this.
|
|
12
|
+
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.newFacilitator)}}>
|
|
13
13
|
<div class="w-6">
|
|
14
14
|
<FaIcon @icon="truck" />
|
|
15
15
|
</div>
|
|
16
16
|
<span>Create new facilitator</span>
|
|
17
17
|
</a>
|
|
18
|
-
<a href="javascript:;" class="next-dd-item" {{on "click" (fn this.
|
|
18
|
+
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.newPlace)}}>
|
|
19
19
|
<div class="w-6">
|
|
20
20
|
<FaIcon @icon="map-pin" />
|
|
21
21
|
</div>
|
|
22
22
|
<span>Create new place</span>
|
|
23
23
|
</a>
|
|
24
|
-
<a href="javascript:;" class="next-dd-item" {{on "click" (fn this.
|
|
24
|
+
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.addEntity)}}>
|
|
25
25
|
<div class="w-6">
|
|
26
26
|
<FaIcon @icon="box" />
|
|
27
27
|
</div>
|
|
28
28
|
<span>Add entity to order</span>
|
|
29
29
|
</a>
|
|
30
|
-
<a href="javascript:;" class="next-dd-item" {{on "click" (fn this.
|
|
30
|
+
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.editMetaData)}}>
|
|
31
31
|
<div class="w-6">
|
|
32
32
|
<FaIcon @icon="table" />
|
|
33
33
|
</div>
|
|
34
34
|
<span>Edit order metadata</span>
|
|
35
35
|
</a>
|
|
36
|
-
<a href="javascript:;" class="next-dd-item" {{on "click" (fn this.
|
|
36
|
+
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd this.addCustomField)}}>
|
|
37
37
|
<div class="w-6">
|
|
38
38
|
<FaIcon @icon="edit" />
|
|
39
39
|
</div>
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
</InputGroup>
|
|
63
63
|
|
|
64
64
|
<InputGroup @name="Customer" @helpText="Optionally assign the customer of this order. If it's a new customer, use the 'New Customer' button above.">
|
|
65
|
-
<ModelSelect @modelName="customer" @selectedModel={{this.order.customer}} @placeholder="Select Customer" @triggerClass="form-select form-input" @infiniteScroll={{false}} @renderInPlace={{true}} @allowClear={{true}} @onChange={{
|
|
65
|
+
<ModelSelect @modelName="customer" @selectedModel={{this.order.customer}} @placeholder="Select Customer" @triggerClass="form-select form-input" @infiniteScroll={{false}} @renderInPlace={{true}} @allowClear={{true}} @onChange={{this.setOrderCustomer}} as |model|>
|
|
66
66
|
<div class="flex items-center">
|
|
67
67
|
<div class="w-7">
|
|
68
68
|
<FaIcon @icon={{if model.isVendor "warehouse" "user" }} />
|
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetbase/fleetops-engine",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"version": "0.1.7",
|
|
6
|
-
"priority": 0,
|
|
3
|
+
"version": "0.1.9",
|
|
4
|
+
"description": "Fleetbase Fleet-Ops extension provides a fleet management and last mile delivery operations system module.",
|
|
7
5
|
"fleetbase": {
|
|
6
|
+
"route": "fleet-ops",
|
|
8
7
|
"dashboard": "int/v1/fleet-ops/dashboard"
|
|
9
8
|
},
|
|
10
|
-
"description": "Fleetbase Fleet-Ops extension provides a fleet management and last mile delivery operations system module.",
|
|
11
9
|
"keywords": [
|
|
12
10
|
"fleetbase-extension",
|
|
13
11
|
"fleet-management",
|
|
@@ -39,9 +37,9 @@
|
|
|
39
37
|
"test:ember-compatibility": "ember try:each"
|
|
40
38
|
},
|
|
41
39
|
"dependencies": {
|
|
42
|
-
"@fleetbase/ember-core": "^0.0
|
|
43
|
-
"@fleetbase/ember-ui":
|
|
44
|
-
"@fleetbase/fleetops-data": "^0.0.
|
|
40
|
+
"@fleetbase/ember-core": "^0.1.0",
|
|
41
|
+
"@fleetbase/ember-ui": "^0.1.3",
|
|
42
|
+
"@fleetbase/fleetops-data": "^0.0.6",
|
|
45
43
|
"@fleetbase/leaflet-routing-machine": "^3.2.16",
|
|
46
44
|
"@fortawesome/ember-fontawesome": "^0.4.1",
|
|
47
45
|
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import Service from '@ember/service';
|
|
2
|
-
import Evented from '@ember/object/evented';
|
|
3
|
-
|
|
4
|
-
export default class EngineContextService extends Service.extend(Evented) {
|
|
5
|
-
options = {};
|
|
6
|
-
|
|
7
|
-
setOption(key, value) {
|
|
8
|
-
this.options = {
|
|
9
|
-
...this.options,
|
|
10
|
-
[key]: value,
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
getOption(key) {
|
|
15
|
-
return this.options[key];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '@fleetbase/fleetops-engine/services/engine-context';
|