Skip to content

Commit

Permalink
[Angular] Mograte to signals (sort-by.directive.ts)
Browse files Browse the repository at this point in the history
  • Loading branch information
qmonmert committed Dec 15, 2024
1 parent c0a81fe commit 4f81e08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -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);
});

Expand All @@ -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);
});

Expand All @@ -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);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

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

iconComponent = contentChild(FaIconComponent);

Expand All @@ -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;
Expand All @@ -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());
}
}
}

0 comments on commit 4f81e08

Please sign in to comment.