Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | 1x 1x 1x 1x 1x 1x 1x 1x | import { ChangeDetectionStrategy, Component, ElementRef, Input, OnChanges } from '@angular/core'; import { Observable } from 'rxjs'; import { CMSFacade } from 'ish-core/facades/cms.facade'; import { CallParameters } from 'ish-core/models/call-parameters/call-parameters.model'; import { ContentPageletEntryPointView } from 'ish-core/models/content-view/content-view.model'; /** * The Content ViewContext Component renders the content of the ViewContext * (identified by the 'viewContextId') for the current context * (given by the 'callParameters') if any content is available. * * @example * <ish-content-viewcontext * viewContextId="vc_product_detail" * [callParameters]="{ Product: product.sku, Category: category.categoryRef }" * ></ish-content-viewcontext> */ @Component({ selector: 'ish-content-viewcontext', templateUrl: './content-viewcontext.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) export class ContentViewcontextComponent implements OnChanges { /** * The ID of the View Context whose content is to be rendered. */ @Input({ required: true }) viewContextId: string; /** * The call parameter object to provide the context, e.g. { Product: product.sku, Category: category.categoryRef }. */ @Input({ required: true }) callParameters: CallParameters; viewContextEntrypoint$: Observable<ContentPageletEntryPointView>; constructor(private cmsFacade: CMSFacade, private hostElement: ElementRef) {} ngOnChanges() { this.viewContextEntrypoint$ = this.cmsFacade.viewContext$(this.viewContextId, this.callParameters); // the 'callparametersstring' attribute is needed for the Design View - do not remove this code this.hostElement.nativeElement.setAttribute( 'callparametersstring', Object.keys(this.callParameters) .map(key => `${key}=${this.callParameters[key]}`) .join('&') ); } } |