Skip to content

Commit

Permalink
Remove sort option from dhEnumToWattDropdownOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ManBearTM committed Oct 21, 2024
1 parent 9264665 commit 846554b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,7 @@ export class DhDelegationCreateModalComponent extends WattTypedModal<DhActorExte
}

private getDelegatedProcesses() {
return dhEnumToWattDropdownOptions(
DelegatedProcess,
null,
this.getDelegatedProcessesToExclude()
);
return dhEnumToWattDropdownOptions(DelegatedProcess, this.getDelegatedProcessesToExclude());
}

private getGridAreaOptions(): Observable<WattDropdownOptions> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class DhMarketParticipantGridAreaOverviewComponent {
isLoading = input<boolean>(false);
hasError = input<boolean>(false);

gridAreaTypeOptions = dhEnumToWattDropdownOptions(GridAreaType, null, [GridAreaType.NotSet]);
gridAreaTypeOptions = dhEnumToWattDropdownOptions(GridAreaType, [GridAreaType.NotSet]);

selectedGridAreaType = signal<GridAreaType | null>(null);

Expand Down
15 changes: 1 addition & 14 deletions libs/dh/shared/ui-util/src/lib/dh-enum-to-dropdown-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,11 @@
*/
import { WattDropdownOptions } from '@energinet-datahub/watt/dropdown';

export function dhEnumToWattDropdownOptions<T extends object>(
enumObj: T,
sort: 'asc' | 'desc' | null = null,
exclude?: string[]
) {
export function dhEnumToWattDropdownOptions<T extends object>(enumObj: T, exclude?: string[]) {
return Object.keys(enumObj)
.map((key) => ({
displayValue: key,
value: Object.values(enumObj)[Object.keys(enumObj).indexOf(key)],
}))
.sort((a, b) => {
if (sort === null) return 0;

if (sort === 'asc') {
return a.displayValue.localeCompare(b.displayValue);
} else {
return b.displayValue.localeCompare(a.displayValue);
}
})
.filter(({ value }) => !exclude?.includes(value)) as WattDropdownOptions;
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export class DhCalculationsFiltersComponent implements OnInit {
calculationTypesOptions = dhEnumToWattDropdownOptions(CalculationType);
executionTypeOptions = dhEnumToWattDropdownOptions(CalculationExecutionType);
gridAreaOptions$ = getGridAreaOptions();
executionStateOptions = dhEnumToWattDropdownOptions(CalculationOrchestrationState, null, [
executionStateOptions = dhEnumToWattDropdownOptions(CalculationOrchestrationState, [
CalculationOrchestrationState.ActorMessagesEnqueued,
]);

Expand Down

0 comments on commit 846554b

Please sign in to comment.