From c1d8664ad6fafd2da34b98081cc1b3c12c268b59 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Tue, 25 Jun 2019 12:00:54 +0200 Subject: [PATCH] feat(admin-ui): Improve layout of OrderDetailComponent --- .../src/app/common/base-detail.component.ts | 6 +- .../app/data/definitions/facet-definitions.ts | 1 + .../order-detail/order-detail.component.html | 246 ++++++++---------- .../order-detail/order-detail.component.scss | 20 ++ .../order-detail/order-detail.component.ts | 7 +- .../order-list/order-list.component.html | 18 +- .../action-bar/action-bar.component.ts | 4 +- .../order-state-label.component.html | 1 + .../order-state-label.component.scss | 33 +++ .../order-state-label.component.ts | 25 ++ .../background-color-from.directive.ts | 4 +- admin-ui/src/app/shared/shared.module.ts | 2 + admin-ui/src/i18n-messages/en.json | 10 +- 13 files changed, 220 insertions(+), 157 deletions(-) create mode 100644 admin-ui/src/app/shared/components/order-state-label/order-state-label.component.html create mode 100644 admin-ui/src/app/shared/components/order-state-label/order-state-label.component.scss create mode 100644 admin-ui/src/app/shared/components/order-state-label/order-state-label.component.ts diff --git a/admin-ui/src/app/common/base-detail.component.ts b/admin-ui/src/app/common/base-detail.component.ts index 424fbea84e..f3fd83a46f 100644 --- a/admin-ui/src/app/common/base-detail.component.ts +++ b/admin-ui/src/app/common/base-detail.component.ts @@ -9,7 +9,7 @@ import { ServerConfigService } from '../data/server-config'; import { LanguageCode } from './generated-types'; import { getDefaultLanguage } from './utilities/get-default-language'; -export abstract class BaseDetailComponent { +export abstract class BaseDetailComponent { entity$: Observable; availableLanguages$: Observable; languageCode$: Observable; @@ -27,7 +27,9 @@ export abstract class BaseDetailComponent { init() { this.entity$ = this.route.data.pipe( switchMap(data => data.entity as Observable), - distinctUntilChanged((a, b) => a.id === b.id), + distinctUntilChanged((a, b) => { + return a.id === b.id && a.updatedAt === b.updatedAt; + }), tap(entity => (this.id = entity.id)), shareReplay(1), ); diff --git a/admin-ui/src/app/data/definitions/facet-definitions.ts b/admin-ui/src/app/data/definitions/facet-definitions.ts index f9792cfa23..ff0d853946 100644 --- a/admin-ui/src/app/data/definitions/facet-definitions.ts +++ b/admin-ui/src/app/data/definitions/facet-definitions.ts @@ -21,6 +21,7 @@ export const FACET_VALUE_FRAGMENT = gql` export const FACET_WITH_VALUES_FRAGMENT = gql` fragment FacetWithValues on Facet { id + updatedAt languageCode isPrivate code diff --git a/admin-ui/src/app/order/components/order-detail/order-detail.component.html b/admin-ui/src/app/order/components/order-detail/order-detail.component.html index 0aa8cac92f..7c8d3c2739 100644 --- a/admin-ui/src/app/order/components/order-detail/order-detail.component.html +++ b/admin-ui/src/app/order/components/order-detail/order-detail.component.html @@ -1,154 +1,120 @@ - - + + +
+ +
+ + {{ 'common.updated' | translate }}: + {{ order.updatedAt | date: 'medium' }} +
+
+
-
- - - - - - - - - - - - - - +
+
{{ 'order.order-code' | translate }}{{ order.code }}
{{ 'order.state' | translate }}{{ order.state }}
{{ 'common.created' | translate }}{{ order.createdAt | date: 'medium' }}
+ - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
{{ 'common.updated' | translate }}{{ order.updatedAt | date: 'medium' }}{{ 'order.product-name' | translate }}{{ 'order.product-sku' | translate }}{{ 'order.unit-price' | translate }}{{ 'order.quantity' | translate }}{{ 'order.total' | translate }}
{{ line.productVariant.name }}{{ line.productVariant.sku }} + {{ line.unitPriceWithTax / 100 | currency: order.currencyCode }} + {{ line.quantity }}{{ line.totalPrice / 100 | currency: order.currencyCode }}
{{ 'order.sub-total' | translate }}{{ order.subTotal / 100 | currency: order.currencyCode }}
{{ adjustment.description }}{{ adjustment.amount / 100 | currency: order.currencyCode }}
{{ 'order.shipping' | translate }}{{ order.shippingMethod?.description }}{{ order.shipping / 100 | currency: order.currencyCode }}
{{ 'order.total' | translate }}{{ order.total / 100 | currency: order.currencyCode }}
-
- - - - - - - - - - - -
{{ 'order.customer' | translate }}
{{ 'order.shipping-address' | translate }} -
+
+
+
+ {{ 'order.customer' | translate }} +
+
+
+ +
+ {{ 'order.shipping-address' | translate }} +
+
    +
  • {{ line }} -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
{{ 'order.payment-state' | translate }} - {{ payment.state }} - - - - - - - - -
{{ 'order.payment-method' | translate }}{{ payment.method }}
{{ 'order.amount' | translate }}{{ payment.amount / 100 | currency: order.currencyCode }}
{{ 'order.transaction-id' | translate }}{{ payment.transactionId }}
{{ 'order.payment-metadata' | translate }} - -
+ + +
+
+
+ +
+
+ {{ 'order.payment' | translate }} +
+
+
{{ 'order.payment-state' | translate }}
+ {{ payment.state }} +
{{ 'order.payment-method' | translate }}
+ {{ payment.method }} +
{{ 'order.amount' | translate }}
+ {{ payment.amount / 100 | currency: order.currencyCode }} +
{{ 'order.transaction-id' | translate }}
+ {{ payment.transactionId }} +
{{ 'order.payment-metadata' | translate }}
+ +
+ +
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{{ 'order.product-name' | translate }}{{ 'order.product-sku' | translate }}{{ 'order.unit-price' | translate }}{{ 'order.quantity' | translate }}{{ 'order.total' | translate }}
{{ line.productVariant.name }}{{ line.productVariant.sku }}{{ line.unitPriceWithTax / 100 | currency: order.currencyCode }}{{ line.quantity }}{{ line.totalPrice / 100 | currency: order.currencyCode }}
{{ 'order.sub-total' | translate }}{{ order.subTotal / 100 | currency: order.currencyCode }}
{{ adjustment.description }}{{ adjustment.amount / 100 | currency: order.currencyCode }}
{{ 'order.shipping' | translate }}{{ order.shippingMethod?.description }}{{ order.shipping / 100 | currency: order.currencyCode }}
{{ 'order.total' | translate }}{{ order.total / 100 | currency: order.currencyCode }}
diff --git a/admin-ui/src/app/order/components/order-detail/order-detail.component.scss b/admin-ui/src/app/order/components/order-detail/order-detail.component.scss index d7f8267c27..d3bae19881 100644 --- a/admin-ui/src/app/order/components/order-detail/order-detail.component.scss +++ b/admin-ui/src/app/order/components/order-detail/order-detail.component.scss @@ -1,8 +1,21 @@ @import "variables"; +.date-detail { + color: $color-grey-500; + padding-left: 6px; +} + ul.payment-metadata { list-style-type: none; } +.metadata-prop { + color: $color-grey-500; +} + +.shipping-address { + list-style-type: none; + line-height: 1.3em; +} .order-lines { @@ -15,3 +28,10 @@ ul.payment-metadata { border-top: 1px dashed $color-grey-300; } } + +.order-cards { + h6 { + margin-top: 6px; + color: $color-grey-500; + } +} diff --git a/admin-ui/src/app/order/components/order-detail/order-detail.component.ts b/admin-ui/src/app/order/components/order-detail/order-detail.component.ts index f959df6900..b0202f04c3 100644 --- a/admin-ui/src/app/order/components/order-detail/order-detail.component.ts +++ b/admin-ui/src/app/order/components/order-detail/order-detail.component.ts @@ -41,7 +41,9 @@ export class OrderDetailComponent extends BaseDetailComponent val !== 'ShippingAddress'); + return Object.values(shippingAddress) + .filter(val => val !== 'OrderAddress') + .filter(line => !!line); } getPaymentMetadata(payment: OrderWithLines.Payments) { @@ -56,8 +58,7 @@ export class OrderDetailComponent extends BaseDetailComponent{{ 'common.updated-at' | translate }} - {{ order.id }} - {{ order.code }} - - {{ order.state }} - {{ order.total / 100 | currency: order.currencyCode }} - {{ order.updatedAt | date: 'medium' }} - + {{ order.id }} + {{ order.code }} + + + + + + + {{ order.total / 100 | currency: order.currencyCode }} + {{ order.updatedAt | date: 'medium' }} + {{ stateToken | translate }} diff --git a/admin-ui/src/app/shared/components/order-state-label/order-state-label.component.scss b/admin-ui/src/app/shared/components/order-state-label/order-state-label.component.scss new file mode 100644 index 0000000000..88e8ccc007 --- /dev/null +++ b/admin-ui/src/app/shared/components/order-state-label/order-state-label.component.scss @@ -0,0 +1,33 @@ +@import "variables"; + +:host { + ::ng-deep vdr-chip { + &.PaymentAuthorized, &.PaymentSettled { + .wrapper { + color: $color-warning-700; + } + .chip-label { + color: $color-warning-700; + background-color: $color-warning-400; + } + } + &.Fulfilled { + .wrapper { + color: $color-success-700; + } + .chip-label { + color: $color-success-700; + background-color: $color-success-400; + } + } + &.Cancelled { + .wrapper { + color: $color-error-700; + } + .chip-label { + color: $color-error-700; + background-color: $color-error-400; + } + } + } +} diff --git a/admin-ui/src/app/shared/components/order-state-label/order-state-label.component.ts b/admin-ui/src/app/shared/components/order-state-label/order-state-label.component.ts new file mode 100644 index 0000000000..d588c83549 --- /dev/null +++ b/admin-ui/src/app/shared/components/order-state-label/order-state-label.component.ts @@ -0,0 +1,25 @@ +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { _ } from 'src/app/core/providers/i18n/mark-for-extraction'; + +@Component({ + selector: 'vdr-order-state-label', + templateUrl: './order-state-label.component.html', + styleUrls: ['./order-state-label.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class OrderStateLabelComponent { + @Input() state: string; + private readonly stateI18nTokens = { + AddingItems: _('order.state-adding-items'), + ArrangingPayment: _('order.state-arranging-payment'), + PaymentAuthorized: _('order.state-payment-authorized'), + PaymentSettled: _('order.state-payment-settled'), + PartiallyFulfilled: _('order.state-partially-fulfilled'), + Fulfilled: _('order.state-fulfilled'), + Cancelled: _('order.state-cancelled'), + }; + + get stateToken(): string { + return this.stateI18nTokens[this.state as any] || this.state; + } +} diff --git a/admin-ui/src/app/shared/directives/background-color-from.directive.ts b/admin-ui/src/app/shared/directives/background-color-from.directive.ts index 3cd5591e77..7ff1c49576 100644 --- a/admin-ui/src/app/shared/directives/background-color-from.directive.ts +++ b/admin-ui/src/app/shared/directives/background-color-from.directive.ts @@ -15,6 +15,8 @@ export class BackgroundColorFromDirective implements OnChanges { @Input() private vdrBackgroundColorFrom: string; ngOnChanges(): void { - this.backgroundColor = stringToColor(this.vdrBackgroundColorFrom); + if (this.vdrBackgroundColorFrom !== '') { + this.backgroundColor = stringToColor(this.vdrBackgroundColorFrom); + } } } diff --git a/admin-ui/src/app/shared/shared.module.ts b/admin-ui/src/app/shared/shared.module.ts index adfd93e30c..7be6137ac2 100644 --- a/admin-ui/src/app/shared/shared.module.ts +++ b/admin-ui/src/app/shared/shared.module.ts @@ -37,6 +37,7 @@ import { DialogButtonsDirective } from './components/modal-dialog/dialog-buttons import { DialogComponentOutletComponent } from './components/modal-dialog/dialog-component-outlet.component'; import { DialogTitleDirective } from './components/modal-dialog/dialog-title.directive'; import { ModalDialogComponent } from './components/modal-dialog/modal-dialog.component'; +import { OrderStateLabelComponent } from './components/order-state-label/order-state-label.component'; import { PaginationControlsComponent } from './components/pagination-controls/pagination-controls.component'; import { RichTextEditorComponent } from './components/rich-text-editor/rich-text-editor.component'; import { SelectToggleComponent } from './components/select-toggle/select-toggle.component'; @@ -100,6 +101,7 @@ const DECLARATIONS = [ DropdownMenuComponent, DropdownTriggerDirective, DropdownItemDirective, + OrderStateLabelComponent, ]; @NgModule({ diff --git a/admin-ui/src/i18n-messages/en.json b/admin-ui/src/i18n-messages/en.json index aa1353bd73..f790bda7ee 100644 --- a/admin-ui/src/i18n-messages/en.json +++ b/admin-ui/src/i18n-messages/en.json @@ -110,7 +110,6 @@ "confirm": "Confirm", "confirm-navigation": "Confirm navigation", "create": "Create", - "created": "Created", "created-at": "Created at", "custom-fields": "Custom fields", "delete": "Delete", @@ -408,7 +407,7 @@ "order": { "amount": "Amount", "customer": "Customer", - "order-code": "Order code", + "payment": "Payment", "payment-metadata": "Payment metadata", "payment-method": "Payment method", "payment-state": "State", @@ -421,6 +420,13 @@ "shipping": "Shipping", "shipping-address": "Shipping address", "state": "State", + "state-adding-items": "Adding items", + "state-arranging-payment": "Arranging payment", + "state-cancelled": "Cancelled", + "state-fulfilled": "Fulfilled", + "state-partially-fulfilled": "Partially fulfilled", + "state-payment-authorized": "Payment authorized", + "state-payment-settled": "Payment settled", "sub-total": "Sub total", "total": "Total", "transaction-id": "Transaction ID",