From 1f1baf1e39105287c482977ef40c4e398cf893f4 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Tue, 9 Apr 2024 12:12:57 +0800 Subject: [PATCH] critical patch for updating driver user in consumable api may break tracking --- .../layout/fleet-ops-sidebar/driver-listing.js | 3 +-- composer.json | 2 +- extension.json | 2 +- package.json | 2 +- .../FixInvalidPolymorphicRelationTypeNamespaces.php | 2 +- .../src/Http/Controllers/Api/v1/DriverController.php | 7 +++++-- .../src/Http/Controllers/Api/v1/OrderController.php | 4 ++-- server/src/Http/Controllers/FleetOpsController.php | 1 - .../Controllers/Internal/v1/DriverController.php | 12 ++++++++---- server/src/Http/Requests/CreateContactRequest.php | 2 +- server/src/Http/Requests/CreateEntityRequest.php | 2 +- server/src/Http/Requests/CreateIssueRequest.php | 2 +- server/src/Http/Requests/CreatePlaceRequest.php | 2 +- server/src/Http/Requests/CreateVehicleRequest.php | 2 +- 14 files changed, 25 insertions(+), 20 deletions(-) diff --git a/addon/components/layout/fleet-ops-sidebar/driver-listing.js b/addon/components/layout/fleet-ops-sidebar/driver-listing.js index e889f57f..caa9de10 100644 --- a/addon/components/layout/fleet-ops-sidebar/driver-listing.js +++ b/addon/components/layout/fleet-ops-sidebar/driver-listing.js @@ -19,13 +19,12 @@ export default class LayoutFleetOpsSidebarDriverListingComponent extends Compone } displayPanelDropdown = true; - panelDropdownButtonActions = [ { label: 'Create new driver...', onClick: () => { const driver = this.store.createRecord('driver'); - this.contextPanel.focus(driver); + this.contextPanel.focus(driver, 'editing'); }, }, ]; diff --git a/composer.json b/composer.json index db7fdd37..03e15899 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fleetbase/fleetops-api", - "version": "0.4.24", + "version": "0.4.25", "description": "Fleet & Transport Management Extension for Fleetbase", "keywords": [ "fleetbase-extension", diff --git a/extension.json b/extension.json index 65b2df19..0c67e3af 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "Fleet-Ops", - "version": "0.4.24", + "version": "0.4.25", "description": "Fleet & Transport Management Extension for Fleetbase", "repository": "https://github.com/fleetbase/fleetops", "license": "MIT", diff --git a/package.json b/package.json index 0513d6fc..c73dfc67 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/fleetops-engine", - "version": "0.4.24", + "version": "0.4.25", "description": "Fleet & Transport Management Extension for Fleetbase", "fleetbase": { "route": "fleet-ops" diff --git a/server/src/Console/Commands/FixInvalidPolymorphicRelationTypeNamespaces.php b/server/src/Console/Commands/FixInvalidPolymorphicRelationTypeNamespaces.php index 8e6a5883..3289db9c 100644 --- a/server/src/Console/Commands/FixInvalidPolymorphicRelationTypeNamespaces.php +++ b/server/src/Console/Commands/FixInvalidPolymorphicRelationTypeNamespaces.php @@ -36,7 +36,7 @@ public function handle() ['model' => \Fleetbase\FleetOps\Models\Order::class, 'columns' => ['customer_type', 'facilitator_type']], ['model' => \Fleetbase\FleetOps\Models\Place::class, 'columns' => ['owner_type']], ['model' => \Fleetbase\FleetOps\Models\Entity::class, 'columns' => ['customer_type']], - ['model' => \Fleetbase\FleetOps\Models\PurchaseRate::class, 'columns' => ['customer_type']] + ['model' => \Fleetbase\FleetOps\Models\PurchaseRate::class, 'columns' => ['customer_type']], ]; foreach ($models as $modelConfig) { diff --git a/server/src/Http/Controllers/Api/v1/DriverController.php b/server/src/Http/Controllers/Api/v1/DriverController.php index e0b32f9d..1c5e9655 100644 --- a/server/src/Http/Controllers/Api/v1/DriverController.php +++ b/server/src/Http/Controllers/Api/v1/DriverController.php @@ -148,7 +148,10 @@ public function update($id, UpdateDriverRequest $request) $userDetails = $request->only(['name', 'password', 'email', 'phone']); // update driver user details - $driver->user->update($userDetails); + $driverUser = $driver->getUser(); + if ($driverUser) { + $driverUser->update($userDetails); + } // vehicle assignment public_id -> uuid if ($request->has('vehicle')) { @@ -776,4 +779,4 @@ private static function phone(?string $phone = null): string return $phone; } -} \ No newline at end of file +} diff --git a/server/src/Http/Controllers/Api/v1/OrderController.php b/server/src/Http/Controllers/Api/v1/OrderController.php index c050b0e6..a2345f0f 100644 --- a/server/src/Http/Controllers/Api/v1/OrderController.php +++ b/server/src/Http/Controllers/Api/v1/OrderController.php @@ -498,7 +498,7 @@ public function query(Request $request) if ($request->filled('on')) { $on = Carbon::parse($request->input('on')); - + $query->where(function ($q) use ($on) { $q->whereDate('created_at', $on); $q->orWhereDate('scheduled_at', $on); @@ -1408,4 +1408,4 @@ public function getEditableEntityFields(string $id, Request $request) return response()->json($entityEditingSettings); } -} \ No newline at end of file +} diff --git a/server/src/Http/Controllers/FleetOpsController.php b/server/src/Http/Controllers/FleetOpsController.php index d8783222..fadafc39 100644 --- a/server/src/Http/Controllers/FleetOpsController.php +++ b/server/src/Http/Controllers/FleetOpsController.php @@ -2,7 +2,6 @@ namespace Fleetbase\FleetOps\Http\Controllers; -use Fleetbase\FleetOps\Models\Order; use Fleetbase\Http\Controllers\FleetbaseController; class FleetOpsController extends FleetbaseController diff --git a/server/src/Http/Controllers/Internal/v1/DriverController.php b/server/src/Http/Controllers/Internal/v1/DriverController.php index 438116ed..4234dd68 100644 --- a/server/src/Http/Controllers/Internal/v1/DriverController.php +++ b/server/src/Http/Controllers/Internal/v1/DriverController.php @@ -255,14 +255,18 @@ function (&$request, &$driver, &$input) { } $input = $input->except(['name', 'password', 'email', 'phone', 'meta', 'avatar_uuid', 'photo_uuid'])->toArray(); - $driver->user->update($userInput); - $driver->flushAttributesCache(); + // Update driver user details + $driverUser = $driver->getUser(); + if ($driverUser) { + $driverUser->update($userInput); + $input['slug'] = $driverUser->slug; + } - $input['slug'] = $driver->user->slug; + // Flush cache + $driver->flushAttributesCache(); }, function ($request, &$driver) { $driver->load(['user']); - if ($driver->user) { $driver->user->setHidden(['driver']); } diff --git a/server/src/Http/Requests/CreateContactRequest.php b/server/src/Http/Requests/CreateContactRequest.php index b17223a1..68cb2c3b 100644 --- a/server/src/Http/Requests/CreateContactRequest.php +++ b/server/src/Http/Requests/CreateContactRequest.php @@ -14,7 +14,7 @@ class CreateContactRequest extends FleetbaseRequest */ public function authorize() { - return request()->session()->has('storefront_key') || request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');; + return request()->session()->has('storefront_key') || request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token'); } /** diff --git a/server/src/Http/Requests/CreateEntityRequest.php b/server/src/Http/Requests/CreateEntityRequest.php index 96a9f7f3..33fdb67c 100644 --- a/server/src/Http/Requests/CreateEntityRequest.php +++ b/server/src/Http/Requests/CreateEntityRequest.php @@ -14,7 +14,7 @@ class CreateEntityRequest extends FleetbaseRequest */ public function authorize() { - return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');; + return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token'); } /** diff --git a/server/src/Http/Requests/CreateIssueRequest.php b/server/src/Http/Requests/CreateIssueRequest.php index c63ea808..9555f242 100644 --- a/server/src/Http/Requests/CreateIssueRequest.php +++ b/server/src/Http/Requests/CreateIssueRequest.php @@ -13,7 +13,7 @@ class CreateIssueRequest extends FleetbaseRequest */ public function authorize() { - return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');; + return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token'); } /** diff --git a/server/src/Http/Requests/CreatePlaceRequest.php b/server/src/Http/Requests/CreatePlaceRequest.php index 926c82ff..55238373 100644 --- a/server/src/Http/Requests/CreatePlaceRequest.php +++ b/server/src/Http/Requests/CreatePlaceRequest.php @@ -16,7 +16,7 @@ class CreatePlaceRequest extends FleetbaseRequest */ public function authorize() { - return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');; + return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token'); } /** diff --git a/server/src/Http/Requests/CreateVehicleRequest.php b/server/src/Http/Requests/CreateVehicleRequest.php index 479438f5..0ac4ccf6 100644 --- a/server/src/Http/Requests/CreateVehicleRequest.php +++ b/server/src/Http/Requests/CreateVehicleRequest.php @@ -14,7 +14,7 @@ class CreateVehicleRequest extends FleetbaseRequest */ public function authorize() { - return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token');; + return request()->session()->has('api_credential') || request()->session()->has('is_sanctum_token'); } /**