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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | 3x 3x 3x 3x 3x 3x 3x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x 1x 1x 1x 1x 1x 1x 4x 1x 3x 1x | import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { Observable, combineLatest, map } 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;
isPageletSelected$: Observable<boolean>;
isPageletPreviewed$: Observable<boolean>;
shouldScroll$: Observable<boolean>;
constructor(
private cmsFacade: CMSFacade,
private previewService: PreviewService,
private designViewService: DesignViewService
) {}
ngOnInit() {
this.isDesignViewMode = this.previewService.isDesignViewMode;
if (this.isDesignViewMode) {
this.initializeComponent();
}
}
onPageletHover() {
Iif (this.isDesignViewMode && this.pageletId) {
this.triggerAction(this.pageletId, 'pageletPreview');
}
}
onPageletLeave() {
Iif (this.isDesignViewMode) {
this.triggerAction(undefined, 'pageletPreview');
}
}
triggerAction(id: string, action: string) {
this.designViewService.messageToHost({ type: 'dv-clientAction', payload: { id, action } });
}
private initializeComponent() {
if (this.pageletId) {
this.type = 'pagelet';
this.pagelet$ = this.cmsFacade.pagelet$(this.pageletId);
this.isPageletSelected$ = this.cmsFacade.designViewSelectedPageletId$.pipe(
map(id => (this.isDesignViewMode ? this.pageletId === id : false))
);
this.isPageletPreviewed$ = combineLatest([
this.cmsFacade.designViewPreviewedPageletId$,
this.cmsFacade.designViewSelectedPageletId$,
]).pipe(
map(
([previewedId, selectedId]) =>
this.isDesignViewMode && this.pageletId === previewedId && this.pageletId !== selectedId
)
);
this.shouldScroll$ = this.cmsFacade.designViewScrollToPageletId$.pipe(
map(id => this.isDesignViewMode && id === this.pageletId)
);
} else if (this.slotId) {
this.type = 'slot';
} else if (this.include) {
this.type = 'include';
}
}
}
|