Skip to content

Commit

Permalink
Merge pull request #114 from fleetbase/dev-v0.5.0
Browse files Browse the repository at this point in the history
v0.5.0
  • Loading branch information
roncodes authored Jul 2, 2024
2 parents cfc3b2e + 307be2c commit 024761d
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 45 deletions.
11 changes: 11 additions & 0 deletions addon/controllers/operations/orders/index/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ export default class OperationsOrdersIndexNewController extends BaseController {
return renderableComponents;
}

get renderableEntityInputComponents() {
const renderableComponents = this.universe.getRenderableComponentsFromRegistry('fleet-ops:template:operations:orders:new:entities-input');
return renderableComponents;
}

@not('isServicable') isNotServicable;
@alias('currentUser.latitude') userLatitude;
@alias('currentUser.longitude') userLongitude;
Expand Down Expand Up @@ -1418,6 +1423,12 @@ export default class OperationsOrdersIndexNewController extends BaseController {
this.entities.pushObject(entity);
}

@action addEntities(entities = []) {
if (isArray(entities)) {
this.entities.pushObjects(entities);
}
}

@action addEntity(importId = null) {
const entity = this.store.createRecord('entity', {
_import_id: importId,
Expand Down
2 changes: 2 additions & 0 deletions addon/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ export default class FleetOpsEngine extends Engine {
// create all registries necessary
universe.createRegistries([
'engine:fleet-ops',
'component:live-map-drawer',
'component:vehicle-panel',
'component:driver-panel',
'component:order-config-manager',
'contextmenu:vehicle',
'contextmenu:driver',
'fleet-ops:template:operations:orders:view',
'fleet-ops:template:operations:orders:new',
'fleet-ops:template:operations:orders:new:entities-input',
]);
};
}
Expand Down
7 changes: 6 additions & 1 deletion addon/templates/operations/orders/index/new.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@

{{#if this.renderableComponents}}
{{#each this.renderableComponents as |renderableComponent|}}
{{component renderableComponent order=this.order}}
{{component renderableComponent order=this.order controller=this}}
{{/each}}
{{/if}}

Expand Down Expand Up @@ -568,6 +568,11 @@
</div>
</DropdownButton>
{{/if}}
{{#if this.renderableEntityInputComponents}}
{{#each this.renderableEntityInputComponents as |renderableEntityInputComponent|}}
{{component renderableEntityInputComponent order=this.order controller=this}}
{{/each}}
{{/if}}
</div>
{{/if}}
{{#if this.isCsvImportedOrder}}
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/fleetops-api",
"version": "0.4.30",
"version": "0.5.0",
"description": "Fleet & Transport Management Extension for Fleetbase",
"keywords": [
"fleetbase-extension",
Expand All @@ -22,7 +22,7 @@
],
"require": {
"php": "^8.0",
"fleetbase/core-api": "^1.4.25",
"fleetbase/core-api": "^1.4.26",
"barryvdh/laravel-dompdf": "^2.0",
"brick/geo": "0.7.2",
"cknow/laravel-money": "^7.1",
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Fleet-Ops",
"version": "0.4.30",
"version": "0.5.0",
"description": "Fleet & Transport Management Extension for Fleetbase",
"repository": "https://github.com/fleetbase/fleetops",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/fleetops-engine",
"version": "0.4.30",
"version": "0.5.0",
"description": "Fleet & Transport Management Extension for Fleetbase",
"fleetbase": {
"route": "fleet-ops"
Expand Down Expand Up @@ -43,7 +43,7 @@
"dependencies": {
"@babel/core": "^7.23.2",
"@fleetbase/ember-core": "^0.2.11",
"@fleetbase/ember-ui": "^0.2.16",
"@fleetbase/ember-ui": "^0.2.17",
"@fleetbase/fleetops-data": "^0.1.15",
"@fleetbase/leaflet-routing-machine": "^3.2.16",
"@fortawesome/ember-fontawesome": "^0.4.1",
Expand Down
51 changes: 21 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 10 additions & 7 deletions server/src/Http/Controllers/Api/v1/DriverController.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class DriverController extends Controller
/**
* Creates a new Fleetbase Driver resource.
*
* @param \Fleetbase\Http\Requests\CreateDriverRequest $request
*
* @return \Fleetbase\Http\Resources\Driver
*/
public function create(CreateDriverRequest $request)
Expand All @@ -52,7 +50,12 @@ public function create(CreateDriverRequest $request)
$userDetails = $request->only(['name', 'password', 'email', 'phone', 'timezone']);

// Get current company session
$company = Auth::getCompany();
$company = $request->has('company') ? Auth::getCompanyFromRequest($request) : Auth::getCompany();

// Debugging: Ensure company is retrieved correctly
if (!$company) {
return response()->apiError('Company not found.');
}

// Apply user infos
$userDetails = User::applyUserInfoFromRequest($request, $userDetails);
Expand All @@ -74,29 +77,29 @@ public function create(CreateDriverRequest $request)

// set user id
$input['user_uuid'] = $user->uuid;
$input['company_uuid'] = $company->uuid;
$input['company_uuid'] = $company->uuid; // Ensure correct company_uuid is set

// vehicle assignment public_id -> uuid
if ($request->has('vehicle')) {
$input['vehicle_uuid'] = Utils::getUuid('vehicles', [
'public_id' => $request->input('vehicle'),
'company_uuid' => session('company'),
'company_uuid' => $company->uuid, // Use $company->uuid instead of session
]);
}

// vendor assignment public_id -> uuid
if ($request->has('vendor')) {
$input['vendor_uuid'] = Utils::getUuid('vendors', [
'public_id' => $request->input('vendor'),
'company_uuid' => session('company'),
'company_uuid' => $company->uuid, // Use $company->uuid instead of session
]);
}

// order|alias:job assignment public_id -> uuid
if ($request->has('job')) {
$input['current_job_uuid'] = Utils::getUuid('orders', [
'public_id' => $request->input('job'),
'company_uuid' => session('company'),
'company_uuid' => $company->uuid, // Use $company->uuid instead of session
]);
}

Expand Down
2 changes: 2 additions & 0 deletions server/src/Http/Controllers/Api/v1/IssueController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function create(CreateIssueRequest $request)
'type',
'report',
'priority',
'status',
]);

// Find driver who is reporting
Expand Down Expand Up @@ -83,6 +84,7 @@ public function update($id, UpdateIssueRequest $request)
'type',
'report',
'priority',
'status',
]);

// update the issue
Expand Down
4 changes: 3 additions & 1 deletion server/src/Http/Controllers/Api/v1/NavigatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Fleetbase\FleetOps\Http\Controllers\Api\v1;

use Fleetbase\Http\Controllers\Controller;
use Fleetbase\Models\Company;
use Fleetbase\Models\Setting;

class NavigatorController extends Controller
Expand All @@ -25,7 +26,8 @@ class NavigatorController extends Controller
*/
public function getDriverOnboardSettings($companyId)
{
$driverOnboardSettings = Setting::where('key', 'fleet-ops.driver-onboard-settings.' . $companyId)->value('value');
$company = Company::select()->where('public_id', $companyId)->first();
$driverOnboardSettings = Setting::where('key', 'fleet-ops.driver-onboard-settings.' . $company->uuid)->value('value');
if (!$driverOnboardSettings) {
$driverOnboardSettings = [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function listOrganizations(Request $request)
$companies = Company::whereHas('users')->get()->map(function ($company) {
return [
'name' => $company->name,
'uuid' => $company->uuid,
'id' => $company->public_id,
];
});

Expand Down

0 comments on commit 024761d

Please sign in to comment.