Skip to content

Commit

Permalink
feat: allow to add top navigation to iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
gion-andri committed Jun 3, 2024
1 parent 5647972 commit 85f2f69
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export class AppComponent implements OnInit {
if (params['showAddButton'] === 'true') {
this.iframeService.enableAddButton();
}
if (params['showTopNavigation'] === 'true') {
this.iframeService.enableTopNavigation();
}
}

if (params['view'] === 'cards') {
Expand Down
17 changes: 17 additions & 0 deletions src/app/components/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,20 @@
</ng-template>

</div>

<div class="hdr top-navigation" *ngIf="isInIframe && isTopNavigationVisible">
<div class="short-menu">
<ul>
<li>
<a [routerLink]="'/'" [class.active]="isLinkActive('/')">
{{ 'COMPONENTS.HEADER.SUB_MENU.EVENTS' | translate }}
</a>
</li>
<li>
<a [routerLink]="'/notices'" [class.active]="isLinkActive('/notices')">
{{ 'COMPONENTS.HEADER.SUB_MENU.NOTICE_BOARD' | translate }}
</a>
</li>
</ul>
</div>
</div>
6 changes: 6 additions & 0 deletions src/app/components/header/header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
height: 68px;
border-bottom: 1px solid #BBBFC2;

&.top-navigation {
flex-direction: column;
margin-bottom: 1px;
height: 75px;
}

a {
color: black;
text-decoration: none;
Expand Down
8 changes: 8 additions & 0 deletions src/app/components/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import { Router } from '@angular/router';
export class HeaderComponent implements OnInit, OnDestroy {
public isMenuOpen = false;
public isInIframe = false;
public isTopNavigationVisible = false;

private isIframeSubscription?: Subscription;
private isShowTopNavigationSubscription?: Subscription;

constructor(
private offcanvasService: NgbOffcanvas,
Expand All @@ -28,12 +30,18 @@ export class HeaderComponent implements OnInit, OnDestroy {
this.isIframeSubscription = this.iframeService.getIsIframeObservable().subscribe((value) => {
this.isInIframe = value;
});
this.isShowTopNavigationSubscription = this.iframeService.getShowTopNavigationObservable().subscribe((value) => {
this.isTopNavigationVisible = value;
});
}

ngOnDestroy() {
if (this.isIframeSubscription) {
this.isIframeSubscription.unsubscribe();
}
if (this.isShowTopNavigationSubscription) {
this.isShowTopNavigationSubscription.unsubscribe();
}
}

toggleMenu(content: TemplateRef<any>): void {
Expand Down
13 changes: 13 additions & 0 deletions src/app/services/iframe.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class IframeService {
private showSearch = new BehaviorSubject<boolean>(true);
private showViewSelection = new BehaviorSubject<boolean>(true);
private showAddButton = new BehaviorSubject<boolean>(false);
private showTopNavigation = new BehaviorSubject<boolean>(false);

constructor() {
}
Expand Down Expand Up @@ -61,4 +62,16 @@ export class IframeService {
isShowAddButtonValue(): boolean {
return this.showAddButton.value;
}

enableTopNavigation() {
this.showTopNavigation.next(true);
}

getShowTopNavigationObservable(): Observable<boolean> {
return this.showTopNavigation.asObservable();
}

isShowTopNavigationValue(): boolean {
return this.showTopNavigation.value;
}
}
1 change: 1 addition & 0 deletions src/app/shared/data/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class EventFilterUrlParams {
searchTerm?: string;
iframe?: boolean;
showAddButton?: boolean;
showTopNavigation?: boolean;
showSearch?: boolean;
showViewSelection?: boolean;
view?: string;
Expand Down
4 changes: 4 additions & 0 deletions src/app/shared/utils/url.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ export class UrlUtil {
url.showAddButton = true;
}

if (this.iframeService.isShowTopNavigationValue()) {
url.showTopNavigation = true;
}

if (!this.iframeService.isShowSearchValue()) {
url.showSearch = false;
}
Expand Down

0 comments on commit 85f2f69

Please sign in to comment.