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
Show file tree
Hide file tree
Changes from all commits
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 @@ -94,8 +94,7 @@ export class DhMeteringGridAreaImbalanceFiltersComponent implements OnInit {

gridAreaOptions$ = getGridAreaOptions();
valuestoIncludeOptions: WattDropdownOptions = dhEnumToWattDropdownOptions(
MeteringGridImbalanceValuesToInclude,
'asc'
MeteringGridImbalanceValuesToInclude
);

formGroup!: FormGroup<Filters>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
[chipMode]="true"
[options]="messageTypeOptions"
[placeholder]="t('messageType')"
sortDirection="asc"
dhDropdownTranslator
translateKey="eSett.outgoingMessages.shared.messageType"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ export class DhOutgoingMessagesFiltersComponent implements OnInit {
filter = output<DhOutgoingMessagesFilters>();
formReset = output<void>();

calculationTypeOptions = dhEnumToWattDropdownOptions(ExchangeEventCalculationType, 'asc');
messageTypeOptions = dhEnumToWattDropdownOptions(EsettTimeSeriesType, 'asc');
calculationTypeOptions = dhEnumToWattDropdownOptions(ExchangeEventCalculationType);
messageTypeOptions = dhEnumToWattDropdownOptions(EsettTimeSeriesType);
gridAreaOptions$ = getGridAreaOptions();
energySupplierOptions$ = getActorOptions([EicFunction.EnergySupplier]);
documentStatusOptions = dhEnumToWattDropdownOptions(DocumentStatus, 'asc');
documentStatusOptions = dhEnumToWattDropdownOptions(DocumentStatus);

formGroup!: FormGroup<Filters>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@
},
"statusPlaceholder": "Status",
"status": {
"ACTIVE": "Aktiv",
"AWAITING": "Afventer",
"ACTIVE": "Aktiv",
"EXPIRED": "Stoppet",
"CANCELLED": "Annulleret"
}
Expand Down Expand Up @@ -512,8 +512,8 @@
"E17Consumption": "Forbrug"
},
"statusOptions": {
"ACTIVE": "Aktiv",
"AWAITING": "Afventer",
"ACTIVE": "Aktiv",
"EXPIRED": "Udløbet",
"SOON_TO_EXPIRE": "Udløber snart"
},
Expand Down Expand Up @@ -822,9 +822,9 @@
"RECEIVED": "Modtaget",
"AWAITING_DISPATCH": "Afventer afsendelse",
"AWAITING_REPLY": "Afventer svar fra eSett",
"BIZ_TALK_ACCEPTED": "Afventer svar fra ECP",
"ACCEPTED": "Accepteret",
"REJECTED": "Afvist",
"BIZ_TALK_ACCEPTED": "Afventer svar fra ECP"
"REJECTED": "Afvist"
}
},
"filters": {
Expand Down Expand Up @@ -1088,8 +1088,8 @@
},
"calculationTypes": {
"BALANCE_FIXING": "{{wholesale.shared.BALANCE_FIXING}}",
"WHOLESALE_FIXING": "{{wholesale.shared.WHOLESALE_FIXING}}",
"AGGREGATION": "{{wholesale.shared.AGGREGATION}}",
"WHOLESALE_FIXING": "{{wholesale.shared.WHOLESALE_FIXING}}",
"FIRST_CORRECTION_SETTLEMENT": "{{wholesale.shared.FIRST_CORRECTION_SETTLEMENT}}",
"SECOND_CORRECTION_SETTLEMENT": "{{wholesale.shared.SECOND_CORRECTION_SETTLEMENT}}",
"THIRD_CORRECTION_SETTLEMENT": "{{wholesale.shared.THIRD_CORRECTION_SETTLEMENT}}",
Expand Down Expand Up @@ -1202,12 +1202,12 @@
"MONTHLY_SUBSCRIPTION": "Abonnement månedssum",
"MONTHLY_FEE": "Gebyr månedssum",
"MONTHLY_TARIFF_SUBSCRIPTION_AND_FEE": "Alle månedssummer",
"ALL_ENERGY": "Alle",
"PRODUCTION": "Produktion",
"FLEX_CONSUMPTION": "Forbrug (flexafregning)",
"TOTAL_CONSUMPTION": "Total forbrug",
"PRODUCTION": "Produktion",
"NON_PROFILED_CONSUMPTION": "Forbrug (timeafregning)",
"EXCHANGE": "Udveksling"
"EXCHANGE": "Udveksling",
"ALL_ENERGY": "Alle"
}
},
"settlementReports": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@
},
"statusPlaceholder": "Status",
"status": {
"ACTIVE": "Active",
"AWAITING": "Pending",
"ACTIVE": "Active",
"EXPIRED": "Stopped",
"CANCELLED": "Cancelled"
}
Expand Down Expand Up @@ -513,8 +513,8 @@
"E17Consumption": "Consumption"
},
"statusOptions": {
"ACTIVE": "Active",
"AWAITING": "Awaiting",
"ACTIVE": "Active",
"EXPIRED": "Expired",
"SOON_TO_EXPIRE": "Soon to expire"
},
Expand Down Expand Up @@ -823,9 +823,9 @@
"RECEIVED": "Received",
"AWAITING_DISPATCH": "Awaiting dispatch",
"AWAITING_REPLY": "Awaiting reply from eSett",
"BIZ_TALK_ACCEPTED": "Awaiting reply from ECP",
"ACCEPTED": "Accepted",
"REJECTED": "Rejected",
"BIZ_TALK_ACCEPTED": "Awaiting reply from ECP"
"REJECTED": "Rejected"
}
},
"filters": {
Expand Down Expand Up @@ -1089,8 +1089,8 @@
},
"calculationTypes": {
"BALANCE_FIXING": "{{wholesale.shared.BALANCE_FIXING}}",
"WHOLESALE_FIXING": "{{wholesale.shared.WHOLESALE_FIXING}}",
"AGGREGATION": "{{wholesale.shared.AGGREGATION}}",
"WHOLESALE_FIXING": "{{wholesale.shared.WHOLESALE_FIXING}}",
"FIRST_CORRECTION_SETTLEMENT": "{{wholesale.shared.FIRST_CORRECTION_SETTLEMENT}}",
"SECOND_CORRECTION_SETTLEMENT": "{{wholesale.shared.SECOND_CORRECTION_SETTLEMENT}}",
"THIRD_CORRECTION_SETTLEMENT": "{{wholesale.shared.THIRD_CORRECTION_SETTLEMENT}}",
Expand Down Expand Up @@ -1203,12 +1203,12 @@
"MONTHLY_SUBSCRIPTION": "Subscription monthly sum",
"MONTHLY_FEE": "Fee monthly sum",
"MONTHLY_TARIFF_SUBSCRIPTION_AND_FEE": "All monthly sums",
"ALL_ENERGY": "All",
"PRODUCTION": "Production",
"FLEX_CONSUMPTION": "Flex consumption",
"TOTAL_CONSUMPTION": "Total consumption",
"PRODUCTION": "Production",
"NON_PROFILED_CONSUMPTION": "Non profiled consumption",
"EXCHANGE": "Exchange"
"EXCHANGE": "Exchange",
"ALL_ENERGY": "All"
}
},
"settlementReports": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ import { dhMarketParticipantNameMaxLength } from '../../dh-market-participant-na
export class DhNewActorStepComponent {
newActorForm = input.required<ActorForm>();

marketRoleOptions: WattDropdownOptions = dhEnumToWattDropdownOptions(EicFunction, 'asc');
marketRoleOptions: WattDropdownOptions = dhEnumToWattDropdownOptions(EicFunction);
gridAreaOptions = getGridAreaOptions();

showGridAreaOptions = signal(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ export class DhBalanceResponsibleRelationFilterComponent implements OnInit {
balanceResponsibleOptions$ = getActorOptions([EicFunction.BalanceResponsibleParty], 'actorId');
gridAreaOptions$ = getGridAreaOptions();
statusOptions: WattDropdownOptions = dhEnumToWattDropdownOptions(
BalanceResponsibilityAgreementStatus,
'asc'
BalanceResponsibilityAgreementStatus
);

filtersForm = new FormGroup<Filters>({
Expand Down
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,
'asc',
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 @@ -98,7 +98,7 @@ export class DhDelegationTabComponent {
isEmpty = computed(() => this.delegationsRaw().length === 0);

statusControl = new FormControl<ActorDelegationStatus[] | null>(null);
statusOptions = dhEnumToWattDropdownOptions(ActorDelegationStatus, 'asc');
statusOptions = dhEnumToWattDropdownOptions(ActorDelegationStatus);

constructor() {
effect(() => this.fetchData(this.actor().id), { allowSignalWrites: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ <h3>{{ t("topBarTitle") }}</h3>

<vater-stack align="flex-start" gap="m">
<watt-dropdown
sortDirection="asc"
dhDropdownTranslator
translateKey="marketParticipant.gridAreas.types"
[chipMode]="true"
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, 'asc', [GridAreaType.NotSet]);
gridAreaTypeOptions = dhEnumToWattDropdownOptions(GridAreaType, [GridAreaType.NotSet]);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ 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
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
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
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export class DhWholesaleRequestCalculationComponent {
});

calculationTypeOptions = computed(() =>
dhEnumToWattDropdownOptions(CalculationType, 'asc', this.excludeCalculationTypes())
dhEnumToWattDropdownOptions(CalculationType, this.excludeCalculationTypes())
);

excludeRequestCalculationDataTypes = computed(() => {
Expand Down Expand Up @@ -202,7 +202,6 @@ export class DhWholesaleRequestCalculationComponent {
requestCalculationDataTypeOptions = computed(() => {
return dhEnumToWattDropdownOptions(
RequestCalculationDataType,
null,
this.excludeRequestCalculationDataTypes()
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export class DhRequestSettlementReportModalComponent extends WattTypedModal<Sett
}

private getCalculationTypeOptions(): WattDropdownOptions {
return dhEnumToWattDropdownOptions(CalculationType, null, [
return dhEnumToWattDropdownOptions(CalculationType, [
CalculationType.Aggregation,
this.modalData.marketRole === EicFunction.SystemOperator ? CalculationType.BalanceFixing : '',
]);
Expand Down
Loading