diff --git a/packages/admin-ui/i18n-coverage.json b/packages/admin-ui/i18n-coverage.json index 5c16b86de3..eb6d240a1a 100644 --- a/packages/admin-ui/i18n-coverage.json +++ b/packages/admin-ui/i18n-coverage.json @@ -1,36 +1,36 @@ { - "generatedOn": "2020-06-30T13:29:58.358Z", - "lastCommit": "dc82b2c2392004d08f4a1aea4b126360f733b296", + "generatedOn": "2020-07-10T12:40:06.107Z", + "lastCommit": "3196b525dfbb31edc2bbe8c5f50b0349b8386f15", "translationStatus": { "de": { - "tokenCount": 656, + "tokenCount": 658, "translatedCount": 609, "percentage": 93 }, "en": { - "tokenCount": 656, - "translatedCount": 656, + "tokenCount": 658, + "translatedCount": 658, "percentage": 100 }, "es": { - "tokenCount": 656, + "tokenCount": 658, "translatedCount": 467, "percentage": 71 }, "pl": { - "tokenCount": 656, + "tokenCount": 658, "translatedCount": 566, "percentage": 86 }, "zh_Hans": { - "tokenCount": 656, + "tokenCount": 658, "translatedCount": 550, "percentage": 84 }, "zh_Hant": { - "tokenCount": 656, + "tokenCount": 658, "translatedCount": 550, "percentage": 84 } } -} +} \ No newline at end of file diff --git a/packages/admin-ui/src/lib/core/src/common/generated-types.ts b/packages/admin-ui/src/lib/core/src/common/generated-types.ts index 520ec3d77e..118c405bf4 100644 --- a/packages/admin-ui/src/lib/core/src/common/generated-types.ts +++ b/packages/admin-ui/src/lib/core/src/common/generated-types.ts @@ -1899,6 +1899,7 @@ export type Mutation = { setUiLanguage?: Maybe; settlePayment: Payment; settleRefund: Refund; + transitionOrderToState?: Maybe; /** Update an existing Administrator */ updateAdministrator: Administrator; /** Update an existing Asset */ @@ -2289,6 +2290,12 @@ export type MutationSettleRefundArgs = { }; +export type MutationTransitionOrderToStateArgs = { + id: Scalars['ID']; + state: Scalars['String']; +}; + + export type MutationUpdateAdministratorArgs = { input: UpdateAdministratorInput; }; @@ -4780,7 +4787,7 @@ export type OrderAddressFragment = ( export type OrderFragment = ( { __typename?: 'Order' } - & Pick + & Pick & { customer?: Maybe<( { __typename?: 'Customer' } & Pick @@ -5015,6 +5022,20 @@ export type DeleteOrderNoteMutation = ( ) } ); +export type TransitionOrderToStateMutationVariables = { + id: Scalars['ID']; + state: Scalars['String']; +}; + + +export type TransitionOrderToStateMutation = ( + { __typename?: 'Mutation' } + & { transitionOrderToState?: Maybe<( + { __typename?: 'Order' } + & OrderFragment + )> } +); + export type AssetFragment = ( { __typename?: 'Asset' } & Pick @@ -7322,6 +7343,12 @@ export namespace DeleteOrderNote { export type DeleteOrderNote = DeleteOrderNoteMutation['deleteOrderNote']; } +export namespace TransitionOrderToState { + export type Variables = TransitionOrderToStateMutationVariables; + export type Mutation = TransitionOrderToStateMutation; + export type TransitionOrderToState = OrderFragment; +} + export namespace Asset { export type Fragment = AssetFragment; export type FocalPoint = (NonNullable); diff --git a/packages/admin-ui/src/lib/core/src/data/definitions/order-definitions.ts b/packages/admin-ui/src/lib/core/src/data/definitions/order-definitions.ts index f7dbcb77fa..bf13405135 100644 --- a/packages/admin-ui/src/lib/core/src/data/definitions/order-definitions.ts +++ b/packages/admin-ui/src/lib/core/src/data/definitions/order-definitions.ts @@ -42,6 +42,7 @@ export const ORDER_FRAGMENT = gql` updatedAt code state + nextStates total currencyCode customer { @@ -291,3 +292,12 @@ export const DELETE_ORDER_NOTE = gql` } } `; + +export const TRANSITION_ORDER_TO_STATE = gql` + mutation TransitionOrderToState($id: ID!, $state: String!) { + transitionOrderToState(id: $id, state: $state) { + ...Order + } + } + ${ORDER_FRAGMENT} +`; diff --git a/packages/admin-ui/src/lib/core/src/data/providers/order-data.service.ts b/packages/admin-ui/src/lib/core/src/data/providers/order-data.service.ts index 73871bc7c1..d488992829 100644 --- a/packages/admin-ui/src/lib/core/src/data/providers/order-data.service.ts +++ b/packages/admin-ui/src/lib/core/src/data/providers/order-data.service.ts @@ -15,6 +15,7 @@ import { SettlePayment, SettleRefund, SettleRefundInput, + TransitionOrderToState, UpdateOrderNote, UpdateOrderNoteInput, } from '../../common/generated-types'; @@ -29,6 +30,7 @@ import { REFUND_ORDER, SETTLE_PAYMENT, SETTLE_REFUND, + TRANSITION_ORDER_TO_STATE, UPDATE_ORDER_NOTE, } from '../definitions/order-definitions'; @@ -119,4 +121,14 @@ export class OrderDataService { }, ); } + + transitionToState(id: string, state: string) { + return this.baseDataService.mutate( + TRANSITION_ORDER_TO_STATE, + { + id, + state, + }, + ); + } } diff --git a/packages/admin-ui/src/lib/order/src/components/order-detail/order-detail.component.html b/packages/admin-ui/src/lib/order/src/components/order-detail/order-detail.component.html index c51d1b4710..136cf701e6 100644 --- a/packages/admin-ui/src/lib/order/src/components/order-detail/order-detail.component.html +++ b/packages/admin-ui/src/lib/order/src/components/order-detail/order-detail.component.html @@ -24,7 +24,7 @@ type="button" class="btn" vdrDropdownItem - *ngIf="order.state !== 'Cancelled'" + *ngIf="order.nextStates.includes('Cancelled')" (click)="cancelOrRefund(order)" > @@ -37,6 +37,13 @@ {{ 'order.cancel-order' | translate }} + + + + @@ -47,39 +54,39 @@
- - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -102,13 +109,13 @@ - + - + - + - +
{{ 'order.product-name' | translate }}{{ 'order.product-sku' | translate }}{{ 'order.unit-price' | translate }}{{ 'order.quantity' | translate }} - - - - {{ 'order.total' | 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.customFields[customField.name] | date: 'short' - }} + }} @@ -125,11 +132,11 @@ - + {{ line.totalPrice / 100 | currency: order.currencyCode }} @@ -150,7 +157,7 @@ {{ promotion.description }}{{ promotion.description }}
{{ promotion.amount / 100 | currency: order.currencyCode }} @@ -164,7 +171,7 @@
{{ 'order.sub-total' | translate }} {{ order.subTotal / 100 | currency: order.currencyCode }} @@ -175,13 +182,13 @@
{{ adjustment.description }} {{ couponCode - }} + }} @@ -191,7 +198,7 @@
{{ 'order.shipping' | translate }} {{ order.shippingMethod?.description }} {{ order.shippingWithTax / 100 | currency: order.currencyCode }} @@ -203,7 +210,7 @@
{{ 'order.total' | translate }} {{ order.total / 100 | currency: order.currencyCode }} diff --git a/packages/admin-ui/src/lib/order/src/components/order-detail/order-detail.component.ts b/packages/admin-ui/src/lib/order/src/components/order-detail/order-detail.component.ts index 9a06a35944..67640b47bb 100644 --- a/packages/admin-ui/src/lib/order/src/components/order-detail/order-detail.component.ts +++ b/packages/admin-ui/src/lib/order/src/components/order-detail/order-detail.component.ts @@ -19,7 +19,7 @@ import { } from '@vendure/admin-ui/core'; import { omit } from '@vendure/common/lib/omit'; import { EMPTY, Observable, of, Subject } from 'rxjs'; -import { startWith, switchMap, take } from 'rxjs/operators'; +import { map, startWith, switchMap, take } from 'rxjs/operators'; import { CancelOrderDialogComponent } from '../cancel-order-dialog/cancel-order-dialog.component'; import { FulfillOrderDialogComponent } from '../fulfill-order-dialog/fulfill-order-dialog.component'; @@ -36,10 +36,20 @@ export class OrderDetailComponent extends BaseDetailComponent; + nextStates$: Observable; fetchHistory = new Subject(); customFields: CustomFieldConfig[]; orderLineCustomFields: CustomFieldConfig[]; orderLineCustomFieldsVisible = false; + private readonly defaultStates = [ + 'AddingItems', + 'ArrangingPayment', + 'PaymentAuthorized', + 'PaymentSettled', + 'PartiallyFulfilled', + 'Fulfilled', + 'Cancelled', + ]; constructor( router: Router, route: ActivatedRoute, @@ -52,7 +62,7 @@ export class OrderDetailComponent extends BaseDetailComponent data.order?.history.items); }), ); + this.nextStates$ = this.entity$.pipe( + map((order) => { + const isInCustomState = !this.defaultStates.includes(order.state); + return isInCustomState + ? order.nextStates + : order.nextStates.filter((s) => !this.defaultStates.includes(s)); + }), + ); } ngOnDestroy() { @@ -96,6 +114,13 @@ export class OrderDetailComponent extends BaseDetailComponent { + this.notificationService.success(_('order.transitioned-to-state-success'), { state }); + this.fetchHistory.next(); + }); + } + getCouponCodeForAdjustment( order: OrderDetail.Fragment, promotionAdjustment: OrderDetail.Adjustments, diff --git a/packages/admin-ui/src/lib/static/i18n-messages/de.json b/packages/admin-ui/src/lib/static/i18n-messages/de.json index fc228bddb8..b88f1900c5 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/de.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/de.json @@ -60,9 +60,8 @@ "collection-contents": "Inhalt der Sammlung", "confirm-adding-options-delete-default-body": "Das Hinzufügen von Optionen zu diesem Produkt führt dazu, dass die vorhandene Standardvariante gelöscht wird. Möchten Sie fortfahren?", "confirm-adding-options-delete-default-title": "Standardvariante löschen?", - "confirm-delete-assets": "{count} {count, plural, one {Asset} other {Assets}} löschen?", "confirm-delete-administrator": "", - "confirm-delete-asset": "Asset löschen?", + "confirm-delete-assets": "{count} {count, plural, one {Asset} other {Assets}} löschen?", "confirm-delete-channel": "Kanal löschen?", "confirm-delete-collection": "Sammlung löschen?", "confirm-delete-collection-and-children-body": "Wenn Sie diese Sammlung löschen, werden auch alle untergeordneten Sammlungen gelöscht.", @@ -602,6 +601,8 @@ "total": "Gesamtsumme", "tracking-code": "Sendungsverfolgungscode", "transaction-id": "Transaktions-ID", + "transition-to-state": "", + "transitioned-to-state-success": "", "unfulfilled": "Nicht ausgeführt", "unit-price": "Einzelpreis" }, @@ -686,4 +687,4 @@ "job-result": "Job-Ergebnis", "job-state": "Job-Status" } -} +} \ No newline at end of file diff --git a/packages/admin-ui/src/lib/static/i18n-messages/en.json b/packages/admin-ui/src/lib/static/i18n-messages/en.json index 27aae16420..b8ef42f649 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/en.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/en.json @@ -601,6 +601,8 @@ "total": "Total", "tracking-code": "Tracking code", "transaction-id": "Transaction ID", + "transition-to-state": "Transition to { state } state", + "transitioned-to-state-success": "Successfully transitioned to { state }", "unfulfilled": "Unfulfilled", "unit-price": "Unit price" }, @@ -685,4 +687,4 @@ "job-result": "Job result", "job-state": "Job state" } -} +} \ No newline at end of file diff --git a/packages/admin-ui/src/lib/static/i18n-messages/es.json b/packages/admin-ui/src/lib/static/i18n-messages/es.json index e81cde2177..dd8dfdefa7 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/es.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/es.json @@ -601,6 +601,8 @@ "total": "Total", "tracking-code": "", "transaction-id": "ID de transacción", + "transition-to-state": "", + "transitioned-to-state-success": "", "unfulfilled": "", "unit-price": "Precio unitario" }, @@ -685,4 +687,4 @@ "job-result": "Resultado", "job-state": "Estado" } -} +} \ No newline at end of file diff --git a/packages/admin-ui/src/lib/static/i18n-messages/pl.json b/packages/admin-ui/src/lib/static/i18n-messages/pl.json index 296e53d0ef..b0cc29c022 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/pl.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/pl.json @@ -61,7 +61,6 @@ "confirm-adding-options-delete-default-body": "Dodawanie opcji spowoduje, że obecna domyślna opcja zostanie usunięta. Czy chcesz kontynuować?", "confirm-adding-options-delete-default-title": "Usunąć domyślny tytuł?", "confirm-delete-administrator": "", - "confirm-delete-asset": "", "confirm-delete-assets": "", "confirm-delete-channel": "Usunąć kanał?", "confirm-delete-collection": "Usunąć kolekcje?", @@ -602,6 +601,8 @@ "total": "Total", "tracking-code": "Numer przesyłki", "transaction-id": "Numer transakcji", + "transition-to-state": "", + "transitioned-to-state-success": "", "unfulfilled": "Unfulfilled", "unit-price": "Cena jednostkowa" }, @@ -686,4 +687,4 @@ "job-result": "Rezultat zlecenia", "job-state": "Status zlecenia" } -} +} \ No newline at end of file diff --git a/packages/admin-ui/src/lib/static/i18n-messages/zh_Hans.json b/packages/admin-ui/src/lib/static/i18n-messages/zh_Hans.json index 9f66b23c6b..74868adeff 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/zh_Hans.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/zh_Hans.json @@ -61,7 +61,6 @@ "confirm-adding-options-delete-default-body": "添加新规格到此产品会导致含此规格的产品被删除,确认继续吗?", "confirm-adding-options-delete-default-title": "确认删除产品规格么?", "confirm-delete-administrator": "", - "confirm-delete-asset": "", "confirm-delete-assets": "", "confirm-delete-channel": "确认删除销售渠道?", "confirm-delete-collection": "确认删除商品系列吗?", @@ -602,6 +601,8 @@ "total": "总计金额", "tracking-code": "物流码", "transaction-id": "交易ID", + "transition-to-state": "", + "transitioned-to-state-success": "", "unfulfilled": "未配货", "unit-price": "单价" }, @@ -686,4 +687,4 @@ "job-result": "", "job-state": "" } -} +} \ No newline at end of file diff --git a/packages/admin-ui/src/lib/static/i18n-messages/zh_Hant.json b/packages/admin-ui/src/lib/static/i18n-messages/zh_Hant.json index 9b846df7b6..dd9c55b565 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/zh_Hant.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/zh_Hant.json @@ -61,7 +61,6 @@ "confirm-adding-options-delete-default-body": "新增規格到此產品會引致包含此規格的產品被移除,確認繼續吗?", "confirm-adding-options-delete-default-title": "確認移除產品規格嗎?", "confirm-delete-administrator": "", - "confirm-delete-asset": "", "confirm-delete-assets": "", "confirm-delete-channel": "確認移除渠道?", "confirm-delete-collection": "確認移除商品系列吗?", @@ -602,6 +601,8 @@ "total": "總計金額", "tracking-code": "物流碼", "transaction-id": "交易編號", + "transition-to-state": "", + "transitioned-to-state-success": "", "unfulfilled": "未配貨", "unit-price": "單價" }, @@ -686,4 +687,4 @@ "job-result": "", "job-state": "" } -} +} \ No newline at end of file