Skip to content

Commit

Permalink
Feature: Customer Login and Authentication, Vender Personnel and Flee…
Browse files Browse the repository at this point in the history
…t Management, improved Subcontracting, Tracking Pages, Bugfixes and more
  • Loading branch information
roncodes committed Sep 4, 2024
1 parent fac2832 commit 21068c1
Show file tree
Hide file tree
Showing 160 changed files with 2,795 additions and 575 deletions.
88 changes: 55 additions & 33 deletions addon/components/contact-form-panel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -84,46 +84,68 @@
</div>
</div>
</div>
<div class="flex justify-end w-1/4">
<Badge @status={{this.contact.public_id}} @type="info" @hideStatusDot={{true}} />
</div>
{{#if this.contact.public_id}}
<div class="flex justify-end w-1/4">
<Badge @status={{this.contact.public_id}} @type="info" @hideStatusDot={{true}} />
</div>
{{/if}}
</div>
</Overlay::Header>

<Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 pt-4">
<Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 pt-4 space-y-4">
{{#let (cannot this.savePermission) as |unauthorized|}}
<div class="grid grid-cols-1 text-xs dark:text-gray-100">
<InputGroup @name={{t "fleet-ops.common.name"}}>
<Input @value={{this.contact.name}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.name"}} disabled={{unauthorized}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.title"}}>
<Input @value={{this.contact.title}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.title"}} disabled={{unauthorized}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.internal-id"}}>
<Input @value={{this.contact.internal_id}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.internal-id"}} disabled={{unauthorized}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.email"}}>
<Input @value={{this.contact.email}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.email"}} disabled={{unauthorized}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.phone"}}>
<PhoneInput @value={{this.contact.phone}} @onInput={{fn (mut this.contact.phone)}} class="form-input w-full" disabled={{unauthorized}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.type"}}>
<div class="fleetbase-model-select fleetbase-power-select ember-model-select">
<PowerSelect
@options={{this.contactTypeOptions}}
@selected={{this.contact.type}}
@onChange={{fn (mut this.contact.type)}}
@placeholder="Select contact type"
<ContentPanel @title={{t "fleet-ops.component.contact-form-panel.contact-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"}}>
<Input @value={{this.contact.name}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.name"}} disabled={{unauthorized}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.title"}}>
<Input @value={{this.contact.title}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.title"}} disabled={{unauthorized}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.email"}}>
<Input @value={{this.contact.email}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.email"}} disabled={{unauthorized}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.phone"}}>
<PhoneInput @value={{this.contact.phone}} @onInput={{fn (mut this.contact.phone)}} class="form-input w-full" disabled={{unauthorized}} />
</InputGroup>
<InputGroup @name={{t "fleet-ops.common.internal-id"}}>
<Input @value={{this.contact.internal_id}} @type="text" class="w-full form-input" placeholder={{t "fleet-ops.common.internal-id"}} disabled={{unauthorized}} />
</InputGroup>
<InputGroup @wrapperClass="col-span-2">
<div class="flex items-center justify-between">
<label>
{{t "fleet-ops.common.address"}}
</label>
<div class="mb-1.5 flex flex-row">
<Button
@type="default"
@size="xs"
@icon="edit"
@text={{if this.contact.has_place (t "fleet-ops.component.contact-form-panel.edit") (t "fleet-ops.component.contact-form-panel.new-address")}}
@onClick={{this.editAddress}}
@disabled={{unauthorized}}
/>
</div>
</div>
<ModelSelect
@modelName="place"
@selectedModel={{this.contact.place}}
@placeholder={{t "fleet-ops.component.contact-form-panel.select-address"}}
@triggerClass="form-select form-input"
@infiniteScroll={{false}}
@renderInPlace={{true}}
@onChange={{this.selectContactAddress}}
@disabled={{unauthorized}}
as |type|
as |model|
>
{{smart-humanize type}}
</PowerSelect>
</div>
</InputGroup>
</div>
<div class="flex items-center flex-row justify-between">
<div class="truncate flex-1">{{n-a model.address}}</div>
<Badge @hideStatusDot={{true}} @status="info">{{model.public_id}}</Badge>
</div>
</ModelSelect>
</InputGroup>
</div>
</ContentPanel>
{{/let}}
<Spacer @height="300px" />
</Overlay::Body>
Expand Down
69 changes: 36 additions & 33 deletions addon/components/contact-form-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ export default class ContactFormPanelComponent extends Component {
*/
@tracked context;

/**
* All possible contact types.
*
* @var {String}
*/
@tracked contactTypeOptions = ['contact', 'customer'];

/**
* All possible contact status options.
*
Expand All @@ -38,7 +31,7 @@ export default class ContactFormPanelComponent extends Component {
/**
* Permission needed to update or create record.
*
* @memberof DriverFormPanelComponent
* @memberof ContactFormPanelComponent
*/
@tracked savePermission;

Expand Down Expand Up @@ -93,7 +86,7 @@ export default class ContactFormPanelComponent extends Component {
this.fetch.uploadFile.perform(
file,
{
path: `uploads/${this.currentUser.companyId}/drivers/${this.contact.id}`,
path: `uploads/${this.currentUser.companyId}/contacts/${this.contact.id}`,
subject_uuid: this.contact.id,
subject_type: 'fleet-ops:contact',
type: 'contact_photo',
Expand Down Expand Up @@ -122,36 +115,46 @@ export default class ContactFormPanelComponent extends Component {
}

/**
* Handles cancel button press.
* Edit contact's primary address.
*
* @action
* @returns {any}
* @return {void}
* @memberof ContactFormPanelComponent
*/
@action onPressCancel() {
return contextComponentCallback(this, 'onPressCancel', this.contact);
@action async editAddress() {
let place;

if (this.contact.has_place) {
place = await this.contact.place;
} else {
place = this.store.createRecord('place');
}

return this.contextPanel.focus(place, 'editing', {
onAfterSave: (place) => {
this.selectVendorAddress(place);
this.contextPanel.clear();
},
});
}

/**
* Uploads a file to the server for the contact.
* Select and set the contact's primary address.
*
* @param {File} file
* @param {PlaceModel} place
* @memberof ContactFormPanelComponent
*/
uploadContactPhoto(file) {
this.fetch.uploadFile.perform(
file,
{
path: `uploads/${this.contact.company_uuid}/contacts/${this.contact.slug}`,
subject_uuid: this.contact.id,
subject_type: 'fleet-ops:contact',
type: 'contact_photo',
},
(uploadedFile) => {
this.contact.setProperties({
photo_uuid: uploadedFile.id,
photo_url: uploadedFile.url,
photo: uploadedFile,
});
}
);
@action selectContactAddress(place) {
this.contact.place = place;
this.contact.place_uuid = place.id;
}

/**
* Handles cancel button press.
*
* @action
* @returns {any}
*/
@action onPressCancel() {
return contextComponentCallback(this, 'onPressCancel', this.contact);
}
}
2 changes: 1 addition & 1 deletion addon/components/contact-panel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<h1 class="text-gray-900 dark:text-white text-2xl">{{this.contact.name}}</h1>
<div class="-mt-1">
<div class="flex flex-row items-center">
<span class="text-sm dark:text-blue-400 text-blue-600">{{smart-humanize this.contact.type}}</span>
<span class="text-sm dark:text-blue-400 text-blue-600">{{this.contact.email}}</span>
</div>
</div>
</div>
Expand Down
36 changes: 0 additions & 36 deletions addon/components/contact-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,11 @@ import contextComponentCallback from '@fleetbase/ember-core/utils/context-compon
import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments';

export default class ContactPanelComponent extends Component {
/**
* Service for fetching data.
*
* @type {Service}
*/
@service fetch;

/**
* Service for managing modals.
*
* @type {Service}
*/
@service modalsManager;

/**
* Universe service for managing global data and settings.
*
* @type {Service}
*/
@service universe;

/**
* Ember data store service.
*
* @type {Service}
*/
@service store;

/**
* Service for managing routing within the host app.
*
* @type {Service}
*/
@service hostRouter;

/**
* Service for managing the context panel.
*
* @type {Service}
*/
@service contextPanel;

/**
Expand All @@ -73,7 +38,6 @@ export default class ContactPanelComponent extends Component {
*/
get tabs() {
const registeredTabs = this.universe.getMenuItemsFromRegistry('fleet-ops:component:contact-panel');
// this.universe._createMenuItem('Tracking', null, { icon: 'satellite-dish', component: contactPanelTrackingComponent }),
const defaultTabs = [this.universe._createMenuItem('Details', null, { icon: 'circle-info', component: ContactPanelDetailComponent })];

if (isArray(registeredTabs)) {
Expand Down
20 changes: 12 additions & 8 deletions addon/components/contact-panel/details.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<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.component.contact-panel.details.web-url"}}</div>
<div class="field-name">{{t "fleet-ops.common.name"}}</div>
<div class="field-value">{{n-a @contact.name}}</div>
</div>

Expand All @@ -13,23 +12,28 @@
</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 @contact.internal_id}}</div>
<div class="field-name">{{t "fleet-ops.common.email"}}</div>
<ClickToCopy @value={{@contact.email}} class="field-value">{{n-a @contact.email}}</ClickToCopy>
</div>

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

<div class="field-info-container space-y-2">
<div class="field-name">{{t "fleet-ops.common.email"}}</div>
<div class="field-value">{{n-a @contact.phone}}</div>
<div class="field-name">{{t "fleet-ops.common.internal-id"}}</div>
<div class="field-value">{{n-a @contact.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">{{@contact.type}}</Badge></div>
<div class="field-value"><Badge @status="info" @hideStatusDot={{true}}>{{smart-humanize @contact.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 @contact.address}}</div>
</div>
</div>
</ContentPanel>
Expand Down
2 changes: 1 addition & 1 deletion addon/components/custom-entity-form-panel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</div>
</ContentPanel>
<ContentPanel @title={{t "fleet-ops.component.custom-entity-issue-form-panel.measurements"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
<div class="grid grid-cols-2 gap-1">
<div class="grid grid-cols-2 gap-4">
<InputGroup
@name={{t "fleet-ops.component.custom-entity-issue-form-panel.length"}}
@helpText={{t "fleet-ops.component.custom-entity-issue-form-panel.length-text"}}
Expand Down
Loading

0 comments on commit 21068c1

Please sign in to comment.