diff --git a/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.html b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.html index 831bb1b55..7292ba8ea 100644 --- a/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.html +++ b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.html @@ -1,10 +1,10 @@ -@if (active) { +@if (active()) { diff --git a/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.spec.ts b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.spec.ts index 2f45dd902..50cb5c3bb 100644 --- a/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.spec.ts +++ b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.spec.ts @@ -21,20 +21,20 @@ describe('ClearableBadgeComponent', () => { }) it('should support selected', () => { - component.selected = true - expect(component.active).toBeTruthy() + fixture.componentRef.setInput('selected', true) + expect(component.active()).toBeTruthy() }) it('should support numbered', () => { - component.number = 3 + fixture.componentRef.setInput('number', 3) fixture.detectChanges() - expect(component.active).toBeTruthy() + expect(component.active()).toBeTruthy() expect((fixture.nativeElement as HTMLDivElement).textContent).toContain('3') }) it('should support selected', () => { let clearedResult - component.selected = true + fixture.componentRef.setInput('selected', true) fixture.detectChanges() component.cleared.subscribe((clear) => { clearedResult = clear diff --git a/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.ts b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.ts index 1cdce5679..0ee366110 100644 --- a/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.ts +++ b/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, Output, signal } from '@angular/core' +import { Component, computed, EventEmitter, input, Output } from '@angular/core' import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons' @Component({ @@ -8,37 +8,15 @@ import { NgxBootstrapIconsModule } from 'ngx-bootstrap-icons' imports: [NgxBootstrapIconsModule], }) export class ClearableBadgeComponent { - private numberSignal = signal(undefined) - private selectedSignal = signal(undefined) - - @Input() - get number(): number { - return this.numberSignal() - } - - set number(number: number) { - this.numberSignal.set(number) - } - - @Input() - get selected(): boolean { - return this.selectedSignal() - } - - set selected(selected: boolean) { - this.selectedSignal.set(selected) - } + readonly number = input(undefined) + readonly selected = input(undefined) @Output() cleared: EventEmitter = new EventEmitter() - get active(): boolean { - return this.selected || this.number > -1 - } + readonly active = computed(() => this.selected() || this.number() > -1) - get isNumbered(): boolean { - return this.number > -1 - } + readonly isNumbered = computed(() => this.number() > -1) onClick(event: PointerEvent) { this.cleared.emit(true) diff --git a/src-ui/src/app/components/common/hotkey-dialog/hotkey-dialog.component.html b/src-ui/src/app/components/common/hotkey-dialog/hotkey-dialog.component.html index c98a96ee0..c6aea0fb2 100644 --- a/src-ui/src/app/components/common/hotkey-dialog/hotkey-dialog.component.html +++ b/src-ui/src/app/components/common/hotkey-dialog/hotkey-dialog.component.html @@ -1,11 +1,11 @@