All files / src/app/shared/cms/components/content-design-view-wrapper content-design-view-wrapper.component.ts

94.73% Statements 18/19
82.35% Branches 14/17
66.66% Functions 2/3
94.73% Lines 18/19

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 523x     3x 3x 3x 3x               3x                       5x     5x 5x 5x       5x 1x 1x 4x 1x 3x 1x     5x              
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { Observable } from 'rxjs';
 
import { CMSFacade } from 'ish-core/facades/cms.facade';
import { ContentPageletEntryPointView, ContentPageletView } from 'ish-core/models/content-view/content-view.model';
import { DesignViewService } from 'ish-core/utils/design-view/design-view.service';
import { PreviewService } from 'ish-core/utils/preview/preview.service';
 
@Component({
  selector: 'ish-content-design-view-wrapper',
  templateUrl: './content-design-view-wrapper.component.html',
  styleUrls: ['./content-design-view-wrapper.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ContentDesignViewWrapperComponent implements OnInit {
  // pagelet parameter
  @Input() pageletId: string;
  // slot parameters
  @Input() slotId: string;
  @Input() pagelet: ContentPageletView;
  // include parameter
  @Input() include: ContentPageletEntryPointView;
 
  pagelet$: Observable<ContentPageletView>;
  type: 'pagelet' | 'slot' | 'include';
 
  isDesignViewMode = false; // temporary activation switch
 
  constructor(
    private cmsFacade: CMSFacade,
    private previewService: PreviewService,
    private designViewService: DesignViewService
  ) {}
 
  ngOnInit() {
    if (this.pageletId) {
      this.type = 'pagelet';
      this.pagelet$ = this.cmsFacade.pagelet$(this.pageletId);
    } else if (this.slotId) {
      this.type = 'slot';
    } else if (this.include) {
      this.type = 'include';
    }
 
    this.isDesignViewMode = this.previewService.isDesignViewMode;
  }
 
  triggerAction(id: string, action: string) {
    this.designViewService.messageToHost({ type: 'dv-clientAction', payload: { id, action } });
  }
}