Skip to content

Commit

Permalink
Merge pull request #106 from fleetbase/dev-v0.4.27
Browse files Browse the repository at this point in the history
v0.4.27
  • Loading branch information
roncodes authored Apr 30, 2024
2 parents af22992 + 251bc3c commit 46a2fa7
Show file tree
Hide file tree
Showing 15 changed files with 302 additions and 137 deletions.
109 changes: 66 additions & 43 deletions addon/components/driver-form-panel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,58 +61,81 @@

<Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 space-y-4 pt-4">
<div class="flex-1 space-y-4">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-2 text-xs dark:text-gray-100">
<InputGroup @name={{t "fleet-ops.common.name"}} @wrapperClass="col-span-2">
<Input @value={{this.driver.name}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.name"}} />
</InputGroup>
<ContentPanel @title={{t "fleet-ops.component.driver-form-panel.user-account"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800" @actionButtons={{this.userAccountActionButtons}}>
<div class="mb-4">
<InputGroup @name={{t "fleet-ops.component.driver-form-panel.user-account"}} @helpText={{t "fleet-ops.component.driver-form-panel.user-account-help-text"}}>
<ModelSelect @modelName="user" @selectedModel={{this.driver.user}} @placeholder="Select User" @query={{hash doesnt_have_driver=true}} @triggerClass="form-select form-input" @infiniteScroll={{false}} @renderInPlace={{true}} @onChange={{fn (mut this.driver.user)}} as |model|>
<div class="flex flex-row">
<div class="mr-2 w-6">
<Image src={{model.avatar_url}} @fallbackSrc={{config "defaultValues.userImage"}} alt={{this.user.name}} class="w-6 h-6 rounded-md" />
</div>
<div class="flex flex-col">
<div class="font-semibold">{{model.name}}</div>
<div class="text-xs">{{n-a model.phone}}</div>
</div>
</div>
</ModelSelect>
</InputGroup>
</div>
{{#if this.driver.user}}
<div class="grid grid-cols-1 lg:grid-cols-2 gap-2 text-xs dark:text-gray-100">
<InputGroup @name={{t "fleet-ops.common.name"}} @wrapperClass="col-span-2">
<Input @value={{this.driver.user.name}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.name"}} disabled={{true}} />
</InputGroup>

<InputGroup @name={{t "fleet-ops.common.internal-id"}}>
<Input @value={{this.driver.internal_id}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.internal-id"}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.email"}} @wrapperClass="mb-0i">
<Input @value={{this.driver.user.email}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.email"}} disabled={{true}} />
</InputGroup>

<InputGroup @name={{t "fleet-ops.common.driver-license"}}>
<Input @value={{this.driver.drivers_license_number}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.driver-license"}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.phone"}} @wrapperClass="mb-0i">
<PhoneInput @value={{this.driver.user.phone}} @onInput={{fn (mut this.driver.phone)}} class="form-input w-full" disabled={{true}} />
</InputGroup>
</div>
{{/if}}
</ContentPanel>

<InputGroup @name={{t "fleet-ops.common.email"}}>
<Input @value={{this.driver.email}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.email"}} />
</InputGroup>
<ContentPanel @title={{t "fleet-ops.component.driver-form-panel.driver-details"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-2 text-xs dark:text-gray-100">
<InputGroup @name={{t "fleet-ops.common.internal-id"}}>
<Input @value={{this.driver.internal_id}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.internal-id"}} />
</InputGroup>

<InputGroup @name={{t "fleet-ops.common.phone"}}>
<PhoneInput @value={{this.driver.phone}} @onInput={{fn (mut this.driver.phone)}} class="form-input w-full" />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.driver-license"}}>
<Input @value={{this.driver.drivers_license_number}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.driver-license"}} />
</InputGroup>

<InputGroup @name={{t "fleet-ops.component.driver-form-panel.vendor"}}>
<ModelSelect @modelName="vendor" @selectedModel={{this.driver.vendor}} @placeholder="Select Vendor" @triggerClass="form-select form-input" @infiniteScroll={{false}} @renderInPlace={{true}} @onChange={{fn (mut this.driver.vendor)}} as |model|>
{{model.name}}
</ModelSelect>
</InputGroup>
<InputGroup @name={{t "fleet-ops.component.driver-form-panel.vendor"}}>
<ModelSelect @modelName="vendor" @selectedModel={{this.driver.vendor}} @placeholder="Select Vendor" @triggerClass="form-select form-input" @infiniteScroll={{false}} @renderInPlace={{true}} @onChange={{fn (mut this.driver.vendor)}} as |model|>
{{model.name}}
</ModelSelect>
</InputGroup>

<InputGroup @name={{t "fleet-ops.common.vehicle"}}>
<ModelSelect @modelName="vehicle" @selectedModel={{this.driver.vehicle}} @placeholder={{t "fleet-ops.component.driver-form-panel.select-vehicle"}} @triggerClass="form-select form-input" @infiniteScroll={{false}} @renderInPlace={{true}} @onChange={{fn (mut this.driver.vehicle)}} as |model|>
{{model.display_name}}
</ModelSelect>
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.vehicle"}}>
<ModelSelect @modelName="vehicle" @selectedModel={{this.driver.vehicle}} @placeholder={{t "fleet-ops.component.driver-form-panel.select-vehicle"}} @triggerClass="form-select form-input" @infiniteScroll={{false}} @renderInPlace={{true}} @onChange={{fn (mut this.driver.vehicle)}} as |model|>
{{model.display_name}}
</ModelSelect>
</InputGroup>

<InputGroup @name={{t "fleet-ops.common.city"}}>
<Input @value={{this.driver.city}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.city"}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.city"}}>
<Input @value={{this.driver.city}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.city"}} />
</InputGroup>

<InputGroup @name={{t "fleet-ops.common.country"}}>
<CountrySelect class="w-full form-input form-select form-datalist" @value={{this.driver.country}} @onChange={{fn (mut this.driver.country)}} placeholder={{t "fleet-ops.common.country"}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.country"}}>
<CountrySelect class="w-full form-input form-select form-datalist" @value={{this.driver.country}} @onChange={{fn (mut this.driver.country)}} placeholder={{t "fleet-ops.common.country"}} />
</InputGroup>

<InputGroup @name={{t "fleet-ops.common.status"}}>
<div class="fleetbase-model-select fleetbase-power-select ember-model-select">
<PowerSelect @options={{this.driverStatusOptions}} @selected={{this.driver.status}} @onChange={{fn (mut this.driver.status)}} @placeholder={{t "fleet-ops.common.status"}} @triggerClass="form-select form-input" as |status|>
{{smart-humanize status}}
</PowerSelect>
</div>
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.coordinates"}} @wrapperClass="col-span-2">
<CoordinatesInput @value={{this.driver.location}} @onChange={{this.onCoordinatesChanged}} @onGeocode={{this.onAutocomplete}} @onUpdatedFromMap={{this.onCoordinatesChanged}} @onInit={{this.setCoordinatesInput}} @renderInPlace={{false}} />
</InputGroup>
</div>
<InputGroup @name={{t "fleet-ops.common.status"}}>
<div class="fleetbase-model-select fleetbase-power-select ember-model-select">
<PowerSelect @options={{this.driverStatusOptions}} @selected={{this.driver.status}} @onChange={{fn (mut this.driver.status)}} @placeholder={{t "fleet-ops.common.status"}} @triggerClass="form-select form-input" as |status|>
{{smart-humanize status}}
</PowerSelect>
</div>
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.coordinates"}} @wrapperClass="col-span-2">
<CoordinatesInput @value={{this.driver.location}} @onChange={{this.onCoordinatesChanged}} @onGeocode={{this.onAutocomplete}} @onUpdatedFromMap={{this.onCoordinatesChanged}} @onInit={{this.setCoordinatesInput}} @renderInPlace={{false}} />
</InputGroup>
</div>
</ContentPanel>

<ContentPanel @title={{t "fleet-ops.component.avatar-picker.avatar"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
<AvatarPicker @model={{this.driver}} @defaultAvatar={{config "defaultValues.driverAvatar"}} />
Expand Down
60 changes: 60 additions & 0 deletions addon/components/driver-form-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default class DriverFormPanelComponent extends Component {
* @service fetch
*/
@service fetch;

/**
* @service intl
*/
Expand Down Expand Up @@ -46,6 +47,11 @@ export default class DriverFormPanelComponent extends Component {
*/
@service contextPanel;

/**
* @service modalsManager
*/
@service modalsManager;

/**
* Overlay context.
* @type {any}
Expand All @@ -70,6 +76,60 @@ export default class DriverFormPanelComponent extends Component {
*/
@tracked coordinatesInputComponent;

/**
* Action to create a new user quickly
*
* @memberof DriverFormPanelComponent
*/
userAccountActionButtons = [
{
text: 'Create new user',
icon: 'user-plus',
size: 'xs',
onClick: () => {
const user = this.store.createRecord('user', {
status: 'pending',
type: 'user',
});

this.modalsManager.show('modals/user-form', {
title: 'Create a new user',
user,
uploadNewPhoto: (file) => {
this.fetch.uploadFile.perform(
file,
{
path: `uploads/${this.currentUser.companyId}/users/${user.slug}`,
key_uuid: user.id,
key_type: 'user',
type: 'user_photo',
},
(uploadedFile) => {
user.setProperties({
avatar_uuid: uploadedFile.id,
avatar_url: uploadedFile.url,
avatar: uploadedFile,
});
}
);
},
confirm: (modal) => {
modal.startLoading();

return user
.save()
.then(() => {
this.notifications.success('New user created successfully!');
})
.catch((error) => {
this.notifications.serverError(error);
});
},
});
},
},
];

/**
* Constructs the component and applies initial state.
*/
Expand Down
84 changes: 45 additions & 39 deletions addon/components/driver-panel/details.hbs
Original file line number Diff line number Diff line change
@@ -1,44 +1,50 @@
<div class="p-4">
<ContentPanel @title={{t "fleet-ops.common.details"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-900">
<div class="grid grid-cols-2 gap-2 text-xs md:mb-6 dark:text-gray-100">
<div class="field-info-container md:col-span-3">
<div class="field-name">{{t "fleet-ops.common.name"}}</div>
<div class="field-value">{{n-a @driver.name}}</div>
</div>
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.id"}}</div>
<ClickToCopy @value={{@driver.public_id}} class="field-value">{{n-a @driver.public_id}}</ClickToCopy>
</div>
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.internal-id"}}</div>
<div class="field-value">{{n-a @driver.internal_id}}</div>
</div>
<div class="field-info-container md:col-span-3">
<div class="field-name">{{t "fleet-ops.common.driver-license"}}</div>
<div class="field-value">{{n-a @driver.drivers_license_number}}</div>
</div>
<div class="field-info-container md:col-span-3">
<div class="field-name">{{t "fleet-ops.common.email"}}</div>
<ClickToCopy @value={{@driver.email}} class="field-value">{{n-a @driver.email}}</ClickToCopy>
</div>
<div class="field-info-container md:col-span-3">
<div class="field-name">{{t "fleet-ops.common.phone"}}</div>
<ClickToCopy @value={{@driver.phone}} class="field-value">{{n-a @driver.phone}}</ClickToCopy>
</div>
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.city"}}</div>
<div class="field-value">{{n-a @driver.city}}</div>
</div>
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.country"}}</div>
<div class="field-value">
<CountryName @country={{@driver.country}} />
<div class="flex-1 space-y-4">
<ContentPanel @title={{t "fleet-ops.component.driver-panel.user-account"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-900">
<div class="grid grid-cols-2 gap-2 text-xs dark:text-gray-100">
<div class="field-info-container md:col-span-3">
<div class="field-name">{{t "fleet-ops.common.name"}}</div>
<div class="field-value">{{n-a @driver.name}}</div>
</div>
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.email"}}</div>
<ClickToCopy @value={{@driver.email}} class="field-value">{{n-a @driver.email}}</ClickToCopy>
</div>
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.phone"}}</div>
<ClickToCopy @value={{@driver.phone}} class="field-value">{{n-a @driver.phone}}</ClickToCopy>
</div>
</div>
<div class="field-info-container md:col-span-3">
<div class="field-name">{{t "fleet-ops.common.coordinates"}}</div>
<div class="field-value">{{point-coordinates @driver.location}}</div>
</ContentPanel>
<ContentPanel @title={{t "fleet-ops.component.driver-panel.driver-details"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-900">
<div class="grid grid-cols-2 gap-2 text-xs dark:text-gray-100">
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.id"}}</div>
<ClickToCopy @value={{@driver.public_id}} class="field-value">{{n-a @driver.public_id}}</ClickToCopy>
</div>
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.internal-id"}}</div>
<div class="field-value">{{n-a @driver.internal_id}}</div>
</div>
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.driver-license"}}</div>
<div class="field-value">{{n-a @driver.drivers_license_number}}</div>
</div>
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.city"}}</div>
<div class="field-value">{{n-a @driver.city}}</div>
</div>
<div class="field-info-container">
<div class="field-name">{{t "fleet-ops.common.country"}}</div>
<div class="field-value">
<CountryName @country={{@driver.country}} />
</div>
</div>
<div class="field-info-container md:col-span-3">
<div class="field-name">{{t "fleet-ops.common.coordinates"}}</div>
<div class="field-value">{{point-coordinates @driver.location}}</div>
</div>
</div>
</div>
</ContentPanel>
</ContentPanel>
</div>
</div>
10 changes: 8 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.26",
"version": "0.4.27",
"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.18",
"fleetbase/core-api": "^1.4.20",
"barryvdh/laravel-dompdf": "^2.0",
"brick/geo": "0.7.2",
"cknow/laravel-money": "^7.1",
Expand All @@ -42,6 +42,12 @@
"phpstan/phpstan": "^1.10.38",
"symfony/var-dumper": "^5.4.29"
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/fleetbase/laravel-model-caching"
}
],
"autoload": {
"psr-4": {
"Fleetbase\\FleetOps\\": "server/src/",
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.26",
"version": "0.4.27",
"description": "Fleet & Transport Management Extension for Fleetbase",
"repository": "https://github.com/fleetbase/fleetops",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/fleetops-engine",
"version": "0.4.26",
"version": "0.4.27",
"description": "Fleet & Transport Management Extension for Fleetbase",
"fleetbase": {
"route": "fleet-ops"
Expand Down
Loading

0 comments on commit 46a2fa7

Please sign in to comment.