From c33f1f61ee7f9d7b467479199cfa84eef6eb58ab Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Wed, 18 Dec 2019 11:46:45 +0100 Subject: [PATCH] feat(admin-ui): Display CustomFields for OrderLines in order detail view Closes #227 --- .../app/data/definitions/order-definitions.ts | 63 +++++---- .../order-detail/order-detail.component.html | 127 +++++++++++++++--- .../order-detail/order-detail.component.scss | 17 +++ .../order-detail/order-detail.component.ts | 16 +++ packages/admin-ui/src/i18n-messages/en.json | 2 + 5 files changed, 175 insertions(+), 50 deletions(-) diff --git a/packages/admin-ui/src/app/data/definitions/order-definitions.ts b/packages/admin-ui/src/app/data/definitions/order-definitions.ts index 1ab003dbeb..8e52364baf 100644 --- a/packages/admin-ui/src/app/data/definitions/order-definitions.ts +++ b/packages/admin-ui/src/app/data/definitions/order-definitions.ts @@ -62,6 +62,39 @@ export const FULFILLMENT_FRAGMENT = gql` } `; +export const ORDER_LINE_FRAGMENT = gql` + fragment OrderLine on OrderLine { + id + featuredAsset { + preview + } + productVariant { + id + name + sku + } + adjustments { + ...Adjustment + } + unitPrice + unitPriceWithTax + quantity + items { + id + unitPrice + unitPriceIncludesTax + unitPriceWithTax + taxRate + refundId + cancelled + fulfillment { + ...Fulfillment + } + } + totalPrice + } +`; + export const ORDER_DETAIL_FRAGMENT = gql` fragment OrderDetail on Order { id @@ -76,34 +109,7 @@ export const ORDER_DETAIL_FRAGMENT = gql` lastName } lines { - id - featuredAsset { - preview - } - productVariant { - id - name - sku - } - adjustments { - ...Adjustment - } - unitPrice - unitPriceWithTax - quantity - items { - id - unitPrice - unitPriceIncludesTax - unitPriceWithTax - taxRate - refundId - cancelled - fulfillment { - ...Fulfillment - } - } - totalPrice + ...OrderLine } adjustments { ...Adjustment @@ -159,6 +165,7 @@ export const ORDER_DETAIL_FRAGMENT = gql` ${ADJUSTMENT_FRAGMENT} ${SHIPPING_ADDRESS_FRAGMENT} ${FULFILLMENT_FRAGMENT} + ${ORDER_LINE_FRAGMENT} `; export const GET_ORDERS_LIST = gql` diff --git a/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.html b/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.html index f02630e099..41a67eb0bd 100644 --- a/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.html +++ b/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.html @@ -53,6 +53,31 @@ {{ 'order.product-sku' | translate }} {{ 'order.unit-price' | translate }} {{ 'order.quantity' | translate }} + + + + + + + + + + {{ 'order.total' | translate }} @@ -68,67 +93,123 @@ {{ line.productVariant.sku }} {{ line.unitPriceWithTax / 100 | currency: order.currencyCode }} -
{{ line.unitPrice / 100 | currency: order.currencyCode }}
+
+ {{ line.unitPrice / 100 | currency: order.currencyCode }} +
{{ line.quantity }} + + + + + {{ + line.customFields[customField.name] | date: 'short' + }} + + + + + + + + + + + {{ line.customFields[customField.name] }} + + + + + + {{ line.totalPrice / 100 | currency: order.currencyCode }} -
{{ (line.unitPrice * line.quantity) / 100 | currency: order.currencyCode }}
+
+ {{ (line.unitPrice * line.quantity) / 100 | currency: order.currencyCode }} +
-
{{ 'order.promotions-applied' | translate }}
+
+ {{ 'order.promotions-applied' | translate }} +
-
- {{ promotion.description }} -
{{ promotion.amount / 100 | currency: order.currencyCode }}
+
+ {{ promotion.description }} +
+ {{ promotion.amount / 100 | currency: order.currencyCode }} +
- {{ 'order.sub-total' | translate }} - - - + + {{ order.subTotal / 100 | currency: order.currencyCode }} -
{{ order.subTotalBeforeTax / 100 | currency: order.currencyCode }}
+
+ {{ order.subTotalBeforeTax / 100 | currency: order.currencyCode }} +
- + {{ adjustment.description }} - {{ couponCode }} + {{ + couponCode + }} + + + + {{ adjustment.amount / 100 | currency: order.currencyCode }} - {{ adjustment.amount / 100 | currency: order.currencyCode }} {{ 'order.shipping' | translate }} {{ order.shippingMethod?.description }} - + + {{ order.shippingWithTax / 100 | currency: order.currencyCode }} -
{{ order.shipping / 100 | currency: order.currencyCode }}
+
+ {{ order.shipping / 100 | currency: order.currencyCode }} +
{{ 'order.total' | translate }} - - - + + {{ order.total / 100 | currency: order.currencyCode }} -
{{ order.totalBeforeTax / 100 | currency: order.currencyCode }}
+
+ {{ order.totalBeforeTax / 100 | currency: order.currencyCode }} +
@@ -140,8 +221,10 @@ >
- +
{{ 'order.customer' | translate }} diff --git a/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.scss b/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.scss index 782bc4379a..1af5aa1583 100644 --- a/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.scss +++ b/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.scss @@ -23,6 +23,23 @@ } } +.custom-field-header-button { + background: none; + margin: 0; + padding: 0; + border: none; + cursor: pointer; + color: $color-primary-600; +} + +.order-line-custom-field { + background-color: $color-grey-100; + + .custom-field-ellipsis { + color: $color-grey-300; + } +} + .net-price { font-size: 11px; color: $color-grey-400; diff --git a/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.ts b/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.ts index 186f41df85..1636228b72 100644 --- a/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.ts +++ b/packages/admin-ui/src/app/order/components/order-detail/order-detail.component.ts @@ -36,6 +36,8 @@ export class OrderDetailComponent extends BaseDetailComponent; fetchHistory = new Subject(); customFields: CustomFieldConfig[]; + orderLineCustomFields: CustomFieldConfig[]; + orderLineCustomFieldsVisible = false; constructor( router: Router, route: ActivatedRoute, @@ -48,9 +50,19 @@ export class OrderDetailComponent extends BaseDetailComponent { @@ -69,6 +81,10 @@ export class OrderDetailComponent extends BaseDetailComponent a.type === AdjustmentType.PROMOTION); } diff --git a/packages/admin-ui/src/i18n-messages/en.json b/packages/admin-ui/src/i18n-messages/en.json index e266b2dca3..1cdf7b165b 100644 --- a/packages/admin-ui/src/i18n-messages/en.json +++ b/packages/admin-ui/src/i18n-messages/en.json @@ -136,12 +136,14 @@ "description": "Description", "disabled": "Disabled", "discard-changes": "Discard changes", + "display-custom-fields": "Display custom fields", "done": "Done", "edit": "Edit", "edit-field": "Edit field", "enabled": "Enabled", "extension-running-in-separate-window": "Extension is running in a separate window", "guest": "Guest", + "hide-custom-fields": "Hide custom fields", "items-per-page-option": "{ count } per page", "jobs-in-progress": "{ count } {count, plural, one {job} other {jobs}} in progress", "language": "Language",