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 1 month 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. /// 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 { MenuSection } from '@core/services/menu.models';
import { coerceBoolean } from '@shared/decorators/coercion'; import { coerceBoolean } from '@shared/decorators/coercion';
@ -25,7 +25,7 @@ import { coerceBoolean } from '@shared/decorators/coercion';
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false standalone: false
}) })
export class MenuLinkComponent implements OnInit { export class MenuLinkComponent {
@Input() section: MenuSection; @Input() section: MenuSection;
@ -36,7 +36,4 @@ export class MenuLinkComponent implements OnInit {
constructor() { constructor() {
} }
ngOnInit() {
}
} }

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

@ -37,7 +37,7 @@
[class.tb-toggled]="section.opened"></span> [class.tb-toggled]="section.opened"></span>
</a> </a>
<ul id="docs-menu-{{section.name | nospace}}" class="tb-menu-toggle-list" [style.height]="sectionHeight()"> <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> <li>
<tb-menu-link [section]="page"></tb-menu-link> <tb-menu-link [section]="page"></tb-menu-link>
</li> </li>
@ -49,7 +49,7 @@
<div class="tb-menu-toggle-header"> <div class="tb-menu-toggle-header">
<span>{{section.customTranslate ? (section.name | customTranslate) : (section.name | translate)}}</span> <span>{{section.customTranslate ? (section.name | customTranslate) : (section.name | translate)}}</span>
</div> </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'}" <a mat-button routerLinkActive="tb-active" [routerLinkActiveOptions]="{paths: 'subset', queryParams: 'ignored', matrixParams: 'ignored', fragment: 'ignored'}"
routerLink="{{page.path}}" (click)="menuPopover?.hide();"> routerLink="{{page.path}}" (click)="menuPopover?.hide();">
<span>{{page.customTranslate ? (page.name | customTranslate) : (page.name | translate)}}</span> <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. /// 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 { MenuSection } from '@core/services/menu.models';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
@ -29,7 +29,7 @@ import { coerceBoolean } from '@shared/decorators/coercion';
changeDetection: ChangeDetectionStrategy.OnPush, changeDetection: ChangeDetectionStrategy.OnPush,
standalone: false standalone: false
}) })
export class MenuToggleComponent implements OnInit { export class MenuToggleComponent {
@Input() section: MenuSection; @Input() section: MenuSection;
@ -41,9 +41,6 @@ export class MenuToggleComponent implements OnInit {
private store: Store<AppState>) { private store: Store<AppState>) {
} }
ngOnInit() {
}
sectionHeight(): string { sectionHeight(): string {
if (this.section.opened && !this.collapsed) { if (this.section.opened && !this.collapsed) {
return this.section.pages.length * 40 + 'px'; return this.section.pages.length * 40 + 'px';
@ -72,8 +69,4 @@ export class MenuToggleComponent implements OnInit {
return false; 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"> <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> <li>
@switch (section.type === 'link') { @switch (section.type === 'link') {
@case (true) { @case (true) {

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

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

Loading…
Cancel
Save