diff --git a/src/app/core/directives/product-context.directive.ts b/src/app/core/directives/product-context.directive.ts index 0cb819a6475..af7bfd60cb7 100644 --- a/src/app/core/directives/product-context.directive.ts +++ b/src/app/core/directives/product-context.directive.ts @@ -49,6 +49,10 @@ export class ProductContextDirective implements OnInit, OnChanges { @Input() set parts(parts: SkuQuantityType[]) { this.context.set('parts', () => parts); + this.context.set('displayProperties', () => ({ + readOnly: true, + addToBasket: true, + })); } @Input() diff --git a/src/app/core/facades/product-context.facade.spec.ts b/src/app/core/facades/product-context.facade.spec.ts index c291559f2be..4cba802e587 100644 --- a/src/app/core/facades/product-context.facade.spec.ts +++ b/src/app/core/facades/product-context.facade.spec.ts @@ -54,10 +54,6 @@ describe('Product Context Facade', () => { Object { "allowZeroQuantity": false, "categoryId": null, - "displayProperties": Object { - "addToBasket": true, - "readOnly": true, - }, "propagateActive": true, "requiredCompletenessLevel": 2, } diff --git a/src/app/core/facades/product-context.facade.ts b/src/app/core/facades/product-context.facade.ts index bd20c8eb93d..96c36d5f51f 100644 --- a/src/app/core/facades/product-context.facade.ts +++ b/src/app/core/facades/product-context.facade.ts @@ -127,10 +127,6 @@ export class ProductContextFacade extends RxState { requiredCompletenessLevel: ProductCompletenessLevel.List, propagateActive: true, allowZeroQuantity: false, - displayProperties: { - readOnly: true, - addToBasket: true, - }, // tslint:disable-next-line: no-null-keyword categoryId: null, }); @@ -332,6 +328,11 @@ export class ProductContextFacade extends RxState { current[index] = childState; return current; }); + this.set('displayProperties', state => ({ + ...state.displayProperties, + readOnly: true, + addToBasket: true, + })); } validDebouncedQuantityUpdate$(time = 800) { diff --git a/src/app/pages/product/product-images/product-images.component.html b/src/app/pages/product/product-images/product-images.component.html index 7bdf0246b7e..4c962ff5883 100644 --- a/src/app/pages/product/product-images/product-images.component.html +++ b/src/app/pages/product/product-images/product-images.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/src/app/pages/product/product-images/product-images.component.ts b/src/app/pages/product/product-images/product-images.component.ts index 80a105a353b..4ab6bb64c7e 100644 --- a/src/app/pages/product/product-images/product-images.component.ts +++ b/src/app/pages/product/product-images/product-images.component.ts @@ -1,9 +1,10 @@ -import { ChangeDetectionStrategy, Component, ViewChild } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit, ViewChild } from '@angular/core'; import { NgbCarousel } from '@ng-bootstrap/ng-bootstrap'; +import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; import { ProductContextFacade } from 'ish-core/facades/product-context.facade'; -import { ProductHelper } from 'ish-core/models/product/product.model'; +import { AnyProductViewType, ProductHelper } from 'ish-core/models/product/product.model'; /** * The Product Images Component @@ -19,15 +20,21 @@ import { ProductHelper } from 'ish-core/models/product/product.model'; templateUrl: './product-images.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) -export class ProductImagesComponent { +export class ProductImagesComponent implements OnInit { @ViewChild('carousel') carousel: NgbCarousel; activeSlide = '0'; + product$: Observable; + constructor(private context: ProductContextFacade) {} + ngOnInit() { + this.product$ = this.context.select('product'); + } + getImageViewIDsExcludePrimary$(imageType: string) { - return this.context.select('product').pipe(map(p => ProductHelper.getImageViewIDsExcludePrimary(p, imageType))); + return this.product$.pipe(map(p => ProductHelper.getImageViewIDsExcludePrimary(p, imageType))); } /** diff --git a/src/app/pages/product/product-page.component.html b/src/app/pages/product/product-page.component.html index d95d3c5a59f..330132ee166 100644 --- a/src/app/pages/product/product-page.component.html +++ b/src/app/pages/product/product-page.component.html @@ -1,19 +1,19 @@
- + - - + - + - + - + - + - - +
- + diff --git a/src/app/pages/product/product-page.component.spec.ts b/src/app/pages/product/product-page.component.spec.ts index d546d9a8598..9d3aa44c49c 100644 --- a/src/app/pages/product/product-page.component.spec.ts +++ b/src/app/pages/product/product-page.component.spec.ts @@ -67,12 +67,7 @@ describe('Product Page Component', () => { fixture.detectChanges(); - expect(findAllCustomElements(element)).toMatchInlineSnapshot(` - Array [ - "ish-loading", - "ish-recently-viewed", - ] - `); + expect(findAllCustomElements(element)).toContain('ish-loading'); }); it('should display product page components when product is available', () => {