Browse Source

chore(menu): drop empty ngOnInit hooks and trackByMenuSection/Pages helpers

@for now uses the `track section.id` / `track page.id` syntax directly, so the dedicated trackBy methods are no longer referenced. Remove them along with the empty OnInit lifecycle hooks they used to live next to.
pull/15888/head
Igor Kulikov 4 weeks ago
parent
commit
cc2db891f8
  1. 7
      ui-ngx/src/app/modules/home/menu/menu-link.component.ts
  2. 4
      ui-ngx/src/app/modules/home/menu/menu-toggle.component.html
  3. 11
      ui-ngx/src/app/modules/home/menu/menu-toggle.component.ts
  4. 2
      ui-ngx/src/app/modules/home/menu/side-menu.component.html
  5. 12
      ui-ngx/src/app/modules/home/menu/side-menu.component.ts

7
ui-ngx/src/app/modules/home/menu/menu-link.component.ts

@ -14,7 +14,7 @@
/// limitations under the License.
///
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { MenuSection } from '@core/services/menu.models';
import { coerceBoolean } from '@shared/decorators/coercion';
@ -25,7 +25,7 @@ import { coerceBoolean } from '@shared/decorators/coercion';
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false
})
export class MenuLinkComponent implements OnInit {
export class MenuLinkComponent {
@Input() section: MenuSection;
@ -36,7 +36,4 @@ export class MenuLinkComponent implements OnInit {
constructor() {
}
ngOnInit() {
}
}

4
ui-ngx/src/app/modules/home/menu/menu-toggle.component.html

@ -37,7 +37,7 @@
[class.tb-toggled]="section.opened"></span>
</a>
<ul id="docs-menu-{{section.name | nospace}}" class="tb-menu-toggle-list" [style.height]="sectionHeight()">
@for (page of section.pages; track trackBySectionPages($index, page)) {
@for (page of section.pages; track page.id) {
<li>
<tb-menu-link [section]="page"></tb-menu-link>
</li>
@ -49,7 +49,7 @@
<div class="tb-menu-toggle-header">
<span>{{section.customTranslate ? (section.name | customTranslate) : (section.name | translate)}}</span>
</div>
@for (page of section.pages; track trackBySectionPages($index, page)) {
@for (page of section.pages; track page.id) {
<a mat-button routerLinkActive="tb-active" [routerLinkActiveOptions]="{paths: 'subset', queryParams: 'ignored', matrixParams: 'ignored', fragment: 'ignored'}"
routerLink="{{page.path}}" (click)="menuPopover?.hide();">
<span>{{page.customTranslate ? (page.name | customTranslate) : (page.name | translate)}}</span>

11
ui-ngx/src/app/modules/home/menu/menu-toggle.component.ts

@ -14,7 +14,7 @@
/// limitations under the License.
///
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { MenuSection } from '@core/services/menu.models';
import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
@ -29,7 +29,7 @@ import { coerceBoolean } from '@shared/decorators/coercion';
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false
})
export class MenuToggleComponent implements OnInit {
export class MenuToggleComponent {
@Input() section: MenuSection;
@ -41,9 +41,6 @@ export class MenuToggleComponent implements OnInit {
private store: Store<AppState>) {
}
ngOnInit() {
}
sectionHeight(): string {
if (this.section.opened && !this.collapsed) {
return this.section.pages.length * 40 + 'px';
@ -72,8 +69,4 @@ export class MenuToggleComponent implements OnInit {
return false;
}
}
trackBySectionPages(index: number, section: MenuSection){
return section.id;
}
}

2
ui-ngx/src/app/modules/home/menu/side-menu.component.html

@ -16,7 +16,7 @@
-->
<ul class="tb-side-menu flex flex-col items-stretch justify-start" [class.tb-collapsed]="collapsed">
@for (section of menuSections$ | async; track trackByMenuSection($index, section)) {
@for (section of menuSections$ | async; track section.id) {
<li>
@switch (section.type === 'link') {
@case (true) {

12
ui-ngx/src/app/modules/home/menu/side-menu.component.ts

@ -14,9 +14,8 @@
/// limitations under the License.
///
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { MenuService } from '@core/services/menu.service';
import { MenuSection } from '@core/services/menu.models';
import { coerceBoolean } from '@shared/decorators/coercion';
@Component({
@ -26,7 +25,7 @@ import { coerceBoolean } from '@shared/decorators/coercion';
changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false
})
export class SideMenuComponent implements OnInit {
export class SideMenuComponent {
@Input()
@coerceBoolean()
@ -37,11 +36,4 @@ export class SideMenuComponent implements OnInit {
constructor(private menuService: MenuService) {
}
trackByMenuSection(index: number, section: MenuSection){
return section.id;
}
ngOnInit() {
}
}

Loading…
Cancel
Save