Skip to content

Commit

Permalink
Make translation sort order the default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ManBearTM committed Oct 21, 2024
1 parent 4603c08 commit 0da5fa2
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ export class DhDropdownTranslatorDirective implements OnInit {

translateKey = input.required<string>();

sortByTranslationOrder = input<boolean>(false);

translation = signal<object | undefined>(undefined);

options = input<WattDropdownOptions>([]);
Expand All @@ -41,7 +39,6 @@ export class DhDropdownTranslatorDirective implements OnInit {
effect(() => {
const options = this.options();
const keys = this.translation();
const sortByTranslationOrder = this.sortByTranslationOrder();

if (!keys) return;

Expand All @@ -51,10 +48,8 @@ export class DhDropdownTranslatorDirective implements OnInit {
}));

// Sort translatedOptions based on the order of the translation keys
if (sortByTranslationOrder) {
const keyOrder = Object.keys(keys);
translatedOptions.sort((a, b) => keyOrder.indexOf(a.value) - keyOrder.indexOf(b.value));
}
const keyOrder = Object.keys(keys);
translatedOptions.sort((a, b) => keyOrder.indexOf(a.value) - keyOrder.indexOf(b.value));

this.host.options = this.host.sortDirection
? this.host.sortOptions(translatedOptions)
Expand Down

0 comments on commit 0da5fa2

Please sign in to comment.