diff --git a/devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/property-tab/property-view/property-view-body.component.html b/devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/property-tab/property-view/property-view-body.component.html index bc3b54b1653..7dd4a51d3a5 100644 --- a/devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/property-tab/property-view/property-view-body.component.html +++ b/devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/property-tab/property-view/property-view-body.component.html @@ -22,17 +22,16 @@ } - @for (index of categoryOrder; track $index) { + @for (panel of panels(); track $index) {
- @let panel = panels()[index]; - @if (!panel.hidden) { + @if (panel.controls().dataSource.data.length > 0) { {{ panel.title }} diff --git a/devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/property-tab/property-view/property-view-body.component.ts b/devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/property-tab/property-view/property-view-body.component.ts index 087f6ddbcc9..e88579f3351 100644 --- a/devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/property-tab/property-view/property-view-body.component.ts +++ b/devtools/projects/ng-devtools/src/lib/devtools-tabs/directive-explorer/property-tab/property-view/property-view-body.component.ts @@ -7,7 +7,7 @@ */ import {CdkDragDrop, moveItemInArray, CdkDropList, CdkDrag} from '@angular/cdk/drag-drop'; -import {Component, computed, forwardRef, input, output} from '@angular/core'; +import {Component, computed, forwardRef, input, output, signal} from '@angular/core'; import {DirectivePosition, SerializedInjectedService} from 'protocol'; import { @@ -44,37 +44,23 @@ export class PropertyViewBodyComponent { readonly inspect = output<{node: FlatNode; directivePosition: DirectivePosition}>(); - categoryOrder = [0, 1, 2]; - - readonly panels = computed< + protected readonly panels = signal([ { - title: string; - hidden: boolean; - controls: DirectiveTreeData; - class: string; - }[] - >(() => { - return [ - { - title: 'Inputs', - hidden: this.directiveInputControls().dataSource.data.length === 0, - controls: this.directiveInputControls(), - class: 'cy-inputs', - }, - { - title: 'Outputs', - hidden: this.directiveOutputControls().dataSource.data.length === 0, - controls: this.directiveOutputControls(), - class: 'cy-outputs', - }, - { - title: 'Properties', - hidden: this.directiveStateControls().dataSource.data.length === 0, - controls: this.directiveStateControls(), - class: 'cy-properties', - }, - ]; - }); + title: 'Inputs', + controls: () => this.directiveInputControls(), + class: 'cy-inputs', + }, + { + title: 'Outputs', + controls: () => this.directiveOutputControls(), + class: 'cy-outputs', + }, + { + title: 'Properties', + controls: () => this.directiveStateControls(), + class: 'cy-properties', + }, + ]); readonly controlsLoaded = computed(() => { return ( @@ -89,7 +75,9 @@ export class PropertyViewBodyComponent { } drop(event: CdkDragDrop): void { - moveItemInArray(this.categoryOrder, event.previousIndex, event.currentIndex); + const panels = this.panels(); + moveItemInArray(panels, event.previousIndex, event.currentIndex); + this.panels.set(Array.from(panels)); // Clone array for immutable update. } handleInspect(node: FlatNode): void {