diff --git a/docs/concepts/configuration.md b/docs/concepts/configuration.md index b8e6ce24d6..35dbf3a54d 100644 --- a/docs/concepts/configuration.md +++ b/docs/concepts/configuration.md @@ -165,7 +165,6 @@ Of course, the ICM server must supply appropriate REST resources to leverage fun | **B2B Features** | | | businessCustomerRegistration | Create business customers on registration | | costCenters | Cost center feature | -| messageToMerchant | Write a message to the merchant at checkout | | orderTemplates | Order template feature | | punchout | Punchout feature | | quickorder | Quick order page and direct add to cart input | diff --git a/docs/guides/migrations.md b/docs/guides/migrations.md index c69647b569..11890a471b 100644 --- a/docs/guides/migrations.md +++ b/docs/guides/migrations.md @@ -12,6 +12,10 @@ kb_sync_latest_only The OrderListComponent is strictly presentational, components using it have to supply the data. The getOrders method of the OrderService doesn't fetch all related order data by default, you can provide an additional parameter to include the data you need. +In ICM 11 the `messageToMerchant` flag can be configured in the back office and its setting is supplied by the `/configurations` REST call. +For this reason the `messageToMerchant` feature toggle is removed as a configurable feature toggle. +To still be able to configure the message to merchant feature via feature toggle in ICM 7.10 environments an [`ICMCompatibilityInterceptor`](../../src/app/core/interceptors/icm-compatibility.interceptor.ts) was introduced that can be enabled in ICM 7.10 based projects in the [`core.module.ts`](../../src/app/core/core.module.ts). + ## From 4.2 to 5.0 Starting with the Intershop PWA 5.0 we develop and test against an Intershop Commerce Management 11 server. diff --git a/projects/requisition-management/src/app/pages/requisition-detail/requisition-detail-page.component.html b/projects/requisition-management/src/app/pages/requisition-detail/requisition-detail-page.component.html index a420c9fe56..7ceba33faf 100644 --- a/projects/requisition-management/src/app/pages/requisition-detail/requisition-detail-page.component.html +++ b/projects/requisition-management/src/app/pages/requisition-detail/requisition-detail-page.component.html @@ -37,7 +37,7 @@

{{ 'approval.detailspage.order_details.heading' | translate }}

-
+
diff --git a/projects/requisition-management/src/app/pages/requisition-detail/requisition-detail-page.component.spec.ts b/projects/requisition-management/src/app/pages/requisition-detail/requisition-detail-page.component.spec.ts index f03f173ca7..e07c7c85e4 100644 --- a/projects/requisition-management/src/app/pages/requisition-detail/requisition-detail-page.component.spec.ts +++ b/projects/requisition-management/src/app/pages/requisition-detail/requisition-detail-page.component.spec.ts @@ -2,12 +2,12 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { TranslateModule } from '@ngx-translate/core'; -import { MockComponent, MockDirective } from 'ng-mocks'; +import { MockComponent, MockDirective, MockPipe } from 'ng-mocks'; import { of } from 'rxjs'; import { instance, mock, when } from 'ts-mockito'; import { AuthorizationToggleDirective } from 'ish-core/directives/authorization-toggle.directive'; -import { FeatureToggleModule } from 'ish-core/feature-toggle.module'; +import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe'; import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; import { AddressComponent } from 'ish-shared/components/address/address/address.component'; import { BasketCostSummaryComponent } from 'ish-shared/components/basket/basket-cost-summary/basket-cost-summary.component'; @@ -34,7 +34,7 @@ describe('Requisition Detail Page Component', () => { context = mock(RequisitionContextFacade); await TestBed.configureTestingModule({ - imports: [FeatureToggleModule.forTesting('messageToMerchant'), RouterTestingModule, TranslateModule.forRoot()], + imports: [RouterTestingModule, TranslateModule.forRoot()], declarations: [ MockComponent(AddressComponent), MockComponent(BasketCostSummaryComponent), @@ -47,6 +47,7 @@ describe('Requisition Detail Page Component', () => { MockComponent(RequisitionRejectDialogComponent), MockComponent(RequisitionSummaryComponent), MockDirective(AuthorizationToggleDirective), + MockPipe(ServerSettingPipe, path => path === 'shipping.messageToMerchant'), RequisitionDetailPageComponent, ], }) diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index 62416b3801..33f70302c4 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -30,6 +30,8 @@ import { DefaultErrorHandler } from './utils/default-error-handler'; StateManagementModule, ], providers: [ + // include the ICMCompatibilityInterceptor to add support for REST API changes (e.g. messageToMerchant) + // { provide: HTTP_INTERCEPTORS, useClass: ICMCompatibilityInterceptor, multi: true }, { provide: HTTP_INTERCEPTORS, useClass: PGIDChangeInterceptor, multi: true }, { provide: HTTP_INTERCEPTORS, useClass: ICMErrorMapperInterceptor, multi: true }, { diff --git a/src/app/core/interceptors/icm-compatibility.interceptor.ts b/src/app/core/interceptors/icm-compatibility.interceptor.ts new file mode 100644 index 0000000000..787894fe3f --- /dev/null +++ b/src/app/core/interceptors/icm-compatibility.interceptor.ts @@ -0,0 +1,31 @@ +import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http'; +import { Injectable } from '@angular/core'; +import { Observable, map, withLatestFrom } from 'rxjs'; + +import { FeatureToggleService } from 'ish-core/feature-toggle.module'; + +// not-dead-code +/** + * provides a compatibility layer for REST API changes in newer ICM versions + * please enable the interceptor in the `core.module.ts` if needed + * e.g. `messageToMerchant` is no longer an environment feature toggle in ICM 11 but controlled by the configurations call + */ +@Injectable() +export class ICMCompatibilityInterceptor implements HttpInterceptor { + constructor(private featureToggleService: FeatureToggleService) {} + + intercept(req: HttpRequest, next: HttpHandler): Observable> { + if (req.url.endsWith('/configurations') && req instanceof HttpRequest) { + return next.handle(req).pipe( + withLatestFrom(this.featureToggleService.enabled$('messageToMerchant')), + map(([event, messageToMerchant]) => { + if (event instanceof HttpResponse && messageToMerchant && event.body?.data?.shipping) { + event.body.data.shipping.messageToMerchant = true; + } + return event; + }) + ); + } + return next.handle(req); + } +} diff --git a/src/app/pages/account-order/account-order/account-order.component.html b/src/app/pages/account-order/account-order/account-order.component.html index 7297728ad3..7875209b73 100644 --- a/src/app/pages/account-order/account-order/account-order.component.html +++ b/src/app/pages/account-order/account-order/account-order.component.html @@ -48,7 +48,7 @@

{{ 'account.orderdetails.heading.default' | translate }}

- + diff --git a/src/app/pages/account-order/account-order/account-order.component.spec.ts b/src/app/pages/account-order/account-order/account-order.component.spec.ts index 35e6e8a919..9d4e2106f6 100644 --- a/src/app/pages/account-order/account-order/account-order.component.spec.ts +++ b/src/app/pages/account-order/account-order/account-order.component.spec.ts @@ -5,6 +5,7 @@ import { MockComponent, MockPipe } from 'ng-mocks'; import { FeatureToggleModule } from 'ish-core/feature-toggle.module'; import { DatePipe } from 'ish-core/pipes/date.pipe'; +import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe'; import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; import { AddressComponent } from 'ish-shared/components/address/address/address.component'; import { BasketCostSummaryComponent } from 'ish-shared/components/basket/basket-cost-summary/basket-cost-summary.component'; @@ -32,8 +33,9 @@ describe('Account Order Component', () => { MockComponent(InfoBoxComponent), MockComponent(LineItemListComponent), MockPipe(DatePipe), + MockPipe(ServerSettingPipe, path => path === 'shipping.messageToMerchant'), ], - imports: [FeatureToggleModule.forTesting('messageToMerchant'), TranslateModule.forRoot()], + imports: [FeatureToggleModule.forTesting(), TranslateModule.forRoot()], }).compileComponents(); }); diff --git a/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.html b/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.html index cff39d2093..5c187abd30 100644 --- a/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.html +++ b/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.html @@ -3,7 +3,7 @@ - + diff --git a/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.spec.ts b/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.spec.ts index 501e36091a..eb8c66f005 100644 --- a/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.spec.ts +++ b/src/app/pages/checkout-receipt/checkout-receipt/checkout-receipt.component.spec.ts @@ -1,9 +1,10 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { TranslateModule } from '@ngx-translate/core'; -import { MockComponent } from 'ng-mocks'; +import { MockComponent, MockPipe } from 'ng-mocks'; import { FeatureToggleModule } from 'ish-core/feature-toggle.module'; +import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe'; import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; import { AddressComponent } from 'ish-shared/components/address/address/address.component'; @@ -31,8 +32,9 @@ describe('Checkout Receipt Component', () => { MockComponent(FaIconComponent), MockComponent(InfoBoxComponent), MockComponent(LineItemListComponent), + MockPipe(ServerSettingPipe, path => path === 'shipping.messageToMerchant'), ], - imports: [FeatureToggleModule.forTesting('messageToMerchant'), TranslateModule.forRoot()], + imports: [FeatureToggleModule.forTesting(), TranslateModule.forRoot()], }).compileComponents(); }); diff --git a/src/app/pages/checkout-review/checkout-review/checkout-review.component.html b/src/app/pages/checkout-review/checkout-review/checkout-review.component.html index 773b551cad..44eed319b2 100644 --- a/src/app/pages/checkout-review/checkout-review/checkout-review.component.html +++ b/src/app/pages/checkout-review/checkout-review/checkout-review.component.html @@ -33,7 +33,7 @@

- + diff --git a/src/app/pages/checkout-review/checkout-review/checkout-review.component.spec.ts b/src/app/pages/checkout-review/checkout-review/checkout-review.component.spec.ts index a9ad976a2b..b9f3e1a48d 100644 --- a/src/app/pages/checkout-review/checkout-review/checkout-review.component.spec.ts +++ b/src/app/pages/checkout-review/checkout-review/checkout-review.component.spec.ts @@ -2,12 +2,13 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ReactiveFormsModule, UntypedFormGroup } from '@angular/forms'; import { FormlyModule } from '@ngx-formly/core'; import { TranslateModule } from '@ngx-translate/core'; -import { MockComponent, MockDirective } from 'ng-mocks'; +import { MockComponent, MockDirective, MockPipe } from 'ng-mocks'; import { spy, verify } from 'ts-mockito'; import { ServerHtmlDirective } from 'ish-core/directives/server-html.directive'; import { FeatureToggleModule } from 'ish-core/feature-toggle.module'; import { BasketApproval } from 'ish-core/models/basket-approval/basket-approval.model'; +import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe'; import { makeHttpError } from 'ish-core/utils/dev/api-service-utils'; import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; import { findAllCustomElements } from 'ish-core/utils/dev/html-query-utils'; @@ -47,9 +48,10 @@ describe('Checkout Review Component', () => { MockComponent(LineItemListComponent), MockComponent(ModalDialogLinkComponent), MockDirective(ServerHtmlDirective), + MockPipe(ServerSettingPipe, path => path === 'shipping.messageToMerchant'), ], imports: [ - FeatureToggleModule.forTesting('messageToMerchant'), + FeatureToggleModule.forTesting(), FormlyModule.forRoot({ types: [{ name: 'ish-checkout-review-tac-field', component: CheckoutReviewTacFieldComponent }], }), diff --git a/src/app/pages/checkout-shipping/checkout-shipping-page.component.html b/src/app/pages/checkout-shipping/checkout-shipping-page.component.html index a51eed72b7..499729f60e 100644 --- a/src/app/pages/checkout-shipping/checkout-shipping-page.component.html +++ b/src/app/pages/checkout-shipping/checkout-shipping-page.component.html @@ -32,7 +32,7 @@

{{ 'checkout.shipping_method.selection.heading' | translate }}

- + diff --git a/src/app/pages/checkout-shipping/checkout-shipping-page.component.spec.ts b/src/app/pages/checkout-shipping/checkout-shipping-page.component.spec.ts index 53a179da2d..849768e301 100644 --- a/src/app/pages/checkout-shipping/checkout-shipping-page.component.spec.ts +++ b/src/app/pages/checkout-shipping/checkout-shipping-page.component.spec.ts @@ -1,13 +1,13 @@ import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; -import { MockComponent, MockDirective } from 'ng-mocks'; +import { MockComponent, MockDirective, MockPipe } from 'ng-mocks'; import { of } from 'rxjs'; import { anything, instance, mock, verify, when } from 'ts-mockito'; import { ServerHtmlDirective } from 'ish-core/directives/server-html.directive'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { CheckoutFacade } from 'ish-core/facades/checkout.facade'; -import { FeatureToggleModule } from 'ish-core/feature-toggle.module'; +import { ServerSettingPipe } from 'ish-core/pipes/server-setting.pipe'; import { makeHttpError } from 'ish-core/utils/dev/api-service-utils'; import { BasketMockData } from 'ish-core/utils/dev/basket-mock-data'; import { BasketAddressSummaryComponent } from 'ish-shared/components/basket/basket-address-summary/basket-address-summary.component'; @@ -39,8 +39,9 @@ describe('Checkout Shipping Page Component', () => { MockComponent(CheckoutShippingComponent), MockComponent(ErrorMessageComponent), MockDirective(ServerHtmlDirective), + MockPipe(ServerSettingPipe, path => path === 'shipping.messageToMerchant'), ], - imports: [FeatureToggleModule.forTesting('messageToMerchant'), TranslateModule.forRoot()], + imports: [TranslateModule.forRoot()], providers: [ { provide: AccountFacade, useFactory: () => instance(mock(AccountFacade)) }, { provide: CheckoutFacade, useFactory: () => instance(checkoutFacade) }, diff --git a/src/environments/environment.b2b.ts b/src/environments/environment.b2b.ts index 7d96d18eab..a6fc503c0f 100644 --- a/src/environments/environment.b2b.ts +++ b/src/environments/environment.b2b.ts @@ -13,7 +13,6 @@ export const environment: Environment = { 'businessCustomerRegistration', 'costCenters', 'maps', - 'messageToMerchant', 'punchout', 'quickorder', 'quoting', diff --git a/src/environments/environment.model.ts b/src/environments/environment.model.ts index d26bf8db15..b42139945e 100644 --- a/src/environments/environment.model.ts +++ b/src/environments/environment.model.ts @@ -35,7 +35,6 @@ export interface Environment { /* B2B features */ | 'businessCustomerRegistration' | 'costCenters' - | 'messageToMerchant' | 'quoting' | 'quickorder' | 'orderTemplates' @@ -49,6 +48,8 @@ export interface Environment { | 'tracking' | 'tacton' | 'maps' + /* ICM compatibility - see ICMCompatibilityInterceptor */ + | 'messageToMerchant' )[]; /* ADDITIONAL FEATURE CONFIGURATIONS */