Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dh): add input to sort dropdown entries by translation key order #3649

Merged
merged 22 commits into from
Oct 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ac94890
Add input to sort dropdown entries by translation key order
ManBearTM Oct 21, 2024
017ccf8
Fix ordering of translation for marketRoles
ManBearTM Oct 21, 2024
f9a96d9
Align translation with enum
ManBearTM Oct 21, 2024
047c75f
Revert "Align translation with enum"
ManBearTM Oct 21, 2024
4603c08
Revert "Fix ordering of translation for marketRoles"
ManBearTM Oct 21, 2024
0da5fa2
Make translation sort order the default behavior
ManBearTM Oct 21, 2024
8a9a484
Fix translation order to match enum for calculationType
ManBearTM Oct 21, 2024
6fef9aa
Align requestCalculationDataType translation with enum
ManBearTM Oct 21, 2024
39be9a0
Use better ordering from translation file
ManBearTM Oct 21, 2024
fd5167a
Move sortDirection to watt-dropdown instead
ManBearTM Oct 21, 2024
450c0c0
Remove asc sort from CalculationTypes to align with other dropdowns
ManBearTM Oct 21, 2024
1c00c75
Remove unneeded asc sort of enum
ManBearTM Oct 21, 2024
52909c9
Remove unneeded asc order of EicFunction
ManBearTM Oct 21, 2024
27312fb
Remove asc sort order from statusOptions
ManBearTM Oct 21, 2024
d7c3b07
Remove asc from delegatedProcesses option
ManBearTM Oct 21, 2024
aa73d59
Align status translation with enum (sorted by order of operation)
ManBearTM Oct 21, 2024
be42d89
Remove asc from ActorDelegationStatus
ManBearTM Oct 21, 2024
9577125
Move asc sort to template for gridAreas types
ManBearTM Oct 21, 2024
9264665
Remove asc from CalculationType dropdown in request calculation
ManBearTM Oct 21, 2024
846554b
Remove sort option from dhEnumToWattDropdownOptions
ManBearTM Oct 21, 2024
3371396
Remove more null args
ManBearTM Oct 21, 2024
06feeab
Merge branch 'main' into feat/dropdown-translator-sort-by-translation…
ManBearTM Oct 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export class DhDropdownTranslatorDirective implements OnInit {

translateKey = input.required<string>();

sortByTranslationOrder = input<boolean>(false);

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

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

if (!keys) return;

Expand All @@ -47,6 +50,12 @@ export class DhDropdownTranslatorDirective implements OnInit {
displayValue: this.translateDisplayValue(keys[option.value as keyof typeof keys]),
}));

// 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));
}

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