Skip to content

Commit 4d5f914

Browse files
authored
[Angular] Migrate to signals (sort-by.directive.ts) (#28197)
1 parent c0a81fe commit 4d5f914

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.spec.ts.ejs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('Directive: SortByDirective', () => {
7777
fixture.detectChanges();
7878

7979
// THEN
80-
expect(sortByDirective.<%= jhiPrefix %>SortBy).toEqual('name');
80+
expect(sortByDirective.<%= jhiPrefix %>SortBy()).toEqual('name');
8181
expect(sortByDirective.iconComponent()?.icon).toEqual(faSort.iconName);
8282
});
8383

@@ -90,7 +90,7 @@ describe('Directive: SortByDirective', () => {
9090
fixture.detectChanges();
9191

9292
// THEN
93-
expect(sortByDirective.<%= jhiPrefix %>SortBy).toEqual('name');
93+
expect(sortByDirective.<%= jhiPrefix %>SortBy()).toEqual('name');
9494
expect(sortByDirective.iconComponent()?.icon).toEqual(faSortUp.iconName);
9595
});
9696

@@ -103,7 +103,7 @@ describe('Directive: SortByDirective', () => {
103103
fixture.detectChanges();
104104

105105
// THEN
106-
expect(sortByDirective.<%= jhiPrefix %>SortBy).toEqual('name');
106+
expect(sortByDirective.<%= jhiPrefix %>SortBy()).toEqual('name');
107107
expect(sortByDirective.iconComponent()?.icon).toEqual(faSortDown.iconName);
108108
});
109109

@@ -116,7 +116,7 @@ describe('Directive: SortByDirective', () => {
116116
fixture.detectChanges();
117117

118118
// THEN
119-
expect(sortByDirective.<%= jhiPrefix %>SortBy).toEqual('name');
119+
expect(sortByDirective.<%= jhiPrefix %>SortBy()).toEqual('name');
120120
expect(sortByDirective.iconComponent()?.icon).toEqual(faSort.iconName);
121121
});
122122

generators/angular/templates/src/main/webapp/app/shared/sort/sort-by.directive.ts.ejs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
See the License for the specific language governing permissions and
1717
limitations under the License.
1818
-%>
19-
import { Directive, HostListener, Input, contentChild, effect, inject } from '@angular/core';
19+
import { Directive, HostListener, contentChild, effect, inject, input } from '@angular/core';
2020
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
2121
import { faSort, faSortDown, faSortUp, IconDefinition } from '@fortawesome/free-solid-svg-icons';
2222

@@ -26,7 +26,7 @@ import { SortDirective } from './sort.directive';
2626
selector: '[<%= jhiPrefix %>SortBy]',
2727
})
2828
export class SortByDirective {
29-
@Input() <%= jhiPrefix %>SortBy!: string;
29+
readonly <%= jhiPrefix %>SortBy = input.required<string>();
3030

3131
iconComponent = contentChild(FaIconComponent);
3232

@@ -41,7 +41,7 @@ export class SortByDirective {
4141
if (this.iconComponent()) {
4242
let icon: IconDefinition = this.sortIcon;
4343
const { predicate, order } = this.sort.sortState();
44-
if (predicate === this.<%= jhiPrefix %>SortBy && order !== undefined) {
44+
if (predicate === this.<%= jhiPrefix %>SortBy() && order !== undefined) {
4545
icon = order === 'asc' ? this.sortAscIcon : this.sortDescIcon;
4646
}
4747
this.iconComponent()!.icon = icon.iconName;
@@ -53,7 +53,7 @@ export class SortByDirective {
5353
@HostListener('click')
5454
onClick(): void {
5555
if (this.iconComponent()) {
56-
this.sort.sort(this.<%= jhiPrefix %>SortBy);
56+
this.sort.sort(this.<%= jhiPrefix %>SortBy());
5757
}
5858
}
5959
}

0 commit comments

Comments
 (0)