@fleetbase/fleetops-engine 0.4.2 → 0.4.4

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.
Files changed (30) hide show
  1. package/addon/components/edit-order-route-panel.hbs +182 -0
  2. package/addon/components/edit-order-route-panel.js +265 -0
  3. package/addon/components/fleet-panel.js +3 -3
  4. package/addon/components/map-container/toolbar.hbs +2 -2
  5. package/addon/components/modals/order-route-form.hbs +1 -1
  6. package/addon/controllers/operations/orders/index/new.js +73 -36
  7. package/addon/controllers/operations/orders/index/view.js +131 -126
  8. package/addon/routes/operations/orders/index/view.js +1 -1
  9. package/addon/services/context-panel.js +6 -0
  10. package/addon/styles/fleetops-engine.css +5 -0
  11. package/addon/templates/operations/orders/index/new.hbs +390 -58
  12. package/addon/templates/operations/orders/index/view.hbs +135 -105
  13. package/addon/templates/operations/service-rates/index/new.hbs +3 -1
  14. package/composer.json +2 -2
  15. package/extension.json +1 -1
  16. package/package.json +3 -3
  17. package/server/src/Http/Controllers/Api/v1/DriverController.php +59 -20
  18. package/server/src/Http/Controllers/Api/v1/OrderController.php +2 -0
  19. package/server/src/Http/Controllers/Internal/v1/DriverController.php +16 -3
  20. package/server/src/Http/Controllers/Internal/v1/OrderController.php +11 -0
  21. package/server/src/Http/Resources/v1/Order.php +3 -0
  22. package/server/src/Http/Resources/v1/PurchaseRate.php +2 -1
  23. package/server/src/Http/Resources/v1/ServiceQuote.php +1 -0
  24. package/server/src/Http/Resources/v1/ServiceQuoteItem.php +29 -0
  25. package/server/src/Models/Driver.php +1 -1
  26. package/server/src/Models/Order.php +16 -0
  27. package/server/src/Models/Place.php +2 -2
  28. package/server/src/Observers/DriverObserver.php +6 -1
  29. package/server/src/routes.php +1 -0
  30. package/translations/en-us.yaml +9 -2
@@ -21,13 +21,14 @@ class PurchaseRate extends FleetbaseResource
21
21
  'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
22
22
  'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
23
23
  'public_id' => $this->when(Http::isInternalRequest(), $this->public_id),
24
- 'service_quote' => $this->service_quote_id,
24
+ 'service_quote' => $this->when(Http::isInternalRequest(), $this->serviceQuote(), $this->service_quote_id),
25
25
  'order' => $this->order_id,
26
26
  'customer' => $this->customer_id,
27
27
  'transaction' => $this->transaction_id,
28
28
  'amount' => $this->amount,
29
29
  'currency' => $this->currency,
30
30
  'status' => $this->status,
31
+ // 'type' => $this->when(Http::isInternalRequest(), 'service-rate'),
31
32
  'updated_at' => $this->updated_at,
32
33
  'created_at' => $this->created_at,
33
34
  ];
@@ -25,6 +25,7 @@ class ServiceQuote extends FleetbaseResource
25
25
  'service_rate_name' => $this->when(Http::isInternalRequest(), data_get($this, 'serviceRate.name')),
26
26
  'service_rate' => $this->when(Http::isPublicRequest(), data_get($this, 'serviceRate.public_id')),
27
27
  'facilitator' => $this->when(Http::isPublicRequest(), data_get($this, 'integratedVendor.public_id')),
28
+ 'items' => ServiceQuoteItem::collection($this->items),
28
29
  'request_id' => $this->request_id,
29
30
  'amount' => $this->amount,
30
31
  'currency' => $this->currency,
@@ -0,0 +1,29 @@
1
+ <?php
2
+
3
+ namespace Fleetbase\FleetOps\Http\Resources\v1;
4
+
5
+ use Fleetbase\Http\Resources\FleetbaseResource;
6
+ use Fleetbase\Support\Http;
7
+
8
+ class ServiceQuoteItem extends FleetbaseResource
9
+ {
10
+ /**
11
+ * Transform the resource into an array.
12
+ *
13
+ * @param \Illuminate\Http\Request $request
14
+ *
15
+ * @return array
16
+ */
17
+ public function toArray($request)
18
+ {
19
+ return [
20
+ 'id' => $this->when(Http::isInternalRequest(), $this->id, $this->public_id),
21
+ 'uuid' => $this->when(Http::isInternalRequest(), $this->uuid),
22
+ 'service_quote_uuid' => $this->when(Http::isInternalRequest(), $this->service_quote_uuid),
23
+ 'amount' => $this->amount,
24
+ 'currency' => $this->currency,
25
+ 'details' => $this->details,
26
+ 'code' => $this->code,
27
+ ];
28
+ }
29
+ }
@@ -203,7 +203,7 @@ class Driver extends Model
203
203
  */
204
204
  public function user()
205
205
  {
206
- return $this->belongsTo(\Fleetbase\Models\User::class)->select(['uuid', 'avatar_uuid', 'name', 'phone', 'email'])->without(['driver'])->withTrashed();
206
+ return $this->belongsTo(\Fleetbase\Models\User::class)->select(['uuid', 'company_uuid', 'avatar_uuid', 'name', 'phone', 'email'])->without(['driver'])->withTrashed();
207
207
  }
208
208
 
209
209
  /**
@@ -323,6 +323,22 @@ class Order extends Model
323
323
  return $this->belongsTo(Driver::class)->without(['devices', 'vendor']);
324
324
  }
325
325
 
326
+ /**
327
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
328
+ */
329
+ public function comments()
330
+ {
331
+ return $this->hasMany(\Fleetbase\Models\Comment::class, 'subject_uuid')->whereNull('parent_comment_uuid')->latest();
332
+ }
333
+
334
+ /**
335
+ * @return \Illuminate\Database\Eloquent\Relations\HasMany
336
+ */
337
+ public function files()
338
+ {
339
+ return $this->hasMany(\Fleetbase\Models\File::class, 'subject_uuid')->latest();
340
+ }
341
+
326
342
  /**
327
343
  * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough
328
344
  */
@@ -451,8 +451,8 @@ class Place extends Model
451
451
  $uuid = data_get($place, 'uuid');
452
452
 
453
453
  // If $place has a valid uuid and a matching Place object exists, return the uuid
454
- if (Str::isUuid($uuid) && $place = Place::where('uuid', $uuid)->first()) {
455
- return $place;
454
+ if (Str::isUuid($uuid) && $existingPlace = Place::where('uuid', $uuid)->first()) {
455
+ return $existingPlace;
456
456
  }
457
457
 
458
458
  // Otherwise, create a new Place object with the given attributes
@@ -4,6 +4,7 @@ namespace Fleetbase\FleetOps\Observers;
4
4
 
5
5
  use Fleetbase\FleetOps\Models\Driver;
6
6
  use Fleetbase\FleetOps\Models\Order;
7
+ use Fleetbase\Models\CompanyUser;
7
8
  use Fleetbase\Models\User;
8
9
  use Grimzy\LaravelMysqlSpatial\Types\Point;
9
10
 
@@ -41,7 +42,11 @@ class DriverObserver
41
42
  public function deleted(Driver $driver)
42
43
  {
43
44
  // if the driver is deleted, delete their user account assosciated as well
44
- User::where(['uuid' => $driver->user_uuid, 'type' => 'driver'])->delete();
45
+ if ($driver->user->companies()->count() === 1) {
46
+ User::where(['uuid' => $driver->user_uuid, 'type' => 'driver'])->delete();
47
+ } else {
48
+ CompanyUser::where(['user_uuid' => $driver->user_uuid, 'company_uuid' => session('company')])->delete();
49
+ }
45
50
 
46
51
  // also unassign them from any order they are assigned to
47
52
  Order::where(['driver_assigned_uuid' => $driver->uuid])->update(['driver_assigned_uuid' => null]);
@@ -40,6 +40,7 @@ Route::prefix(config('fleetops.api.routing.prefix', null))->namespace('Fleetbase
40
40
  $router->get('/', 'DriverController@query');
41
41
  $router->get('{id}', 'DriverController@find');
42
42
  $router->get('{id}/organizations', 'DriverController@listOrganizations');
43
+ $router->get('{id}/current-organization', 'DriverController@currentOrganization');
43
44
  $router->put('{id}', 'DriverController@update');
44
45
  $router->delete('{id}', 'DriverController@delete');
45
46
  });
@@ -8,6 +8,7 @@ fleet-ops:
8
8
  avatar: Avatar
9
9
  building: Building
10
10
  bulk-action: Bulk Action
11
+ cancel: Cancel
11
12
  category: Category
12
13
  city: City
13
14
  coordinates: Coordinates
@@ -185,8 +186,8 @@ fleet-ops:
185
186
  create-zone: Create zone inside...
186
187
  toolbar:
187
188
  create: Create Order
188
- view: View Orders
189
- service: Service Areas
189
+ view-order: View Orders
190
+ view-service-area: View Service Areas
190
191
  visibility: Visibility Controls
191
192
  scope: Scope
192
193
  modals:
@@ -1157,6 +1158,12 @@ fleet-ops:
1157
1158
  edit-field-title: Edit custom field
1158
1159
  edit-metadata: Edit Metadata
1159
1160
  view:
1161
+ purchase-rate-panel-title: Purchase Rate
1162
+ documents-panel-title: Documents & Files
1163
+ route-panel-title: Route
1164
+ currency: Currency
1165
+ comments-title: Comments
1166
+ notes-title: Notes
1160
1167
  dispatch: Dispatch
1161
1168
  order-actions: Order Actions
1162
1169
  edit-details: Edit Details