From 90ed7c487c169f8151fa3d7412a220a8413c1176 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Mon, 1 Feb 2021 21:21:21 +0100 Subject: [PATCH] feat(admin-ui): Implement default TaxCategory support Relates to #566 --- packages/admin-ui/i18n-coverage.json | 26 +++++++++---------- .../lib/core/src/common/generated-types.ts | 5 +++- .../data/definitions/settings-definitions.ts | 1 + .../tax-category-detail.component.html | 11 ++++++++ .../tax-category-detail.component.ts | 19 ++++++++------ .../tax-category-list.component.html | 4 +++ .../routing/tax-category-resolver.ts | 1 + .../src/lib/static/i18n-messages/cs.json | 1 + .../src/lib/static/i18n-messages/de.json | 1 + .../src/lib/static/i18n-messages/en.json | 1 + .../src/lib/static/i18n-messages/es.json | 1 + .../src/lib/static/i18n-messages/fr.json | 1 + .../src/lib/static/i18n-messages/pl.json | 1 + .../src/lib/static/i18n-messages/pt_BR.json | 1 + .../src/lib/static/i18n-messages/zh_Hans.json | 1 + .../src/lib/static/i18n-messages/zh_Hant.json | 1 + 16 files changed, 54 insertions(+), 22 deletions(-) diff --git a/packages/admin-ui/i18n-coverage.json b/packages/admin-ui/i18n-coverage.json index 42f4df3d87..e1f9fa4dca 100644 --- a/packages/admin-ui/i18n-coverage.json +++ b/packages/admin-ui/i18n-coverage.json @@ -1,49 +1,49 @@ { - "generatedOn": "2021-02-01T13:23:30.145Z", - "lastCommit": "56c39f8ada2711dd731de4543e48358d24212b3f", + "generatedOn": "2021-02-01T20:16:12.347Z", + "lastCommit": "7eb21d16d0c17f87e9cc267a024b937c2e4deefa", "translationStatus": { "cs": { - "tokenCount": 767, + "tokenCount": 768, "translatedCount": 753, "percentage": 98 }, "de": { - "tokenCount": 767, + "tokenCount": 768, "translatedCount": 594, "percentage": 77 }, "en": { - "tokenCount": 767, - "translatedCount": 764, + "tokenCount": 768, + "translatedCount": 767, "percentage": 100 }, "es": { - "tokenCount": 767, + "tokenCount": 768, "translatedCount": 456, "percentage": 59 }, "fr": { - "tokenCount": 767, + "tokenCount": 768, "translatedCount": 690, "percentage": 90 }, "pl": { - "tokenCount": 767, + "tokenCount": 768, "translatedCount": 549, - "percentage": 72 + "percentage": 71 }, "pt_BR": { - "tokenCount": 767, + "tokenCount": 768, "translatedCount": 749, "percentage": 98 }, "zh_Hans": { - "tokenCount": 767, + "tokenCount": 768, "translatedCount": 531, "percentage": 69 }, "zh_Hant": { - "tokenCount": 767, + "tokenCount": 768, "translatedCount": 531, "percentage": 69 } 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 f585039fc6..0535b3efa8 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 @@ -2418,11 +2418,13 @@ export type UpdateTagInput = { export type CreateTaxCategoryInput = { name: Scalars['String']; + isDefault?: Maybe; }; export type UpdateTaxCategoryInput = { id: Scalars['ID']; name?: Maybe; + isDefault?: Maybe; }; export type CreateTaxRateInput = { @@ -4224,6 +4226,7 @@ export type TaxCategory = Node & { createdAt: Scalars['DateTime']; updatedAt: Scalars['DateTime']; name: Scalars['String']; + isDefault: Scalars['Boolean']; }; export type TaxRate = Node & { @@ -6925,7 +6928,7 @@ export type RemoveMembersFromZoneMutation = { removeMembersFromZone: ( export type TaxCategoryFragment = ( { __typename?: 'TaxCategory' } - & Pick + & Pick ); export type GetTaxCategoriesQueryVariables = Exact<{ [key: string]: never; }>; diff --git a/packages/admin-ui/src/lib/core/src/data/definitions/settings-definitions.ts b/packages/admin-ui/src/lib/core/src/data/definitions/settings-definitions.ts index bbf60885ef..7da083f57b 100644 --- a/packages/admin-ui/src/lib/core/src/data/definitions/settings-definitions.ts +++ b/packages/admin-ui/src/lib/core/src/data/definitions/settings-definitions.ts @@ -175,6 +175,7 @@ export const TAX_CATEGORY_FRAGMENT = gql` createdAt updatedAt name + isDefault } `; diff --git a/packages/admin-ui/src/lib/settings/src/components/tax-category-detail/tax-category-detail.component.html b/packages/admin-ui/src/lib/settings/src/components/tax-category-detail/tax-category-detail.component.html index 8d8389d28a..d57b6a0a9e 100644 --- a/packages/admin-ui/src/lib/settings/src/components/tax-category-detail/tax-category-detail.component.html +++ b/packages/admin-ui/src/lib/settings/src/components/tax-category-detail/tax-category-detail.component.html @@ -35,4 +35,15 @@ [readonly]="!('UpdateSettings' | hasPermission)" /> + + + + + diff --git a/packages/admin-ui/src/lib/settings/src/components/tax-category-detail/tax-category-detail.component.ts b/packages/admin-ui/src/lib/settings/src/components/tax-category-detail/tax-category-detail.component.ts index e50a2db5f7..092d206480 100644 --- a/packages/admin-ui/src/lib/settings/src/components/tax-category-detail/tax-category-detail.component.ts +++ b/packages/admin-ui/src/lib/settings/src/components/tax-category-detail/tax-category-detail.component.ts @@ -22,7 +22,8 @@ import { mergeMap, take } from 'rxjs/operators'; styleUrls: ['./tax-category-detail.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, }) -export class TaxCategoryDetailComponent extends BaseDetailComponent +export class TaxCategoryDetailComponent + extends BaseDetailComponent implements OnInit, OnDestroy { taxCategory$: Observable; detailForm: FormGroup; @@ -42,7 +43,7 @@ export class TaxCategoryDetailComponent extends BaseDetailComponent { + data => { this.notificationService.success(_('common.notify-create-success'), { entity: 'TaxCategory', }); @@ -74,7 +75,7 @@ export class TaxCategoryDetailComponent extends BaseDetailComponent { + err => { this.notificationService.error(_('common.notify-create-error'), { entity: 'TaxCategory', }); @@ -90,23 +91,24 @@ export class TaxCategoryDetailComponent extends BaseDetailComponent { + mergeMap(taxCategory => { const input = { id: taxCategory.id, name: formValue.name, + isDefault: formValue.isDefault, } as UpdateTaxCategoryInput; return this.dataService.settings.updateTaxCategory(input); }), ) .subscribe( - (data) => { + data => { this.notificationService.success(_('common.notify-update-success'), { entity: 'TaxCategory', }); this.detailForm.markAsPristine(); this.changeDetector.markForCheck(); }, - (err) => { + err => { this.notificationService.error(_('common.notify-update-error'), { entity: 'TaxCategory', }); @@ -120,6 +122,7 @@ export class TaxCategoryDetailComponent extends BaseDetailComponent{{ 'common.name' | translate }} + {{ taxCategory.name }} + + {{ 'common.default-tax-category' | translate }} + dataService.settings.getTaxCategory(id).mapStream(data => data.taxCategory), ); diff --git a/packages/admin-ui/src/lib/static/i18n-messages/cs.json b/packages/admin-ui/src/lib/static/i18n-messages/cs.json index 4e64c2515c..08cc728d8f 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/cs.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/cs.json @@ -179,6 +179,7 @@ "custom-fields": "Extra pole", "default-channel": "Výchozí kanál", "default-language": "Výchozí jazyk", + "default-tax-category": "", "delete": "Smazat", "description": "Popis", "details": "Detaily", 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 de61e6b984..fefeea71f1 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/de.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/de.json @@ -179,6 +179,7 @@ "custom-fields": "Benutzerdefinierte Felder", "default-channel": "Standardkanal", "default-language": "Standardsprache", + "default-tax-category": "", "delete": "Löschen", "description": "Beschreibung", "details": "", 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 54300a0b8e..d8952bcece 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/en.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/en.json @@ -179,6 +179,7 @@ "custom-fields": "Custom fields", "default-channel": "Default channel", "default-language": "Default language", + "default-tax-category": "Default tax category", "delete": "Delete", "description": "Description", "details": "Details", 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 0a3829aa76..d0a6a97d00 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/es.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/es.json @@ -179,6 +179,7 @@ "custom-fields": "Campos personalizados", "default-channel": "Canal de ventas por defecto", "default-language": "Idioma por defecto", + "default-tax-category": "", "delete": "Eliminar", "description": "Descripción", "details": "Detalles", diff --git a/packages/admin-ui/src/lib/static/i18n-messages/fr.json b/packages/admin-ui/src/lib/static/i18n-messages/fr.json index 45752f651d..7e9931c424 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/fr.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/fr.json @@ -179,6 +179,7 @@ "custom-fields": "Champs personnalisés", "default-channel": "Canal par défaut", "default-language": "Langue par défaut", + "default-tax-category": "", "delete": "Supprimer", "description": "Description", "details": "Détails", 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 7174fbff90..1f6a91fe4d 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/pl.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/pl.json @@ -179,6 +179,7 @@ "custom-fields": "Dodatkowe pola", "default-channel": "Domyślny kanał", "default-language": "Domyślny jezyk", + "default-tax-category": "", "delete": "Usuń", "description": "Opis", "details": "", diff --git a/packages/admin-ui/src/lib/static/i18n-messages/pt_BR.json b/packages/admin-ui/src/lib/static/i18n-messages/pt_BR.json index 4c5b3d0ebf..cd6567cc52 100644 --- a/packages/admin-ui/src/lib/static/i18n-messages/pt_BR.json +++ b/packages/admin-ui/src/lib/static/i18n-messages/pt_BR.json @@ -179,6 +179,7 @@ "custom-fields": "Campos customizados", "default-channel": "Canal padrão", "default-language": "Idioma padrão", + "default-tax-category": "", "delete": "Excluir", "description": "Descrição", "details": "Detalhes", 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 e91e60d962..6dfc84929e 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 @@ -179,6 +179,7 @@ "custom-fields": "客户化字段", "default-channel": "默认销售渠道", "default-language": "", + "default-tax-category": "", "delete": "删除", "description": "描述", "details": "", 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 df82a473a5..bbef2fb2a2 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 @@ -179,6 +179,7 @@ "custom-fields": "客戶自訂欄位", "default-channel": "默認渠道", "default-language": "", + "default-tax-category": "", "delete": "移除", "description": "描述", "details": "",