From 191788a377089e1d8916f8dd92e17b1db2a026fa Mon Sep 17 00:00:00 2001 From: Danilo Hoffmann Date: Tue, 5 Sep 2023 19:55:39 +0200 Subject: [PATCH] fix: replace translate.instant in product-list-toolbar.component (#1482) --- .../product-list-toolbar.component.html | 3 +++ .../product-list-toolbar.component.spec.ts | 8 ++++---- .../product-list-toolbar.component.ts | 7 ++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.html b/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.html index b1b188666c..6c5032bb7a 100644 --- a/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.html +++ b/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.html @@ -58,6 +58,9 @@ name="SortingAttribute" (change)="changeSortBy($event.target)" > + diff --git a/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.spec.ts b/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.spec.ts index 54c06d6662..1935248112 100644 --- a/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.spec.ts +++ b/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.spec.ts @@ -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'; @@ -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(); }); diff --git a/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.ts b/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.ts index 3aee8c4bc6..bef29a1068 100644 --- a/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.ts +++ b/src/app/shared/components/product/product-list-toolbar/product-list-toolbar.component.ts @@ -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'; @@ -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); @@ -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() {