-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from fleetbase/dev-v0.4.24
v0.4.24
- Loading branch information
Showing
38 changed files
with
600 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<ContentPanel @title={{t "fleet-ops.component.driver-onboard-settings.driver-onboard-settings"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800 mb-4"> | ||
{{#if this.driverOnboardSettingsLoaded}} | ||
<InputGroup> | ||
<div class="flex items-center"> | ||
<Toggle @isToggled={{this.driverOnboardSettings.enableDriverOnboardFromApp}} @onToggle={{this.enableDriverOnboard}} @label={{t "fleet-ops.component.driver-onboard-settings.enable-driver-onboard-from-app"}} @helpText={{t "fleet-ops.component.driver-onboard-settings.enable-driver-onboard-from-app-help-text"}} /> | ||
</div> | ||
</InputGroup> | ||
{{#if this.driverOnboardSettings.enableDriverOnboardFromApp}} | ||
<InputGroup @name={{t "fleet-ops.component.driver-onboard-settings.select-onboard-method"}} @helpText={{t "fleet-ops.component.driver-onboard-settings.select-onboard-method-help-text"}}> | ||
<Select class="w-full flex-1" @value={{this.driverOnboardSettings.driverOnboardAppMethod}} @options={{this.driverOnboardMethods}} @placeholder={{t "fleet-ops.component.driver-onboard-settings.select-onboard-method"}} @onSelect={{this.selectDriverOnboardMethod}} /> | ||
</InputGroup> | ||
<InputGroup> | ||
<div class="flex items-center"> | ||
<Toggle @isToggled={{this.driverOnboardSettings.driverMustProvideOnboardDocuments}} @onToggle={{this.enableDriverOnboardDocuments}} @label={{t "fleet-ops.component.driver-onboard-settings.require-driver-to-upload-onboard-documents"}} @helpText={{t "fleet-ops.component.driver-onboard-settings.require-driver-to-upload-onboard-documents-help-text"}} /> | ||
</div> | ||
</InputGroup> | ||
{{#if this.driverOnboardSettings.driverMustProvideOnboardDocuments}} | ||
<InputGroup> | ||
<ArrayInput @data={{this.driverOnboardSettings.requiredOnboardDocuments}} @placeholder={{t "fleet-ops.component.driver-onboard-settings.enter-document-name"}} @onDataChanged={{this.onOnboardDocumentsChanged}} @addButtonText={{t "fleet-ops.component.driver-onboard-settings.add-onboard-document"}}> | ||
<InputLabel @labelText={{t "fleet-ops.component.driver-onboard-settings.required-onboard-documents"}} @helpText={{t "fleet-ops.component.driver-onboard-settings.required-onboard-documents-help-text"}} /> | ||
</ArrayInput> | ||
</InputGroup> | ||
{{/if}} | ||
{{/if}} | ||
<div class="mt-3 flex items-center mb-4"> | ||
<Button @type="primary" @size="lg" @icon="save" @text={{t "fleet-ops.common.save-changes"}} @onClick={{perform this.saveDriverOnboardSettings}} @isLoading={{not this.saveDriverOnboardSettings.isIdle}} /> | ||
</div> | ||
{{/if}} | ||
</ContentPanel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { inject as service } from '@ember/service'; | ||
import { action } from '@ember/object'; | ||
import { task } from 'ember-concurrency-decorators'; | ||
|
||
export default class DriverOnboardSettingsComponent extends Component { | ||
@service fetch; | ||
@service currentUser; | ||
@tracked companyId; | ||
@tracked driverOnboardSettingsLoaded = false; | ||
@tracked driverOnboardSettings = {}; | ||
@tracked driverOnboardMethods = ['invite', 'button']; | ||
|
||
constructor() { | ||
super(...arguments); | ||
this.companyId = this.currentUser.companyId; | ||
this.getDriverOnboardSettings.perform(); | ||
} | ||
|
||
@action enableDriverOnboard(enableDriverOnboardFromApp) { | ||
this.updateDriverOnboardSettings({ enableDriverOnboardFromApp }); | ||
} | ||
|
||
@action enableDriverOnboardDocuments(driverMustProvideOnboardDocuments) { | ||
this.updateDriverOnboardSettings({ driverMustProvideOnboardDocuments }); | ||
} | ||
|
||
@action selectDriverOnboardMethod(driverOnboardAppMethod) { | ||
this.updateDriverOnboardSettings({ driverOnboardAppMethod }); | ||
} | ||
|
||
@action onOnboardDocumentsChanged(requiredOnboardDocuments) { | ||
requiredOnboardDocuments = requiredOnboardDocuments.filter((documentName) => typeof documentName === 'string'); | ||
this.updateDriverOnboardSettings({ requiredOnboardDocuments }); | ||
} | ||
|
||
@task *saveDriverOnboardSettings() { | ||
const { driverOnboardSettings } = this; | ||
const driverOnboardSettingsResponse = yield this.fetch.post('fleet-ops/settings/driver-onboard-settings', { driverOnboardSettings }); | ||
if (driverOnboardSettings?.enableDriverOnboardFromApp == false) this.driverOnboardSettings = driverOnboardSettingsResponse?.driverOnboardSettings; | ||
} | ||
|
||
@task *getDriverOnboardSettings() { | ||
const companyId = this.currentUser.companyId; | ||
const { driverOnboardSettings } = yield this.fetch.get(`fleet-ops/settings/driver-onboard-settings/${companyId}`); | ||
this.driverOnboardSettings = driverOnboardSettings; | ||
|
||
if (this.companyDoesntHaveDriverOnboardSettings()) { | ||
this.updateDriverOnboardSettings({ | ||
enableDriverOnboardFromApp: false, | ||
driverOnboardAppMethod: 'invite', | ||
driverMustProvideOnboardDocuments: false, | ||
requiredOnboardDocuments: [], | ||
}); | ||
} | ||
|
||
this.driverOnboardSettingsLoaded = true; | ||
} | ||
|
||
companyDoesntHaveDriverOnboardSettings() { | ||
const companyId = this.driverOnboardSettings.companyId; | ||
return companyId === undefined; | ||
} | ||
|
||
updateDriverOnboardSettings(props = {}) { | ||
const companyId = this.currentUser.companyId; | ||
const driverOnboardSettings = this.driverOnboardSettings ?? {}; | ||
this.driverOnboardSettings = { | ||
companyId: companyId, | ||
...driverOnboardSettings, | ||
...props, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<ContentPanel @title={{t "fleet-ops.component.entity-field-editing-settings.entitiy-field-editing-settings"}} @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800 mb-4"> | ||
<OrderConfigManager @onConfigChanged={{this.onConfigChanged}} as |Action Context|> | ||
<div> | ||
<InputGroup | ||
@name={{t "fleet-ops.component.entity-field-editing-settings.select-order-config"}} | ||
@helpText={{t "fleet-ops.component.entity-field-editing-settings.select-order-config-help-text"}} | ||
> | ||
<DropdownButton | ||
class="order-config-select-button mr-2" | ||
@disabled={{not Context.configs}} | ||
@text={{if Context.currentConfig.name Context.currentConfig.name (t "fleet-ops.component.entity-field-editing-settings.select-order-config")}} | ||
@textClass="text-sm mr-2" | ||
@buttonClass="flex-row-reverse w-44 justify-between" | ||
@icon="caret-down" | ||
@iconClass="mr-0i" | ||
@size="sm" | ||
@iconPrefix="fas" | ||
@triggerClass="hidden md:flex" | ||
as |dd| | ||
> | ||
<div class="next-dd-menu mt-1 mx-0" aria-labelledby="user-menu"> | ||
<div class="p-1"> | ||
{{#each Context.configs as |orderConfig|}} | ||
<a href="javascript:;" class="next-dd-item" {{on "click" (dropdown-fn dd Context.selectConfig orderConfig)}}> | ||
<div class="flex-1 flex flex-row items-center"> | ||
<div class="w-6"> | ||
<FaIcon @icon="cogs" /> | ||
</div> | ||
<span>{{orderConfig.name}}</span> | ||
</div> | ||
<div> | ||
{{#if (eq Context.currentConfig.id orderConfig.id)}} | ||
<FaIcon @icon="check" class="text-green-500" /> | ||
{{/if}} | ||
</div> | ||
</a> | ||
{{/each}} | ||
</div> | ||
</div> | ||
</DropdownButton> | ||
</InputGroup> | ||
</div> | ||
</OrderConfigManager> | ||
{{#if this.selectedOrderConfig}} | ||
{{#let (get this.entityEditingSettings this.selectedOrderConfig.id) as |orderConfigEntityEditingSettings|}} | ||
<InputGroup> | ||
<div class="flex items-center"> | ||
<Toggle | ||
@isToggled={{orderConfigEntityEditingSettings.is_editable}} | ||
@onToggle={{this.enableEditableEntityFields}} | ||
@label={{t "fleet-ops.component.entity-field-editing-settings.enable-driver-to-edit-entity-fields"}} | ||
@helpText={{t "fleet-ops.component.entity-field-editing-settings.enable-driver-to-edit-entity-fields-help-text"}} | ||
/> | ||
</div> | ||
</InputGroup> | ||
{{#if orderConfigEntityEditingSettings.is_editable}} | ||
<div class="bg-gray-400 border-gray-600 rounded-lg px-4 py-2 dark:bg-gray-700 dark:border-gray-800"> | ||
{{#let (get (get this.entityEditingSettings this.selectedOrderConfig.id) "editable_entity_fields") as |editableEntityFields|}} | ||
{{#each this.entityFields as |entityField|}} | ||
<div class="mt-1"> | ||
<Checkbox @value={{includes entityField editableEntityFields}} @label={{smart-humanize entityField}} @onToggle={{fn this.toggleFieldEditable entityField}} /> | ||
</div> | ||
{{/each}} | ||
{{/let}} | ||
</div> | ||
{{/if}} | ||
<div class="mt-4 flex items-center"> | ||
<Button | ||
@type="primary" | ||
@size="lg" | ||
@icon="save" | ||
@text={{t "fleet-ops.common.save-changes"}} | ||
@onClick={{perform this.saveEntityEditingSettings}} | ||
@isLoading={{not this.saveEntityEditingSettings.isIdle}} | ||
/> | ||
</div> | ||
{{/let}} | ||
{{/if}} | ||
</ContentPanel> |
Oops, something went wrong.