-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CMS navigation category component
- Loading branch information
1 parent
1a6d0ce
commit 19a7ab0
Showing
10 changed files
with
163 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/app/shared/cms/components/cms-navigation-category/cms-navigation-category.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<ng-container *ngIf="pagelet?.hasParam('NavigationCategory')"> | ||
<li | ||
*ngIf="category$ | async as category" | ||
#subMenu | ||
[class]="'dropdown not-first ' + pagelet.stringParam('CSSClass')" | ||
(mouseover)="subMenuShow(subMenu)" | ||
(mouseleave)="subMenuHide(subMenu)" | ||
(click)="subMenuHide(subMenu)" | ||
> | ||
<ng-container *ngIf="pagelet.hasParam('DisplayName'); else noDisplayName"> | ||
<a [routerLink]="category.url" [ngStyle]="{ width: !(showSubMenu() && category.hasChildren) ? '100%' : '' }"> | ||
<div [ishServerHtml]="pagelet.stringParam('DisplayName')"></div> | ||
</a> | ||
</ng-container> | ||
<ng-template #noDisplayName> | ||
<a [routerLink]="category.url">{{ category.name }}</a> | ||
</ng-template> | ||
<ng-container *ngIf="showSubMenu() || pagelet.hasParam('SubNavigationHTML')"> | ||
<ish-sub-category-navigation | ||
[categoryUniqueId]="category.uniqueId" | ||
[subCategoriesDepth]="1" | ||
[view]="'auto'" | ||
></ish-sub-category-navigation> | ||
</ng-container> | ||
</li> | ||
</ng-container> |
31 changes: 31 additions & 0 deletions
31
...p/shared/cms/components/cms-navigation-category/cms-navigation-category.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { instance, mock } from 'ts-mockito'; | ||
|
||
import { ShoppingFacade } from 'ish-core/facades/shopping.facade'; | ||
|
||
import { CMSNavigationCategoryComponent } from './cms-navigation-category.component'; | ||
|
||
describe('Cms Navigation Category Component', () => { | ||
let component: CMSNavigationCategoryComponent; | ||
let fixture: ComponentFixture<CMSNavigationCategoryComponent>; | ||
let element: HTMLElement; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [CMSNavigationCategoryComponent], | ||
providers: [{ provide: ShoppingFacade, useFactory: () => instance(mock(ShoppingFacade)) }], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(CMSNavigationCategoryComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
src/app/shared/cms/components/cms-navigation-category/cms-navigation-category.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
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() pagelet: ContentPageletView; | ||
|
||
category$: Observable<NavigationCategory>; | ||
|
||
constructor(private shoppingFacade: ShoppingFacade) {} | ||
|
||
ngOnChanges(): void { | ||
if (this.pagelet?.hasParam('NavigationCategory')) { | ||
this.category$ = this.shoppingFacade.navigationCategory$( | ||
this.pagelet.stringParam('NavigationCategory'), | ||
this.pagelet.numberParam('SubNavigationDepth') | ||
); | ||
} | ||
} | ||
|
||
showSubMenu() { | ||
return this.pagelet?.hasParam('SubNavigationDepth') && this.pagelet.numberParam('SubNavigationDepth') === 0 | ||
? false | ||
: true; | ||
} | ||
|
||
subMenuShow(subMenu: HTMLElement) { | ||
subMenu.classList.add('hover'); | ||
} | ||
subMenuHide(subMenu: HTMLElement) { | ||
subMenu.classList.remove('hover'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters