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 | 1x 1x 1x 1x 7x 7x 7x 7x 14x 20x | import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
import { Observable } from 'rxjs';
import { ShoppingFacade } from 'ish-core/facades/shopping.facade';
import { ContentPageletView } from 'ish-core/models/content-view/content-view.model';
import { NavigationCategory } from 'ish-core/models/navigation-category/navigation-category.model';
import { CMSComponent } from 'ish-shared/cms/models/cms-component/cms-component.model';
@Component({
selector: 'ish-cms-navigation-category',
templateUrl: './cms-navigation-category.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class CMSNavigationCategoryComponent implements CMSComponent, OnChanges {
@Input({ required: true }) pagelet: ContentPageletView;
categoryTree$: Observable<NavigationCategory>;
private openedCategories: string[] = [];
constructor(private shoppingFacade: ShoppingFacade) {}
ngOnChanges(): void {
if (this.pagelet?.hasParam('Category')) {
this.categoryTree$ = this.shoppingFacade.navigationCategoryTree$(
this.pagelet.stringParam('Category'),
this.pagelet.numberParam('SubNavigationDepth', 0)
);
}
}
showSubMenu(childCount: number) {
return (this.pagelet.hasParam('SubNavigationDepth') &&
this.pagelet.numberParam('SubNavigationDepth') > 0 &&
childCount) ||
this.pagelet.hasParam('SubNavigationHTML')
? true
: false;
}
subMenuShow(subMenu: HTMLElement) {
subMenu.classList.add('hover');
}
subMenuHide(subMenu: HTMLElement) {
subMenu.classList.remove('hover');
}
/**
* Indicate if specific content page is expanded.
*/
isOpened(uniqueId: string): boolean {
return this.openedCategories.includes(uniqueId);
}
/**
* Toggle content page open state.
*/
toggleOpen(uniqueId: string) {
const index = this.openedCategories.findIndex(id => id === uniqueId);
index > -1 ? this.openedCategories.splice(index, 1) : this.openedCategories.push(uniqueId);
}
}
|