All files / src/app/shared/cms/components/cms-static-page cms-static-page.component.ts

100% Statements 8/8
80% Branches 4/5
100% Functions 2/2
100% Lines 8/8

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 391x     1x   1x                       1x         3x     2x 2x                 2x      
import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
import { Observable } from 'rxjs';
 
import { CMSFacade } from 'ish-core/facades/cms.facade';
import { ContentPageTreeView } from 'ish-core/models/content-page-tree-view/content-page-tree-view.model';
import { ContentPageletView } from 'ish-core/models/content-view/content-view.model';
import { CMSComponent } from 'ish-shared/cms/models/cms-component/cms-component.model';
 
/**
 * The CMS Static Page Component to render CMS managed static content pages.
 * With optional side panel and content page hierarchy navigation.
 */
@Component({
  selector: 'ish-cms-static-page',
  templateUrl: './cms-static-page.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CMSStaticPageComponent implements CMSComponent, OnChanges {
  @Input({ required: true }) pagelet: ContentPageletView;
 
  contentPageTree$: Observable<ContentPageTreeView>;
 
  constructor(private cmsFacade: CMSFacade) {}
 
  ngOnChanges() {
    if (this.pagelet?.stringParam('NavigationRoot')) {
      this.contentPageTree$ = this.cmsFacade.contentPageTree$(
        this.pagelet.stringParam('NavigationRoot'),
        this.pagelet.numberParam('NavigationDepth', 0)
      );
    }
 
    // explicitly set breadcrumb data for content pages that use the Static Content component
    // to have the complete breadcrumb data it is necessary that the content page tree
    // was fetched for the given 'NavigationRoot' even if the navigation is not shown in the side panel
    this.cmsFacade.setBreadcrumbForContentPage(this.pagelet?.stringParam('NavigationRoot'));
  }
}