From 10f7094a320451b6c2cdcb1708adb7b3dcf85275 Mon Sep 17 00:00:00 2001 From: Danilo Hoffmann Date: Mon, 2 Mar 2020 14:04:59 +0100 Subject: [PATCH] fix: set correct URL for sharing product page via email (#128, #138) - removed currentUrl$ from AppFacade - use document.URL for sharing link Closes #128 --- src/app/core/facades/app.facade.ts | 9 +-------- .../product-detail-actions.component.html | 2 +- .../product-detail-actions.component.ts | 6 ++++-- .../product/product-detail/product-detail.component.html | 6 +----- .../product/product-detail/product-detail.component.ts | 1 - src/app/pages/product/product-page.component.html | 1 - src/app/pages/product/product-page.component.ts | 5 ----- 7 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/app/core/facades/app.facade.ts b/src/app/core/facades/app.facade.ts index 509850dfdd..22efdd8b55 100644 --- a/src/app/core/facades/app.facade.ts +++ b/src/app/core/facades/app.facade.ts @@ -1,10 +1,8 @@ -import { Location } from '@angular/common'; import { Injectable } from '@angular/core'; import { Store, select } from '@ngrx/store'; import { combineLatest } from 'rxjs'; import { map } from 'rxjs/operators'; -import { getICMBaseURL } from 'ish-core/store/configuration'; import { LoadCountries, getAllCountries, getCountriesLoading } from 'ish-core/store/countries'; import { getGeneralError, getGeneralErrorType } from 'ish-core/store/error'; import { getAvailableLocales, getCurrentLocale } from 'ish-core/store/locale'; @@ -19,12 +17,7 @@ import { @Injectable({ providedIn: 'root' }) export class AppFacade { - constructor(private store: Store<{}>, private location: Location) {} - - currentUrl$ = this.store.pipe( - select(getICMBaseURL), - map(baseUrl => baseUrl + this.location.path()) - ); + constructor(private store: Store<{}>) {} headerType$ = this.store.pipe(select(getHeaderType)); deviceType$ = this.store.pipe(select(getDeviceType)); diff --git a/src/app/pages/product/product-detail-actions/product-detail-actions.component.html b/src/app/pages/product/product-detail-actions/product-detail-actions.component.html index eab544a8a4..0f1af1cea1 100644 --- a/src/app/pages/product/product-detail-actions/product-detail-actions.component.html +++ b/src/app/pages/product/product-detail-actions/product-detail-actions.component.html @@ -33,7 +33,7 @@ diff --git a/src/app/pages/product/product-detail-actions/product-detail-actions.component.ts b/src/app/pages/product/product-detail-actions/product-detail-actions.component.ts index d89b8ee231..11757f16f9 100644 --- a/src/app/pages/product/product-detail-actions/product-detail-actions.component.ts +++ b/src/app/pages/product/product-detail-actions/product-detail-actions.component.ts @@ -1,4 +1,5 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; +import { DOCUMENT } from '@angular/common'; +import { ChangeDetectionStrategy, Component, EventEmitter, Inject, Input, Output } from '@angular/core'; import { Product, ProductHelper } from 'ish-core/models/product/product.model'; @@ -9,7 +10,6 @@ import { Product, ProductHelper } from 'ish-core/models/product/product.model'; }) export class ProductDetailActionsComponent { @Input() product: Product; - @Input() currentUrl: string; @Output() productToCompare = new EventEmitter(); // TODO: to be removed once channelName inforamtion available in system @@ -20,4 +20,6 @@ export class ProductDetailActionsComponent { addToCompare() { this.productToCompare.emit(); } + + constructor(@Inject(DOCUMENT) public document: Document) {} } diff --git a/src/app/pages/product/product-detail/product-detail.component.html b/src/app/pages/product/product-detail/product-detail.component.html index 804166bebd..6bf2ad86cb 100644 --- a/src/app/pages/product/product-detail/product-detail.component.html +++ b/src/app/pages/product/product-detail/product-detail.component.html @@ -1,8 +1,4 @@ - +
diff --git a/src/app/pages/product/product-detail/product-detail.component.ts b/src/app/pages/product/product-detail/product-detail.component.ts index ff775c2de8..4884b7bdcd 100644 --- a/src/app/pages/product/product-detail/product-detail.component.ts +++ b/src/app/pages/product/product-detail/product-detail.component.ts @@ -21,7 +21,6 @@ export class ProductDetailComponent implements OnInit, OnDestroy { @Input() product: ProductView | VariationProductView | VariationProductMasterView; @Input() quantity: number; @Input() price: ProductPrices; - @Input() currentUrl: string; @Input() variationOptions: VariationOptionGroup[]; @Output() productToBasket = new EventEmitter<{ sku: string; quantity: number }>(); @Output() productToCompare = new EventEmitter(); diff --git a/src/app/pages/product/product-page.component.html b/src/app/pages/product/product-page.component.html index 2b5e8e9d57..e3229f2d79 100644 --- a/src/app/pages/product/product-page.component.html +++ b/src/app/pages/product/product-page.component.html @@ -9,7 +9,6 @@ [product]="product" [price]="price$ | async" [(quantity)]="quantity" - [currentUrl]="currentUrl$ | async" [variationOptions]="productVariationOptions$ | async" (productToBasket)="addToBasket()" (productToCompare)="addToCompare($event)" diff --git a/src/app/pages/product/product-page.component.ts b/src/app/pages/product/product-page.component.ts index 52d81430ec..28b7f06a40 100644 --- a/src/app/pages/product/product-page.component.ts +++ b/src/app/pages/product/product-page.component.ts @@ -3,7 +3,6 @@ import { Router } from '@angular/router'; import { Observable, ReplaySubject, Subject, of } from 'rxjs'; import { filter, map, switchMap, take, takeUntil, withLatestFrom } from 'rxjs/operators'; -import { AppFacade } from 'ish-core/facades/app.facade'; import { ShoppingFacade } from 'ish-core/facades/shopping.facade'; import { FeatureToggleService } from 'ish-core/feature-toggle.module'; import { CategoryView } from 'ish-core/models/category-view/category-view.model'; @@ -38,8 +37,6 @@ export class ProductPageComponent implements OnInit, OnDestroy { quantity: number; price$: Observable; - currentUrl$: Observable; - isProductBundle = ProductHelper.isProductBundle; isRetailSet = ProductHelper.isRetailSet; isMasterProduct = ProductHelper.isMasterProduct; @@ -48,7 +45,6 @@ export class ProductPageComponent implements OnInit, OnDestroy { retailSetParts$ = new ReplaySubject(1); constructor( - private appFacade: AppFacade, private shoppingFacade: ShoppingFacade, private router: Router, private featureToggleService: FeatureToggleService, @@ -61,7 +57,6 @@ export class ProductPageComponent implements OnInit, OnDestroy { this.productVariationOptions$ = this.shoppingFacade.selectedProductVariationOptions$; this.category$ = this.shoppingFacade.selectedCategory$; this.productLoading$ = this.shoppingFacade.productDetailLoading$; - this.currentUrl$ = this.appFacade.currentUrl$; this.product$ .pipe(