From 461c8255a2aa22cf18c5ac278e2608e88b1d2f17 Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Mon, 13 May 2024 16:07:44 +0800 Subject: [PATCH 1/7] created order component --- addon/components/driver-panel.js | 7 ++- addon/components/driver-panel/orders.hbs | 38 +++++++++++++++ addon/components/driver-panel/orders.js | 47 +++++++++++++++++++ app/components/driver-panel/orders.js | 1 + .../components/driver-panel/orders-test.js | 26 ++++++++++ translations/en-us.yaml | 1 + 6 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 addon/components/driver-panel/orders.hbs create mode 100644 addon/components/driver-panel/orders.js create mode 100644 app/components/driver-panel/orders.js create mode 100644 tests/integration/components/driver-panel/orders-test.js diff --git a/addon/components/driver-panel.js b/addon/components/driver-panel.js index 6bba5901..653e248e 100644 --- a/addon/components/driver-panel.js +++ b/addon/components/driver-panel.js @@ -4,6 +4,7 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { isArray } from '@ember/array'; import DriverPanelDetailComponent from './driver-panel/details'; +import DriverPanelOrdersComponent from './driver-panel/orders'; import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; @@ -74,8 +75,10 @@ export default class DriverPanelComponent extends Component { get tabs() { const registeredTabs = this.universe.getMenuItemsFromRegistry('component:driver-panel'); // this.universe._createMenuItem('Tracking', null, { icon: 'satellite-dish', component: DriverPanelTrackingComponent }), - const defaultTabs = [this.universe._createMenuItem('Details', null, { icon: 'circle-info', component: DriverPanelDetailComponent })]; - + const defaultTabs = [ + this.universe._createMenuItem('Details', null, { icon: 'circle-info', component: DriverPanelDetailComponent }), + this.universe._createMenuItem('Orders', null, { icon: 'bars-progress', component: DriverPanelOrdersComponent }), + ]; if (isArray(registeredTabs)) { return [...defaultTabs, ...registeredTabs]; } diff --git a/addon/components/driver-panel/orders.hbs b/addon/components/driver-panel/orders.hbs new file mode 100644 index 00000000..8069192d --- /dev/null +++ b/addon/components/driver-panel/orders.hbs @@ -0,0 +1,38 @@ +{{! template-lint-disable no-unbound }} + + + +
+ + {{#if this.isLoading}} +
+ +
+ + {{/if}} + +
\ No newline at end of file diff --git a/addon/components/driver-panel/orders.js b/addon/components/driver-panel/orders.js new file mode 100644 index 00000000..50ab22ae --- /dev/null +++ b/addon/components/driver-panel/orders.js @@ -0,0 +1,47 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; +import { inject as controller } from '@ember/controller'; +import { action, computed } from '@ember/object'; +import { task } from 'ember-concurrency-decorators'; +export default class CustomerOrderHistoryComponent extends Component { + @service store; + @service fetch; + @service intl; + @service appCache; + @service modalsManager; + @service contextPanel; + @tracked isLoading = true; + @tracked orders = []; + @tracked driver; + @controller('orders.index.view') orderDetailsController; + + @computed('args.title') get title() { + return this.args.title ?? this.intl.t('fleetops.component.widget.orders.widget-title'); + } + + constructor() { + super(...arguments); + this.driver = this.args.driver; + this.loadOrdersForDriver.perform(); + } + + @task *loadOrdersForDriver(params = {}) { + try { + this.orders = yield this.store.query('order', { + driver_assigned_uuid: this.driver.id, + ...params, + }); + } catch (error) { + this.notifications.serverError('error', error); + } + } + + @action search(event) { + // this.reloadOrders.perform({ query: event.target.value ?? '' }); + } + + @action async viewOrder(order) { + this.contextPanel.focus(order, 'viewing'); + } +} diff --git a/app/components/driver-panel/orders.js b/app/components/driver-panel/orders.js new file mode 100644 index 00000000..29a7f3a2 --- /dev/null +++ b/app/components/driver-panel/orders.js @@ -0,0 +1 @@ +export { default } from '@fleetbase/fleetops-engine/components/driver-panel/orders'; diff --git a/tests/integration/components/driver-panel/orders-test.js b/tests/integration/components/driver-panel/orders-test.js new file mode 100644 index 00000000..5351b35c --- /dev/null +++ b/tests/integration/components/driver-panel/orders-test.js @@ -0,0 +1,26 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'dummy/tests/helpers'; +import { render } from '@ember/test-helpers'; +import { hbs } from 'ember-cli-htmlbars'; + +module('Integration | Component | driver-panel/orders', function (hooks) { + setupRenderingTest(hooks); + + test('it renders', async function (assert) { + // Set any properties with this.set('myProperty', 'value'); + // Handle any actions with this.set('myAction', function(val) { ... }); + + await render(hbs``); + + assert.dom().hasText(''); + + // Template block usage: + await render(hbs` + + template block text + + `); + + assert.dom().hasText('template block text'); + }); +}); diff --git a/translations/en-us.yaml b/translations/en-us.yaml index 6f919654..4c3abd07 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -778,6 +778,7 @@ fleet-ops: vendor: Vendor select-vehicle: Select Vehicle driver-status: Select driver status + order-history: Order History driver-panel: user-account: User Account driver-details: Driver Details From cb1195eea2c33a75fdb7f10e87eee2af67a19ddd Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Mon, 13 May 2024 18:01:34 +0800 Subject: [PATCH 2/7] changed ui --- addon/components/driver-panel/orders.hbs | 55 ++++++++++-------------- addon/components/driver-panel/orders.js | 2 +- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/addon/components/driver-panel/orders.hbs b/addon/components/driver-panel/orders.hbs index 8069192d..310ec721 100644 --- a/addon/components/driver-panel/orders.hbs +++ b/addon/components/driver-panel/orders.hbs @@ -1,38 +1,29 @@ -{{! template-lint-disable no-unbound }} -
- {{#if this.isLoading}} -
- + - {{/if}} - -
\ No newline at end of file + \ No newline at end of file diff --git a/addon/components/driver-panel/orders.js b/addon/components/driver-panel/orders.js index 50ab22ae..0084e2dc 100644 --- a/addon/components/driver-panel/orders.js +++ b/addon/components/driver-panel/orders.js @@ -38,7 +38,7 @@ export default class CustomerOrderHistoryComponent extends Component { } @action search(event) { - // this.reloadOrders.perform({ query: event.target.value ?? '' }); + this.loadOrdersForDriver.perform({ query: event.target.value ?? '' }); } @action async viewOrder(order) { From 57b1d82173d991f65239004acc0e7c3a69abcfe1 Mon Sep 17 00:00:00 2001 From: Doljinsuren Enkhbayar Date: Mon, 13 May 2024 19:49:57 +0800 Subject: [PATCH 3/7] changed ui --- addon/components/driver-panel/orders.hbs | 105 ++++++++++++++++++++--- translations/en-us.yaml | 5 ++ 2 files changed, 96 insertions(+), 14 deletions(-) diff --git a/addon/components/driver-panel/orders.hbs b/addon/components/driver-panel/orders.hbs index 310ec721..c1be6ba1 100644 --- a/addon/components/driver-panel/orders.hbs +++ b/addon/components/driver-panel/orders.hbs @@ -4,24 +4,101 @@