Skip to content

Commit

Permalink
fix: replace translate.instant in product-list-toolbar.component (#1482)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi authored and shauke committed Sep 5, 2023
1 parent 8d3f6a1 commit 191788a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
name="SortingAttribute"
(change)="changeSortBy($event.target)"
>
<option value="default" [selected]="sortBy === 'default'">
{{ 'product.items.sorting.default.label' | translate }}
</option>
<option *ngFor="let o of sortOptions" [value]="o.value" [selected]="o.value === sortBy">{{ o.label }}</option>
</select>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { FaIconComponent } from '@fortawesome/angular-fontawesome';
import { TranslateModule } from '@ngx-translate/core';
import { MockComponent } from 'ng-mocks';
import { TranslatePipe } from '@ngx-translate/core';
import { MockComponent, MockPipe } from 'ng-mocks';

import { ProductListToolbarComponent } from './product-list-toolbar.component';

Expand All @@ -13,8 +13,8 @@ describe('Product List Toolbar Component', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [MockComponent(FaIconComponent), ProductListToolbarComponent],
imports: [RouterTestingModule, TranslateModule.forRoot()],
declarations: [MockComponent(FaIconComponent), MockPipe(TranslatePipe), ProductListToolbarComponent],
imports: [RouterTestingModule],
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';

import { SortableAttributesType } from 'ish-core/models/product-listing/product-listing.model';
import { SelectOption } from 'ish-core/models/select-option/select-option.model';
Expand All @@ -23,7 +22,7 @@ export class ProductListToolbarComponent implements OnChanges {

sortOptions: SelectOption[] = [];

constructor(private router: Router, private activatedRoute: ActivatedRoute, private translate: TranslateService) {}
constructor(private router: Router, private activatedRoute: ActivatedRoute) {}

ngOnChanges() {
this.sortOptions = this.mapSortableAttributesToSelectOptions(this.sortableAttributes);
Expand All @@ -41,12 +40,10 @@ export class ProductListToolbarComponent implements OnChanges {
}

private mapSortableAttributesToSelectOptions(sortableAttributes: SortableAttributesType[] = []): SelectOption[] {
const options = sortableAttributes
return sortableAttributes
.filter(x => !!x)
.map(sk => ({ value: sk.name, label: sk.displayName || sk.name }))
.sort((a, b) => a.label.localeCompare(b.label));
options.unshift({ value: 'default', label: this.translate.instant('product.items.sorting.default.label') });
return options;
}

get listView() {
Expand Down

0 comments on commit 191788a

Please sign in to comment.