From 4f81e0833a76509c85fa1d9db0714739fa59ab1a Mon Sep 17 00:00:00 2001 From: Quentin Date: Sun, 15 Dec 2024 20:59:37 +0100 Subject: [PATCH] [Angular] Mograte to signals (sort-by.directive.ts) --- .../webapp/app/shared/sort/sort-by.directive.spec.ts.ejs | 8 ++++---- .../main/webapp/app/shared/sort/sort-by.directive.ts.ejs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.spec.ts.ejs b/generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.spec.ts.ejs index c0d4fb08e194..f1c6bdba7bf0 100644 --- a/generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.spec.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.spec.ts.ejs @@ -77,7 +77,7 @@ describe('Directive: SortByDirective', () => { fixture.detectChanges(); // THEN - expect(sortByDirective.<%= jhiPrefix %>SortBy).toEqual('name'); + expect(sortByDirective.<%= jhiPrefix %>SortBy()).toEqual('name'); expect(sortByDirective.iconComponent()?.icon).toEqual(faSort.iconName); }); @@ -90,7 +90,7 @@ describe('Directive: SortByDirective', () => { fixture.detectChanges(); // THEN - expect(sortByDirective.<%= jhiPrefix %>SortBy).toEqual('name'); + expect(sortByDirective.<%= jhiPrefix %>SortBy()).toEqual('name'); expect(sortByDirective.iconComponent()?.icon).toEqual(faSortUp.iconName); }); @@ -103,7 +103,7 @@ describe('Directive: SortByDirective', () => { fixture.detectChanges(); // THEN - expect(sortByDirective.<%= jhiPrefix %>SortBy).toEqual('name'); + expect(sortByDirective.<%= jhiPrefix %>SortBy()).toEqual('name'); expect(sortByDirective.iconComponent()?.icon).toEqual(faSortDown.iconName); }); @@ -116,7 +116,7 @@ describe('Directive: SortByDirective', () => { fixture.detectChanges(); // THEN - expect(sortByDirective.<%= jhiPrefix %>SortBy).toEqual('name'); + expect(sortByDirective.<%= jhiPrefix %>SortBy()).toEqual('name'); expect(sortByDirective.iconComponent()?.icon).toEqual(faSort.iconName); }); diff --git a/generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.ts.ejs b/generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.ts.ejs index baf1c61bcadd..e08a51311046 100644 --- a/generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.ts.ejs +++ b/generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.ts.ejs @@ -16,7 +16,7 @@ See the License for the specific language governing permissions and limitations under the License. -%> -import { Directive, HostListener, Input, contentChild, effect, inject } from '@angular/core'; +import { Directive, HostListener, contentChild, effect, inject, input } from '@angular/core'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { faSort, faSortDown, faSortUp, IconDefinition } from '@fortawesome/free-solid-svg-icons'; @@ -26,7 +26,7 @@ import { SortDirective } from './sort.directive'; selector: '[<%= jhiPrefix %>SortBy]', }) export class SortByDirective { - @Input() <%= jhiPrefix %>SortBy!: string; + readonly <%= jhiPrefix %>SortBy = input.required(); iconComponent = contentChild(FaIconComponent); @@ -41,7 +41,7 @@ export class SortByDirective { if (this.iconComponent()) { let icon: IconDefinition = this.sortIcon; const { predicate, order } = this.sort.sortState(); - if (predicate === this.<%= jhiPrefix %>SortBy && order !== undefined) { + if (predicate === this.<%= jhiPrefix %>SortBy() && order !== undefined) { icon = order === 'asc' ? this.sortAscIcon : this.sortDescIcon; } this.iconComponent()!.icon = icon.iconName; @@ -53,7 +53,7 @@ export class SortByDirective { @HostListener('click') onClick(): void { if (this.iconComponent()) { - this.sort.sort(this.<%= jhiPrefix %>SortBy); + this.sort.sort(this.<%= jhiPrefix %>SortBy()); } } }