Skip to content

Commit aa9f882

Browse files
committed
feat(menu): add grouped source links for client, server, and stack repositories
1 parent 03e9e1f commit aa9f882

3 files changed

Lines changed: 47 additions & 4 deletions

File tree

src/app/core/layout/component/app-menu/app-menu.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ export class AppMenuComponent {
8585
label: 'About',
8686
items: [
8787
{ label: 'Documentation', icon: 'pi pi-fw pi-book', routerLink: ['/docs'] },
88-
{ label: 'View Source', icon: 'pi pi-fw pi-github', url: 'https://github.com/Diogo-Ferraz/TaskManagementClient', target: '_blank' }
88+
{
89+
label: 'Source Code',
90+
icon: 'pi pi-fw pi-github',
91+
items: [
92+
{ label: 'Client Source', icon: 'pi pi-fw pi-desktop', url: 'https://github.com/Diogo-Ferraz/TaskManagementClient', target: '_blank' },
93+
{ label: 'Server Source', icon: 'pi pi-fw pi-server', url: 'https://github.com/Diogo-Ferraz/TaskManagementServer', target: '_blank' },
94+
{ label: 'Stack Source', icon: 'pi pi-fw pi-sitemap', url: 'https://github.com/Diogo-Ferraz/TaskManagementStack', target: '_blank' }
95+
]
96+
}
8997
]
9098
}
9199
];

src/app/core/layout/component/app-menuitem/app-menuitem.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ng-container>
22
<div *ngIf="root && item.visible !== false" class="layout-menuitem-root-text">{{ item.label }}</div>
3-
<a *ngIf="(!item.routerLink || item.items) && item.visible !== false" [attr.href]="item.url" [ngClass]="item.styleClass" [attr.target]="item.target" tabindex="0" pRipple>
3+
<a *ngIf="(!item.routerLink || item.items) && item.visible !== false" [attr.href]="item.url" [ngClass]="item.styleClass" [attr.target]="item.target" tabindex="0" pRipple (click)="onItemClick($event)">
44
<i [ngClass]="item.icon" class="layout-menuitem-icon"></i>
55
<span class="layout-menuitem-text">{{ item.label }}</span>
66
<i class="pi pi-fw pi-angle-down layout-submenu-toggler" *ngIf="item.items"></i>
@@ -32,4 +32,4 @@
3232
<li app-menuitem [item]="child" [index]="i" [parentKey]="key" [class]="child['badgeClass']" [root]="false"></li>
3333
</ng-template>
3434
</ul>
35-
</ng-container>
35+
</ng-container>

src/app/core/layout/component/app-menuitem/app-menuitem.component.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { animate, state, style, transition, trigger } from '@angular/animations';
22
import { CommonModule } from '@angular/common';
3-
import { Component, HostBinding, Input, OnInit, ViewEncapsulation } from '@angular/core';
3+
import { Component, ElementRef, HostBinding, Input, OnInit, inject, ViewEncapsulation } from '@angular/core';
44
import { RouterModule } from '@angular/router';
55
import { MenuItem } from 'primeng/api';
66
import { RippleModule } from 'primeng/ripple';
@@ -31,6 +31,8 @@ import { RippleModule } from 'primeng/ripple';
3131
]
3232
})
3333
export class AppMenuitemComponent implements OnInit {
34+
private readonly elementRef = inject(ElementRef<HTMLElement>);
35+
3436
@Input() item!: MenuItem;
3537

3638
@Input() index!: number;
@@ -47,6 +49,19 @@ export class AppMenuitemComponent implements OnInit {
4749

4850
}
4951

52+
onItemClick(event: MouseEvent): void {
53+
if (!this.item.items || this.item.items.length === 0) {
54+
return;
55+
}
56+
57+
event.preventDefault();
58+
this.active = !this.active;
59+
60+
if (this.active) {
61+
this.scrollExpandedChildrenIntoView();
62+
}
63+
}
64+
5065
@HostBinding('class.active-menuitem')
5166
get activeClass() {
5267
return this.active && !this.root;
@@ -55,4 +70,24 @@ export class AppMenuitemComponent implements OnInit {
5570
get submenuAnimation() {
5671
return this.root ? 'expanded' : this.active ? 'expanded' : 'collapsed';
5772
}
73+
74+
private scrollExpandedChildrenIntoView(): void {
75+
window.setTimeout(() => {
76+
const lastChild = this.elementRef.nativeElement.querySelector('ul > li:last-child');
77+
if (lastChild instanceof HTMLElement) {
78+
lastChild.scrollIntoView({
79+
behavior: 'smooth',
80+
block: 'nearest',
81+
inline: 'nearest'
82+
});
83+
return;
84+
}
85+
86+
this.elementRef.nativeElement.scrollIntoView({
87+
behavior: 'smooth',
88+
block: 'nearest',
89+
inline: 'nearest'
90+
});
91+
}, 420);
92+
}
5893
}

0 commit comments

Comments
 (0)