Skip to content

Commit

Permalink
fix: missing display name for default sorting in product lists
Browse files Browse the repository at this point in the history
  • Loading branch information
shauke committed Aug 9, 2022
1 parent 8fe342b commit 5fb6ee9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 { ProductListToolbarComponent } from './product-list-toolbar.component';
Expand All @@ -13,7 +14,7 @@ describe('Product List Toolbar Component', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [MockComponent(FaIconComponent), ProductListToolbarComponent],
imports: [RouterTestingModule],
imports: [RouterTestingModule, TranslateModule.forRoot()],
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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 @@ -22,7 +23,7 @@ export class ProductListToolbarComponent implements OnChanges {

sortOptions: SelectOption[] = [];

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

ngOnChanges() {
this.sortOptions = this.mapSortableAttributesToSelectOptions(this.sortableAttributes);
Expand All @@ -44,7 +45,7 @@ export class ProductListToolbarComponent implements OnChanges {
.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: undefined });
options.unshift({ value: 'default', label: this.translate.instant('product.items.sorting.default.label') });
return options;
}

Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@
"product.instock.text": "Verfügbar",
"product.itemNumber.label": "Artikelnummer:",
"product.items.label": "{{0, plural, one{# Element} other{# Elemente}}}",
"product.items.sorting.default.label": "Standardsortierung",
"product.manufacturer_name.label": "Herstellername",
"product.out_of_stock.text": "Nicht verfügbar",
"product.price.listPriceFallback.text": "{{0}}",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@
"product.instock.text": "In Stock",
"product.itemNumber.label": "Product ID:",
"product.items.label": "{{0, plural, one{# list item} other{# list items}}}",
"product.items.sorting.default.label": "Default Sorting",
"product.manufacturer_name.label": "Manufacturer Name",
"product.out_of_stock.text": "Out of Stock",
"product.price.listPriceFallback.text": "{{0}}",
Expand Down
1 change: 1 addition & 0 deletions src/assets/i18n/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@
"product.instock.text": "En stock",
"product.itemNumber.label": "ID produit :",
"product.items.label": "{{0, plural, one{# article} other{# articles}}}",
"product.items.sorting.default.label": "Tri par défaut",
"product.manufacturer_name.label": "Nom du fabricant",
"product.out_of_stock.text": "Stock épuisé",
"product.price.listPriceFallback.text": "{{0}}",
Expand Down

0 comments on commit 5fb6ee9

Please sign in to comment.