@fleetbase/fleetops-engine 0.2.8 → 0.3.0
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/context-panel.hbs +5 -0
- package/addon/components/context-panel.js +6 -0
- package/addon/components/driver-card-mini.js +34 -13
- package/addon/components/driver-form-panel.hbs +23 -23
- package/addon/components/driver-form-panel.js +96 -13
- package/addon/components/driver-panel.hbs +12 -12
- package/addon/components/driver-panel.js +125 -21
- package/addon/components/fleet-vehicle-listing.hbs +1 -1
- package/addon/components/live-map.hbs +20 -9
- package/addon/components/live-map.js +1255 -353
- package/addon/components/map-container/toolbar/visibility-control-panel.hbs +66 -0
- package/addon/components/map-container/toolbar/visibility-control-panel.js +74 -0
- package/addon/components/map-container/toolbar/zones-panel.hbs +10 -10
- package/addon/components/map-container/toolbar/zones-panel.js +90 -61
- package/addon/components/map-container/toolbar.hbs +12 -7
- package/addon/components/modals/vehicle-form.hbs +35 -35
- package/addon/components/settings-window.hbs +1 -1
- package/addon/components/vehicle-form-panel.hbs +25 -26
- package/addon/components/vehicle-form-panel.js +95 -12
- package/addon/components/vehicle-panel.hbs +12 -13
- package/addon/components/vehicle-panel.js +130 -20
- package/addon/controllers/management/drivers/index/details.js +53 -0
- package/addon/controllers/management/drivers/index/edit.js +77 -46
- package/addon/controllers/management/drivers/index/new.js +39 -79
- package/addon/controllers/management/drivers/index.js +17 -221
- package/addon/controllers/management/fleets/index/edit.js +1 -1
- package/addon/controllers/management/fleets/index/new.js +1 -1
- package/addon/controllers/management/fuel-reports/index.js +2 -2
- package/addon/controllers/management/vehicles/index/details.js +49 -0
- package/addon/controllers/management/vehicles/index/edit.js +104 -1
- package/addon/controllers/management/vehicles/index/new.js +71 -0
- package/addon/controllers/operations/orders/index/new.js +4 -6
- package/addon/controllers/operations/orders/index/view.js +22 -14
- package/addon/controllers/operations/orders/index.js +124 -50
- package/addon/controllers/operations/service-rates/index/edit.js +1 -1
- package/addon/controllers/operations/service-rates/index/new.js +1 -1
- package/addon/engine.js +6 -0
- package/addon/helpers/is-visibility-control-visible.js +18 -0
- package/addon/routes/application.js +1 -1
- package/addon/routes/home.js +1 -1
- package/addon/routes/management/drivers/index/details.js +5 -0
- package/addon/routes/operations/orders/index/view.js +4 -2
- package/addon/routes/operations/orders/index.js +5 -1
- package/addon/routes/operations/service-rates/index.js +1 -1
- package/addon/routes/operations/zones/index.js +1 -1
- package/addon/services/context-panel.js +173 -0
- package/addon/services/leaflet-contextmenu-manager.js +311 -0
- package/addon/services/leaflet-map-manager.js +61 -0
- package/addon/services/service-areas.js +242 -32
- package/addon/templates/application.hbs +2 -1
- package/addon/templates/management/drivers/index/details.hbs +1 -1
- package/addon/templates/management/drivers/index/edit.hbs +1 -1
- package/addon/templates/management/drivers/index/new.hbs +1 -1
- package/addon/templates/management/vehicles/index/details.hbs +1 -1
- package/addon/templates/management/vehicles/index/edit.hbs +1 -1
- package/addon/templates/management/vehicles/index/new.hbs +1 -1
- package/addon/templates/operations/orders/index/view.hbs +2 -2
- package/addon/templates/operations/orders/index.hbs +1 -1
- package/addon/utils/apply-context-component-arguments.js +31 -0
- package/addon/utils/context-component-callback.js +16 -0
- package/addon/utils/find-leaflet-layer.js +13 -0
- package/addon/utils/fly-to-leaflet-layer.js +25 -0
- package/addon/utils/get-leaflet-layer-by-id.js +12 -0
- package/addon/utils/layer-can-bind-contextmenu.js +3 -0
- package/app/components/context-panel.js +1 -0
- package/app/components/map-container/toolbar/visibility-control-panel.js +1 -0
- package/app/helpers/is-visibility-control-visible.js +1 -0
- package/app/services/context-panel.js +1 -0
- package/app/services/leaflet-contextmenu-manager.js +1 -0
- package/app/services/leaflet-map-manager.js +1 -0
- package/app/utils/apply-context-component-arguments.js +1 -0
- package/app/utils/context-component-callback.js +1 -0
- package/app/utils/find-leaflet-layer.js +1 -0
- package/app/utils/fly-to-leaflet-layer.js +1 -0
- package/app/utils/get-leaflet-layer-by-id.js +1 -0
- package/app/utils/layer-can-bind-contextmenu.js +1 -0
- package/composer.json +11 -1
- package/extension.json +1 -1
- package/package.json +3 -3
- package/server/migrations/2023_09_14_074512_update_vehicles_table.php +89 -88
- package/server/migrations/2023_10_25_093014_create_vehicle_device_events_table.php +56 -0
- package/server/src/Http/Controllers/Internal/v1/LiveController.php +7 -4
- package/server/src/Http/Filter/VehicleFilter.php +7 -0
- package/server/src/Http/Resources/v1/Vehicle.php +52 -39
- package/server/src/Models/VehicleDevice.php +17 -3
- package/server/src/Models/VehicleDeviceEvent.php +90 -0
- package/addon/services/map-manager.js +0 -3
- package/app/services/map-manager.js +0 -1
|
@@ -11,22 +11,86 @@ import Polygon from '@fleetbase/fleetops-data/utils/geojson/polygon';
|
|
|
11
11
|
import FeatureCollection from '@fleetbase/fleetops-data/utils/geojson/feature-collection';
|
|
12
12
|
|
|
13
13
|
export default class ServiceAreasService extends Service {
|
|
14
|
+
/**
|
|
15
|
+
* Inject the `store` service.
|
|
16
|
+
*
|
|
17
|
+
* @memberof ServiceAreasService
|
|
18
|
+
*/
|
|
14
19
|
@service store;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Inject the `modalsManager` service.
|
|
23
|
+
*
|
|
24
|
+
* @memberof ServiceAreasService
|
|
25
|
+
*/
|
|
15
26
|
@service modalsManager;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Inject the `notifications` service.
|
|
30
|
+
*
|
|
31
|
+
* @memberof ServiceAreasService
|
|
32
|
+
*/
|
|
16
33
|
@service notifications;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Inject the `crud` service.
|
|
37
|
+
*
|
|
38
|
+
* @memberof ServiceAreasService
|
|
39
|
+
*/
|
|
17
40
|
@service crud;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Inject the `appCache` service.
|
|
44
|
+
*
|
|
45
|
+
* @memberof ServiceAreasService
|
|
46
|
+
*/
|
|
18
47
|
@service appCache;
|
|
19
48
|
|
|
49
|
+
/**
|
|
50
|
+
* The Leaflet map instance used by the service for map-related operations.
|
|
51
|
+
*
|
|
52
|
+
* @type {Object|null}
|
|
53
|
+
*/
|
|
20
54
|
@tracked leafletMap;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* An array of service area types available within the application.
|
|
58
|
+
*
|
|
59
|
+
* @type {string[]}
|
|
60
|
+
*/
|
|
21
61
|
@tracked serviceAreaTypes = ['neighborhood', 'city', 'region', 'state', 'province', 'country', 'continent'];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A context variable that stores the current context for layer creation.
|
|
65
|
+
*
|
|
66
|
+
* @type {string|null}
|
|
67
|
+
*/
|
|
22
68
|
@tracked layerCreationContext;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A context variable that stores information related to the service area in which zones are being created.
|
|
72
|
+
*
|
|
73
|
+
* @type {Object|null}
|
|
74
|
+
*/
|
|
23
75
|
@tracked zoneServiceAreaContext;
|
|
24
76
|
|
|
25
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Retrieves service areas from the cache.
|
|
79
|
+
*
|
|
80
|
+
* @function
|
|
81
|
+
* @returns {Array} An array of service areas retrieved from the cache.
|
|
82
|
+
*/
|
|
83
|
+
getFromCache() {
|
|
26
84
|
return this.appCache.getEmberData('serviceAreas', 'service-area');
|
|
27
85
|
}
|
|
28
86
|
|
|
29
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Removes a service area from the cache.
|
|
89
|
+
*
|
|
90
|
+
* @function
|
|
91
|
+
* @param {Object} serviceArea - The service area to remove from the cache.
|
|
92
|
+
*/
|
|
93
|
+
removeFromCache(serviceArea) {
|
|
30
94
|
const serviceAreas = this.getFromCache();
|
|
31
95
|
const index = serviceAreas?.findIndex((sa) => sa.id === serviceArea.id);
|
|
32
96
|
|
|
@@ -36,7 +100,13 @@ export default class ServiceAreasService extends Service {
|
|
|
36
100
|
}
|
|
37
101
|
}
|
|
38
102
|
|
|
39
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Adds a service area to the cache.
|
|
105
|
+
*
|
|
106
|
+
* @function
|
|
107
|
+
* @param {ServiceAreaModel} serviceArea - The service area to add to the cache.
|
|
108
|
+
*/
|
|
109
|
+
addToCache(serviceArea) {
|
|
40
110
|
const serviceAreas = this.getFromCache();
|
|
41
111
|
|
|
42
112
|
if (isArray(serviceAreas)) {
|
|
@@ -46,7 +116,14 @@ export default class ServiceAreasService extends Service {
|
|
|
46
116
|
}
|
|
47
117
|
}
|
|
48
118
|
|
|
49
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Converts a Leaflet layer to a Terraformer primitive.
|
|
121
|
+
*
|
|
122
|
+
* @function
|
|
123
|
+
* @param {Object} layer - The Leaflet layer to convert.
|
|
124
|
+
* @returns {Object} The Terraformer primitive.
|
|
125
|
+
*/
|
|
126
|
+
layerToTerraformerPrimitive(layer) {
|
|
50
127
|
const leafletLayerGeoJson = layer.toGeoJSON();
|
|
51
128
|
let featureCollection, feature;
|
|
52
129
|
|
|
@@ -62,7 +139,14 @@ export default class ServiceAreasService extends Service {
|
|
|
62
139
|
return primitive;
|
|
63
140
|
}
|
|
64
141
|
|
|
65
|
-
|
|
142
|
+
/**
|
|
143
|
+
* Converts a Leaflet layer to a Terraformer MultiPolygon.
|
|
144
|
+
*
|
|
145
|
+
* @function
|
|
146
|
+
* @param {Object} layer - The Leaflet layer to convert.
|
|
147
|
+
* @returns {Object} The Terraformer MultiPolygon.
|
|
148
|
+
*/
|
|
149
|
+
layerToTerraformerMultiPolygon(layer) {
|
|
66
150
|
const leafletLayerGeoJson = layer.toGeoJSON();
|
|
67
151
|
let featureCollection, feature, coordinates;
|
|
68
152
|
|
|
@@ -79,7 +163,14 @@ export default class ServiceAreasService extends Service {
|
|
|
79
163
|
return multipolygon;
|
|
80
164
|
}
|
|
81
165
|
|
|
82
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Converts a Leaflet layer to a Terraformer Polygon.
|
|
168
|
+
*
|
|
169
|
+
* @function
|
|
170
|
+
* @param {Object} layer - The Leaflet layer to convert.
|
|
171
|
+
* @returns {Object} The Terraformer Polygon.
|
|
172
|
+
*/
|
|
173
|
+
layerToTerraformerPolygon(layer) {
|
|
83
174
|
const leafletLayerGeoJson = layer.toGeoJSON();
|
|
84
175
|
let featureCollection, feature, coordinates;
|
|
85
176
|
|
|
@@ -96,36 +187,82 @@ export default class ServiceAreasService extends Service {
|
|
|
96
187
|
return polygon;
|
|
97
188
|
}
|
|
98
189
|
|
|
99
|
-
|
|
190
|
+
/**
|
|
191
|
+
* Clears the layer creation context.
|
|
192
|
+
*
|
|
193
|
+
* @function
|
|
194
|
+
*/
|
|
195
|
+
clearLayerCreationContext() {
|
|
100
196
|
this.layerCreationContext = undefined;
|
|
101
197
|
}
|
|
102
198
|
|
|
103
|
-
|
|
199
|
+
/**
|
|
200
|
+
* Sets the layer creation context.
|
|
201
|
+
*
|
|
202
|
+
* @function
|
|
203
|
+
* @param {string} context - The context to set.
|
|
204
|
+
*/
|
|
205
|
+
setLayerCreationContext(context) {
|
|
104
206
|
this.layerCreationContext = context;
|
|
105
207
|
}
|
|
106
208
|
|
|
107
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Clears the zone service area context.
|
|
211
|
+
*
|
|
212
|
+
* @function
|
|
213
|
+
*/
|
|
214
|
+
clearZoneServiceAreaContext() {
|
|
108
215
|
this.zoneServiceAreaContext = undefined;
|
|
109
216
|
}
|
|
110
217
|
|
|
111
|
-
|
|
218
|
+
/**
|
|
219
|
+
* Sets the zone service area context.
|
|
220
|
+
*
|
|
221
|
+
* @function
|
|
222
|
+
* @param {Object} serviceArea - The service area to set as the context.
|
|
223
|
+
*/
|
|
224
|
+
setZoneServiceAreaContext(serviceArea) {
|
|
112
225
|
this.zoneServiceAreaContext = serviceArea;
|
|
113
226
|
}
|
|
114
227
|
|
|
115
|
-
|
|
228
|
+
/**
|
|
229
|
+
* Retrieves the zone service area context.
|
|
230
|
+
*
|
|
231
|
+
* @function
|
|
232
|
+
* @returns {Object} The zone service area context.
|
|
233
|
+
*/
|
|
234
|
+
getZoneServiceAreaContext() {
|
|
116
235
|
return this.zoneServiceAreaContext;
|
|
117
236
|
}
|
|
118
237
|
|
|
119
|
-
|
|
238
|
+
/**
|
|
239
|
+
* Sets the Leaflet map instance for the service.
|
|
240
|
+
*
|
|
241
|
+
* @function
|
|
242
|
+
* @param {Object} map - The Leaflet map instance to set.
|
|
243
|
+
*/
|
|
244
|
+
setMapInstance(map) {
|
|
120
245
|
this.leafletMap = map;
|
|
121
246
|
}
|
|
122
247
|
|
|
123
|
-
|
|
124
|
-
|
|
248
|
+
/**
|
|
249
|
+
* Sends a command to the LiveMap through the Leaflet map instance.
|
|
250
|
+
*
|
|
251
|
+
* @function
|
|
252
|
+
* @param {string} fn - The function name to call on the LiveMap.
|
|
253
|
+
* @param {...any} params - Additional parameters to pass to the function.
|
|
254
|
+
*/
|
|
255
|
+
triggerLiveMapFn(fn, ...params) {
|
|
256
|
+
this.leafletMap.liveMap[fn](...params);
|
|
125
257
|
}
|
|
126
258
|
|
|
259
|
+
/**
|
|
260
|
+
* Initiates the creation of a service area on the map.
|
|
261
|
+
*
|
|
262
|
+
* @function
|
|
263
|
+
*/
|
|
127
264
|
@action createServiceArea() {
|
|
128
|
-
this.
|
|
265
|
+
this.triggerLiveMapFn('showDrawControls', { text: true });
|
|
129
266
|
this.setLayerCreationContext('service-area');
|
|
130
267
|
|
|
131
268
|
this.notifications.info('Use drawing controls to the right to draw a service area, complete point connections to save service area.', {
|
|
@@ -133,6 +270,14 @@ export default class ServiceAreasService extends Service {
|
|
|
133
270
|
});
|
|
134
271
|
}
|
|
135
272
|
|
|
273
|
+
/**
|
|
274
|
+
* Creates a generic layer on the map, such as a service area or zone.
|
|
275
|
+
*
|
|
276
|
+
* @function
|
|
277
|
+
* @param {Object} event - The event that triggered the creation.
|
|
278
|
+
* @param {Object} layer - The layer being created.
|
|
279
|
+
* @param {Object} options - Additional options for the creation (optional).
|
|
280
|
+
*/
|
|
136
281
|
@action createGenericLayer(event, layer, options = {}) {
|
|
137
282
|
if (this.layerCreationContext === 'service-area') {
|
|
138
283
|
return this.saveServiceArea(...arguments);
|
|
@@ -185,18 +330,18 @@ export default class ServiceAreasService extends Service {
|
|
|
185
330
|
|
|
186
331
|
// if service area has been created, add to the active service areas
|
|
187
332
|
if (selectedLayerType === 'Service Area') {
|
|
188
|
-
this.
|
|
189
|
-
this.
|
|
333
|
+
this.triggerLiveMapFn('activateServiceArea', record);
|
|
334
|
+
this.triggerLiveMapFn('focusLayerBoundsByRecord', record);
|
|
190
335
|
} else {
|
|
191
336
|
// if zone was created then we simply add the zone to the serviceArea selected
|
|
192
337
|
// then we focus the service area
|
|
193
338
|
serviceArea?.zones.pushObject(record);
|
|
194
|
-
this.
|
|
195
|
-
this.
|
|
339
|
+
this.triggerLiveMapFn('activateServiceArea', serviceArea);
|
|
340
|
+
this.triggerLiveMapFn('focusLayerBoundsByRecord', serviceArea);
|
|
196
341
|
}
|
|
197
342
|
|
|
198
343
|
// rebuild context menu
|
|
199
|
-
this.
|
|
344
|
+
this.triggerLiveMapFn('rebuildMapContextMenu');
|
|
200
345
|
this.clearLayerCreationContext();
|
|
201
346
|
});
|
|
202
347
|
},
|
|
@@ -208,6 +353,13 @@ export default class ServiceAreasService extends Service {
|
|
|
208
353
|
});
|
|
209
354
|
}
|
|
210
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Saves a service area to the database.
|
|
358
|
+
*
|
|
359
|
+
* @function
|
|
360
|
+
* @param {Object} event - The event that triggered the saving.
|
|
361
|
+
* @param {Object} layer - The layer to be saved as a service area.
|
|
362
|
+
*/
|
|
211
363
|
@action saveServiceArea(event, layer) {
|
|
212
364
|
const { _map } = layer;
|
|
213
365
|
const border = this.layerToTerraformerMultiPolygon(layer);
|
|
@@ -230,6 +382,13 @@ export default class ServiceAreasService extends Service {
|
|
|
230
382
|
});
|
|
231
383
|
}
|
|
232
384
|
|
|
385
|
+
/**
|
|
386
|
+
* Edits and saves details of a service area.
|
|
387
|
+
*
|
|
388
|
+
* @function
|
|
389
|
+
* @param {Object} serviceArea - The service area to edit.
|
|
390
|
+
* @param {Object} options - Additional options for the edit (optional).
|
|
391
|
+
*/
|
|
233
392
|
@action editServiceAreaDetails(serviceArea, options = {}) {
|
|
234
393
|
this.modalsManager.show('modals/service-area-form', {
|
|
235
394
|
title: 'Edit Service Area',
|
|
@@ -247,13 +406,13 @@ export default class ServiceAreasService extends Service {
|
|
|
247
406
|
|
|
248
407
|
this.clearLayerCreationContext();
|
|
249
408
|
this.addToCache(serviceArea);
|
|
250
|
-
this.
|
|
251
|
-
|
|
409
|
+
this.triggerLiveMapFn('focusServiceArea', serviceArea);
|
|
410
|
+
this.triggerLiveMapFn('rebuildMapContextMenu');
|
|
252
411
|
});
|
|
253
412
|
},
|
|
254
413
|
decline: (modal) => {
|
|
255
414
|
this.clearLayerCreationContext();
|
|
256
|
-
this.
|
|
415
|
+
this.triggerLiveMapFn('hideDrawControls', { text: true });
|
|
257
416
|
|
|
258
417
|
if (serviceArea.isNew) {
|
|
259
418
|
serviceArea.destroyRecord();
|
|
@@ -264,21 +423,34 @@ export default class ServiceAreasService extends Service {
|
|
|
264
423
|
});
|
|
265
424
|
}
|
|
266
425
|
|
|
426
|
+
/**
|
|
427
|
+
* Deletes a service area from the database.
|
|
428
|
+
*
|
|
429
|
+
* @function
|
|
430
|
+
* @param {Object} serviceArea - The service area to delete.
|
|
431
|
+
* @param {Object} options - Additional options for the deletion (optional).
|
|
432
|
+
*/
|
|
267
433
|
@action deleteServiceArea(serviceArea, options = {}) {
|
|
268
|
-
this.
|
|
434
|
+
this.triggerLiveMapFn('focusLayerBoundsByRecord', serviceArea);
|
|
269
435
|
|
|
270
436
|
this.crud.delete(serviceArea, {
|
|
271
437
|
onConfirm: () => {
|
|
272
|
-
this.
|
|
438
|
+
this.triggerLiveMapFn('blurServiceArea', serviceArea);
|
|
273
439
|
this.removeFromCache(serviceArea);
|
|
274
440
|
},
|
|
275
441
|
...options,
|
|
276
442
|
});
|
|
277
443
|
}
|
|
278
444
|
|
|
445
|
+
/**
|
|
446
|
+
* Initiates the creation of a zone within a service area on the map.
|
|
447
|
+
*
|
|
448
|
+
* @function
|
|
449
|
+
* @param {Object} serviceArea - The service area within which the zone is being created.
|
|
450
|
+
*/
|
|
279
451
|
@action createZone(serviceArea) {
|
|
280
|
-
this.
|
|
281
|
-
this.
|
|
452
|
+
this.triggerLiveMapFn('showDrawControls', { text: true });
|
|
453
|
+
this.triggerLiveMapFn('focusServiceArea', serviceArea);
|
|
282
454
|
this.setZoneServiceAreaContext(serviceArea);
|
|
283
455
|
this.setLayerCreationContext('zone');
|
|
284
456
|
|
|
@@ -287,6 +459,14 @@ export default class ServiceAreasService extends Service {
|
|
|
287
459
|
});
|
|
288
460
|
}
|
|
289
461
|
|
|
462
|
+
/**
|
|
463
|
+
* Saves a zone to the database.
|
|
464
|
+
*
|
|
465
|
+
* @function
|
|
466
|
+
* @param {Object} event - The event that triggered the saving.
|
|
467
|
+
* @param {Object} layer - The layer to be saved as a zone.
|
|
468
|
+
* @returns {Promise} A promise that resolves when the zone is saved.
|
|
469
|
+
*/
|
|
290
470
|
@action saveZone(event, layer) {
|
|
291
471
|
const { _map } = layer;
|
|
292
472
|
const border = this.layerToTerraformerPolygon(layer);
|
|
@@ -307,6 +487,15 @@ export default class ServiceAreasService extends Service {
|
|
|
307
487
|
});
|
|
308
488
|
}
|
|
309
489
|
|
|
490
|
+
/**
|
|
491
|
+
* Edits and saves details of a zone.
|
|
492
|
+
*
|
|
493
|
+
* @function
|
|
494
|
+
* @param {Object} zone - The zone to edit.
|
|
495
|
+
* @param {Object} serviceArea - The service area to which the zone belongs.
|
|
496
|
+
* @param {Object} options - Additional options for the edit (optional).
|
|
497
|
+
* @returns {Promise} A promise that resolves when the zone is successfully saved.
|
|
498
|
+
*/
|
|
310
499
|
@action editZone(zone, serviceArea, options = {}) {
|
|
311
500
|
this.modalsManager.show('modals/zone-form', {
|
|
312
501
|
title: 'Edit Zone',
|
|
@@ -323,23 +512,23 @@ export default class ServiceAreasService extends Service {
|
|
|
323
512
|
|
|
324
513
|
this.clearLayerCreationContext();
|
|
325
514
|
this.clearZoneServiceAreaContext();
|
|
326
|
-
this.
|
|
327
|
-
this.
|
|
515
|
+
this.triggerLiveMapFn('hideDrawControls', { text: true });
|
|
516
|
+
this.triggerLiveMapFn('blurAllServiceAreas');
|
|
328
517
|
|
|
329
518
|
later(
|
|
330
519
|
this,
|
|
331
520
|
() => {
|
|
332
|
-
this.
|
|
521
|
+
this.triggerLiveMapFn('focusServiceArea', serviceArea);
|
|
333
522
|
},
|
|
334
523
|
300
|
|
335
524
|
);
|
|
336
|
-
|
|
525
|
+
this.triggerLiveMapFn('rebuildMapContextMenu');
|
|
337
526
|
});
|
|
338
527
|
},
|
|
339
528
|
decline: (modal) => {
|
|
340
529
|
this.clearLayerCreationContext();
|
|
341
530
|
this.clearZoneServiceAreaContext();
|
|
342
|
-
this.
|
|
531
|
+
this.triggerLiveMapFn('hideDrawControls', { text: true });
|
|
343
532
|
|
|
344
533
|
if (zone.isNew) {
|
|
345
534
|
zone.destroyRecord();
|
|
@@ -350,12 +539,26 @@ export default class ServiceAreasService extends Service {
|
|
|
350
539
|
});
|
|
351
540
|
}
|
|
352
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Deletes a zone from the database.
|
|
544
|
+
*
|
|
545
|
+
* @function
|
|
546
|
+
* @param {Object} zone - The zone to delete.
|
|
547
|
+
* @param {Object} options - Additional options for the deletion (optional).
|
|
548
|
+
*/
|
|
353
549
|
@action deleteZone(zone, options = {}) {
|
|
354
550
|
this.crud.delete(zone, {
|
|
355
551
|
...options,
|
|
356
552
|
});
|
|
357
553
|
}
|
|
358
554
|
|
|
555
|
+
/**
|
|
556
|
+
* Displays a service area in a dialog for viewing.
|
|
557
|
+
*
|
|
558
|
+
* @function
|
|
559
|
+
* @param {Object} serviceArea - The service area to view in the dialog.
|
|
560
|
+
* @param {Object} options - Additional options for the dialog (optional).
|
|
561
|
+
*/
|
|
359
562
|
@action viewServiceAreaInDialog(serviceArea, options = {}) {
|
|
360
563
|
this.modalsManager.show('modals/view-service-area', {
|
|
361
564
|
title: `Service Area (${serviceArea.get('name')})`,
|
|
@@ -369,6 +572,13 @@ export default class ServiceAreasService extends Service {
|
|
|
369
572
|
});
|
|
370
573
|
}
|
|
371
574
|
|
|
575
|
+
/**
|
|
576
|
+
* Displays a zone in a dialog for viewing.
|
|
577
|
+
*
|
|
578
|
+
* @function
|
|
579
|
+
* @param {Object} zone - The zone to view in the dialog.
|
|
580
|
+
* @param {Object} options - Additional options for the dialog (optional).
|
|
581
|
+
*/
|
|
372
582
|
@action viewZoneInDialog(zone, options = {}) {
|
|
373
583
|
this.modalsManager.show('modals/view-zone', {
|
|
374
584
|
title: `Zone (${zone.get('name')})`,
|
|
@@ -6,4 +6,5 @@
|
|
|
6
6
|
{{outlet}}
|
|
7
7
|
</Layout::Section::Container>
|
|
8
8
|
|
|
9
|
-
<SettingsWindow @isOpen={{false}} @onLoad={{this.setSettingsContext}} @onPressCancel={{this.closeSettings}} />
|
|
9
|
+
<SettingsWindow @isOpen={{false}} @onLoad={{this.setSettingsContext}} @onPressCancel={{this.closeSettings}} />
|
|
10
|
+
<ContextPanel />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<DriverPanel @driver={{@model}} @tab={{this.view}} @onPressCancel={{this.transitionBack}} />
|
|
1
|
+
<DriverPanel @driver={{@model}} @tab={{this.view}} @onTabChanged={{this.onTabChanged}} @onPressCancel={{this.transitionBack}} @onEdit={{this.onEdit}} />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<DriverFormPanel @driver={{@model}} @
|
|
1
|
+
<DriverFormPanel @driver={{@model}} @onPressCancel={{this.transitionBack}} @onAfterSave={{this.onAfterSave}} @onViewDetails={{this.onViewDetails}} @onLoad={{this.setOverlayContext}} />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<DriverFormPanel @driver={{this.driver}} @
|
|
1
|
+
<DriverFormPanel @driver={{this.driver}} @onPressCancel={{this.transitionBack}} @onAfterSave={{this.onAfterSave}} @onLoad={{this.setOverlayContext}} />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<VehiclePanel @vehicle={{@model}} @tab={{this.view}} @onTabChanged={{
|
|
1
|
+
<VehiclePanel @vehicle={{@model}} @tab={{this.view}} @onTabChanged={{this.onTabChanged}} @onPressCancel={{this.transitionBack}} @onEdit={{this.onEdit}} />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<VehicleFormPanel @vehicle={{@model}} @onPressCancel={{this.transitionBack}}/>
|
|
1
|
+
<VehicleFormPanel @vehicle={{@model}} @onPressCancel={{this.transitionBack}} @onAfterSave={{this.onAfterSave}} @onViewDetails={{this.onViewDetails}} @onLoad={{this.setOverlayContext}} />
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<VehicleFormPanel @vehicle={{this.vehicle}} @onPressCancel={{this.transitionBack}} />
|
|
1
|
+
<VehicleFormPanel @vehicle={{this.vehicle}} @onPressCancel={{this.transitionBack}} @onAfterSave={{this.onAfterSave}} @onLoad={{this.setOverlayContext}} />
|
|
@@ -150,7 +150,7 @@
|
|
|
150
150
|
<span>Driver Assigned</span>
|
|
151
151
|
</div>
|
|
152
152
|
<div>
|
|
153
|
-
<
|
|
153
|
+
<a href="javascript:;" class="flex flex-row" {{on "click" (fn this.focusOrderAssignedDriver @model)}}>
|
|
154
154
|
<div>
|
|
155
155
|
<Image src={{avatar-url @model.driver_assigned.photo_url}} @fallbackSrc={{config "defaultValues.driverImage"}} width="32" height="32" class="w-8 h-8 rounded-md shadow-sm mr-3 lg:mr-2" alt={{@model.driver_assigned.name}} />
|
|
156
156
|
</div>
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
<div>{{@model.driver_assigned.phone}}</div>
|
|
161
161
|
{{/if}}
|
|
162
162
|
</div>
|
|
163
|
-
</
|
|
163
|
+
</a>
|
|
164
164
|
<div class="mt-1">
|
|
165
165
|
<Button @size="xs" @type="default" @icon="edit" @text={{if @model.has_driver_assigned "Change Driver" "Assign Driver"}} @onClick={{fn this.assignDriver @model}} />
|
|
166
166
|
</div>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
{{#if this.isMapLayout}}
|
|
14
14
|
<MapContainer @layout={{this.layout}} @onReady={{this.onMapContainerReady}}>
|
|
15
15
|
<GlobalSearch @visible={{this.isSearchVisible}} @onPressOrder={{this.viewOrder}} />
|
|
16
|
-
<MapContainer::Toolbar @activeOrdersCount={{this.activeOrdersCount}} @
|
|
16
|
+
<MapContainer::Toolbar @activeOrdersCount={{this.activeOrdersCount}} @liveMap={{this.liveMap}} @map={{this.leafletMap}} @onPressViewOrders={{this.toggleOrdersPanel}} @onPressSearch={{this.toggleSearch}} @onPressCreateOrder={{this.createOrder}} @onPressCreateDriver={{this.driversController.createDriver}} @onPressDriverProfile={{this.driversController.viewDriver}} />
|
|
17
17
|
<OrderListOverlay @noBackdrop={{true}} @fullHeight={{true}} @outView={{not this.isOrdersPanelVisible}} @width={{if (media 'isMobile') "100%" "338px"}} @onPressCancel={{this.hideOrdersPanel}} @onPressCreateOrder={{this.createOrder}} @onPressViewOrder={{this.viewOrder}} @onPressCreateFleet={{this.fleetController.createFleet}} @onPressManageFleet={{this.fleetController.viewFleet}} @onPressCancelOrders={{this.bulkCancelOrders}} @onPressDeleteOrders={{this.bulkDeleteOrders}} />
|
|
18
18
|
<LiveMap id="leafletMap" class="next-leaflet-container-map" @lat={{1.3521}} @lng={{103.8198}} @zoom={{12}} @zoomControl={{false}} @onLoad={{this.setMapReference}} {{set-container-dimensions}} />
|
|
19
19
|
</MapContainer>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import getModelName from '@fleetbase/ember-core/utils/get-model-name';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Applies context and dynamic arguments to a given component.
|
|
5
|
+
*
|
|
6
|
+
* @param {Component} component - The component to which context and arguments will be applied.
|
|
7
|
+
*/
|
|
8
|
+
export default function applyContextComponentArguments(component) {
|
|
9
|
+
const { context, dynamicArgs = {} } = component.args;
|
|
10
|
+
|
|
11
|
+
// Apply context model if available
|
|
12
|
+
if (context) {
|
|
13
|
+
const contextModelName = getModelName(context);
|
|
14
|
+
if (contextModelName) {
|
|
15
|
+
component[contextModelName] = context;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Execute any apply callback present in dynamic arguments
|
|
20
|
+
const { applyCallback } = dynamicArgs;
|
|
21
|
+
if (typeof applyCallback === 'function') {
|
|
22
|
+
applyCallback(component);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Apply other dynamic arguments to the component
|
|
26
|
+
for (const [key, value] of Object.entries(dynamicArgs)) {
|
|
27
|
+
if (key !== 'applyCallback') {
|
|
28
|
+
component[key] = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default function contextComponentCallback(component, name, ...params) {
|
|
2
|
+
let callbackInvoked = false;
|
|
3
|
+
|
|
4
|
+
if (typeof component.args[name] === 'function') {
|
|
5
|
+
component.args[name](...params);
|
|
6
|
+
callbackInvoked = true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// now do for context options
|
|
10
|
+
if (typeof component.args.options === 'object' && typeof component.args.options[name] === 'function') {
|
|
11
|
+
component.args.options[name](...params);
|
|
12
|
+
callbackInvoked = true;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return callbackInvoked;
|
|
16
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default function flyToLeafletLayer(map, layer, zoom, options = {}) {
|
|
2
|
+
if (!map || !layer) {
|
|
3
|
+
return;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// Check the type of the layer (marker, polygon, etc.) and get its center or bounds
|
|
7
|
+
let targetLatLng;
|
|
8
|
+
|
|
9
|
+
if (layer instanceof L.Marker) {
|
|
10
|
+
// For markers, you can directly get the marker's LatLng
|
|
11
|
+
targetLatLng = layer.getLatLng();
|
|
12
|
+
} else {
|
|
13
|
+
// For other types of layers, like polygons or circles, you can calculate the center
|
|
14
|
+
if (layer.getCenter) {
|
|
15
|
+
targetLatLng = layer.getCenter();
|
|
16
|
+
} else if (layer.getBounds) {
|
|
17
|
+
targetLatLng = layer.getBounds().getCenter();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Check if we have a valid LatLng
|
|
22
|
+
if (targetLatLng) {
|
|
23
|
+
map.flyTo(targetLatLng, zoom, options);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default function getLeafletLayerById(map, layerId) {
|
|
2
|
+
let targetLayer = null;
|
|
3
|
+
|
|
4
|
+
map.eachLayer((layer) => {
|
|
5
|
+
// Check if the layer has an ID property
|
|
6
|
+
if (layer.options && layer.options.id === layerId) {
|
|
7
|
+
targetLayer = layer;
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
return targetLayer;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/components/context-panel';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/components/map-container/toolbar/visibility-control-panel';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/helpers/is-visibility-control-visible';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/services/context-panel';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/services/leaflet-contextmenu-manager';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/services/leaflet-map-manager';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/utils/apply-context-component-arguments';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/utils/context-component-callback';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/utils/find-leaflet-layer';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@fleetbase/fleetops-engine/utils/fly-to-leaflet-layer';
|