Skip to content

Commit

Permalink
Merge pull request #143 from fleetbase/dev-v0.5.25
Browse files Browse the repository at this point in the history
critical patches to consumable api and customer management
  • Loading branch information
roncodes authored Feb 26, 2025
2 parents 226acb7 + c4dfbe3 commit 75cb712
Show file tree
Hide file tree
Showing 19 changed files with 344 additions and 58 deletions.
57 changes: 57 additions & 0 deletions addon/components/customer-form-panel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,63 @@

<Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 pt-4 space-y-4">
{{#let (cannot this.savePermission) as |unauthorized|}}
<ContentPanel
@title={{t "fleet-ops.component.customer-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.customer-form-panel.user-account"}} @helpText={{t "fleet-ops.component.customer-form-panel.user-account-help-text"}}>
<ModelSelect
@modelName="user"
@selectedModel={{this.customer.user}}
@placeholder={{t "fleet-ops.component.customer-form-panel.select-user"}}
@query={{hash doesnt_have_contact=true}}
@triggerClass="form-select form-input"
@infiniteScroll={{false}}
@renderInPlace={{true}}
@onChange={{fn (mut this.customer.user)}}
@permission="fleet-ops update-user-for customer"
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 flex flex-row items-center leading-4">
<FaIcon @icon="envelope" @size="sm" class="mr-1 opacity-75" />
<span>{{n-a model.email}}</span>
</div>
<div class="text-xs flex flex-row items-center leading-4">
<FaIcon @icon="phone" @size="sm" class="mr-1 opacity-75" />
<span>{{n-a model.phone}}</span>
</div>
</div>
</div>
</ModelSelect>
</InputGroup>
</div>
{{#if this.customer.user}}
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4 text-xs dark:text-gray-100">
<InputGroup @name={{t "fleet-ops.common.name"}} @wrapperClass="col-span-2 mb-0i">
<Input @value={{this.customer.user.name}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.name"}} disabled={{true}} />
</InputGroup>

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

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

<ContentPanel @title={{t "fleet-ops.component.customer-form-panel.customer-details"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
<div class="grid grid-cols-2 gap-4 text-xs dark:text-gray-100 no-input-group-padding">
<InputGroup @name={{t "fleet-ops.common.name"}}>
Expand Down
58 changes: 58 additions & 0 deletions addon/components/customer-form-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default class CustomerFormPanelComponent extends Component {
@service notifications;
@service hostRouter;
@service contextPanel;
@service modalsManager;
@service universe;

/**
* Overlay context.
Expand All @@ -28,6 +30,62 @@ export default class CustomerFormPanelComponent extends Component {
*/
@tracked savePermission;

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

this.modalsManager.show('modals/user-form', {
title: 'Create a new user',
user,
formPermission: 'iam create 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: async (modal) => {
modal.startLoading();

try {
await user.save();
this.notifications.success('New user created successfully!');
modal.done();
} catch (error) {
this.notifications.serverError(error);
modal.stopLoading();
}
},
});
},
},
];

/**
* Constructs the component and applies initial state.
*/
Expand Down
84 changes: 48 additions & 36 deletions addon/components/customer-panel/details.hbs
Original file line number Diff line number Diff line change
@@ -1,40 +1,52 @@
<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-1 gap-2 lg:grid-cols-2 lg:gap-4 text-xs dark:text-gray-100">
<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.name"}}</div>
<div class="field-value">{{n-a @customer.name}}</div>
<div class="flex-1 space-y-4">
<ContentPanel @title={{t "fleet-ops.component.customer-panel.user-account"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-900">
<div class="grid grid-cols-2 gap-4 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 @customer.name}}</div>
</div>
<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.email"}}</div>
<ClickToCopy @value={{@customer.email}} class="field-value">{{n-a @customer.email}}</ClickToCopy>
</div>
<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.phone"}}</div>
<ClickToCopy @value={{@customer.phone}} class="field-value">{{n-a @customer.phone}}</ClickToCopy>
</div>
</div>

<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.title"}}</div>
<div class="field-value">{{n-a @customer.title}}</div>
</ContentPanel>
<ContentPanel @title={{t "fleet-ops.common.details"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-900">
<div class="grid grid-cols-1 gap-2 lg:grid-cols-2 lg:gap-4 text-xs dark:text-gray-100">
<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.name"}}</div>
<div class="field-value">{{n-a @customer.name}}</div>
</div>
<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.title"}}</div>
<div class="field-value">{{n-a @customer.title}}</div>
</div>
<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.email"}}</div>
<ClickToCopy @value={{@customer.email}} class="field-value">{{n-a @customer.email}}</ClickToCopy>
</div>
<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.email"}}</div>
<ClickToCopy @value={{@customer.phone}} class="field-value">{{n-a @customer.phone}}</ClickToCopy>
</div>
<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.internal-id"}}</div>
<div class="field-value">{{n-a @customer.internal_id}}</div>
</div>
<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.type"}}</div>
<div class="field-value"><Badge @status="info" @hideStatusDot={{true}}>{{smart-humanize @customer.type}}</Badge></div>
</div>
<div class="field-info-container col-span-2">
<div class="field-name">{{t "fleet-ops.common.address"}}</div>
<div class="field-value">{{n-a @customer.address}}</div>
</div>
</div>

<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.email"}}</div>
<ClickToCopy @value={{@customer.email}} class="field-value">{{n-a @customer.email}}</ClickToCopy>
</div>

<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.email"}}</div>
<ClickToCopy @value={{@customer.phone}} class="field-value">{{n-a @customer.phone}}</ClickToCopy>
</div>

<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.internal-id"}}</div>
<div class="field-value">{{n-a @customer.internal_id}}</div>
</div>

<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.type"}}</div>
<div class="field-value"><Badge @status="info" @hideStatusDot={{true}}>{{smart-humanize @customer.type}}</Badge></div>
</div>

<div class="field-info-container col-span-2">
<div class="field-name">{{t "fleet-ops.common.address"}}</div>
<div class="field-value">{{n-a @customer.address}}</div>
</div>
</div>
</ContentPanel>
</ContentPanel>
</div>
</div>
2 changes: 1 addition & 1 deletion addon/components/customer/orders.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="portal-content-wrapper">
{{#let (and this.newOrder this.map) as |isCreatingOrder|}}
<div id="fleetops-customer-orders-container" class="flex {{if isCreatingOrder 'collapse-sidebar'}}">
<div id="fleetops-customer-orders-sidebar" class="w-1/4 transition-all duration-500">
<div id="fleetops-customer-orders-sidebar" class="transition-all duration-500">
<div class="customer-orders-section-header">
<div class="flex flex-row items-center justify-between mb-4">
<div class="flex flex-row items-center">
Expand Down
11 changes: 9 additions & 2 deletions addon/components/driver-form-panel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,22 @@
</div>
<div class="flex flex-col">
<div class="font-semibold">{{model.name}}</div>
<div class="text-xs">{{n-a model.phone}}</div>
<div class="text-xs flex flex-row items-center leading-4">
<FaIcon @icon="envelope" @size="sm" class="mr-1 opacity-75" />
<span>{{n-a model.email}}</span>
</div>
<div class="text-xs flex flex-row items-center leading-4">
<FaIcon @icon="phone" @size="sm" class="mr-1 opacity-75" />
<span>{{n-a model.phone}}</span>
</div>
</div>
</div>
</ModelSelect>
</InputGroup>
</div>
{{#if this.driver.user}}
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4 text-xs dark:text-gray-100">
<InputGroup @name={{t "fleet-ops.common.name"}} @wrapperClass="col-span-2">
<InputGroup @name={{t "fleet-ops.common.name"}} @wrapperClass="col-span-2 mb-0i">
<Input @value={{this.driver.user.name}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.name"}} disabled={{true}} />
</InputGroup>

Expand Down
35 changes: 33 additions & 2 deletions addon/styles/fleetops-engine.css
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,8 @@ body[data-theme='dark'] .order-progress-bar > .order-progress-bar-wrapper > .ord
bottom: 0;
top: 0;
right: 0;
width: 40%;
max-width: 40%;
width: 52%;
max-width: 52%;
height: 100%;
padding: 1rem;
}
Expand Down Expand Up @@ -981,6 +981,37 @@ body[data-theme='light'] .flb--modal.flb--default-modal.finalize-service-quote-p

#fleetops-customer-orders-container #fleetops-customer-orders-sidebar {
margin-right: 1rem;
width: 50%;
}

@media (width >= 992px) {
#fleetops-customer-orders-container #fleetops-customer-orders-sidebar {
width: 50%;
}
}

@media (width >= 1200px) {
#fleetops-customer-orders-container #fleetops-customer-orders-sidebar {
width: 35%;
}
}

@media (width >= 1400px) {
#fleetops-customer-orders-container #fleetops-customer-orders-sidebar {
width: 30%;
}
}

@media (width >= 1700px) {
#fleetops-customer-orders-container #fleetops-customer-orders-sidebar {
width: 25%;
}
}

@media (width >= 1900px) {
#fleetops-customer-orders-container #fleetops-customer-orders-sidebar {
width: 20%;
}
}

#fleetops-customer-orders-container.collapse-sidebar #fleetops-customer-orders-sidebar {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/fleetops-api",
"version": "0.5.24",
"version": "0.5.25",
"description": "Fleet & Transport Management Extension for Fleetbase",
"keywords": [
"fleetbase-extension",
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.5.24",
"version": "0.5.25",
"description": "Fleet & Transport Management Extension for Fleetbase",
"repository": "https://github.com/fleetbase/fleetops",
"license": "AGPL-3.0-or-later",
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.5.24",
"version": "0.5.25",
"description": "Fleet & Transport Management Extension for Fleetbase",
"fleetbase": {
"route": "fleet-ops"
Expand Down Expand Up @@ -50,9 +50,9 @@
"@fortawesome/fontawesome-svg-core": "6.4.0",
"@fortawesome/free-brands-svg-icons": "6.4.0",
"@fortawesome/free-solid-svg-icons": "6.4.0",
"@stripe/connect-js": "^3.3.10",
"@joint/core": "^4.0.1",
"@joint/layout-directed-graph": "^4.0.1",
"@stripe/connect-js": "^3.3.10",
"@terraformer/spatial": "^2.1.2",
"@zestia/ember-dragula": "^12.0.0",
"broccoli-funnel": "^3.0.8",
Expand Down
Loading

0 comments on commit 75cb712

Please sign in to comment.