Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
reiterl committed Jul 5, 2024
1 parent 7921c8f commit 91dd7f7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,28 @@ export class ParticipantCsvExportService {
// ]
// ]);

public columns = Object.keys(participantHeadersAndVerboseNames).sort(
(a, b) => participantColumnsWeight[a] - participantColumnsWeight[b]
);

public constructor(private csvExport: MeetingCsvExportForBackendService, private translate: TranslateService) {}

public export(participants: ViewUser[]): void {
this.csvExport.export(
participants,
Object.keys(participantHeadersAndVerboseNames)
.sort((a, b) => participantColumnsWeight[a] - participantColumnsWeight[b])
.map(key => {
return {
property: key
} as CsvColumnDefinitionProperty<ViewUser>;
}) as CsvColumnsDefinition<ViewUser>,
this.columns.map(key => {
return {
property: key
} as CsvColumnDefinitionProperty<ViewUser>;
}) as CsvColumnsDefinition<ViewUser>,
this.translate.instant(`Participants`) + `.csv`
);
}

public exportCsvExample(): void {
const rows: UserExport[] = participantsExportExample;
this.csvExport.dummyCSVExport<UserExport>(
Object.keys(participantHeadersAndVerboseNames).sort(
(a, b) => participantColumnsWeight[a] - participantColumnsWeight[b]
),
this.columns,
rows,
`${this.translate.instant(`participants-example`)}.csv`
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ export class ParticipantImportListComponent extends BaseViaBackendImportListMeet
(a, b) => participantColumnsWeight[a] - participantColumnsWeight[b]
);

public columns: ImportListHeaderDefinition[] = Object.keys(participantHeadersAndVerboseNames)
.sort((a, b) => participantColumnsWeight[a] - participantColumnsWeight[b])
.map(header => ({
property: header,
label: (<any>participantHeadersAndVerboseNames)[header],
isTableColumn: true
}));
public columns: ImportListHeaderDefinition[] = this.possibleFields.map(header => ({
property: header,
label: (<any>participantHeadersAndVerboseNames)[header],
isTableColumn: true
}));

/**
* Constructor for list view bases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ export class AccountImportListComponent extends BaseViaBackendImportListComponen
(a, b) => accountColumnsWeight[a] - accountColumnsWeight[b]
);

public columns: ImportListHeaderDefinition[] = Object.keys(accountHeadersAndVerboseNames)
.sort((a, b) => accountColumnsWeight[a] - accountColumnsWeight[b])
.map(header => ({
property: header,
label: (<any>accountHeadersAndVerboseNames)[header],
isTableColumn: true,
customInfo: header === `gender` ? this.getTranslatedGenderInfoObservable() : undefined
}));
public columns: ImportListHeaderDefinition[] = this.possibleFields.map(header => ({
property: header,
label: (<any>accountHeadersAndVerboseNames)[header],
isTableColumn: true,
customInfo: header === `gender` ? this.getTranslatedGenderInfoObservable() : undefined
}));

public constructor(
protected override translate: TranslateService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ import { AccountExportServiceModule } from '../account-export-service.module';
providedIn: AccountExportServiceModule
})
export class AccountExportService {
public columns = Object.keys(accountHeadersAndVerboseNames).sort(
(a, b) => accountColumnsWeight[a] - accountColumnsWeight[b]
);

public constructor(private csvExportService: CsvExportForBackendService, private translate: TranslateService) {}

public downloadCsvImportExample(): void {
this.csvExportService.dummyCSVExport<UserExport>(
Object.keys(accountHeadersAndVerboseNames).sort(
(a, b) => accountColumnsWeight[a] - accountColumnsWeight[b]
),
this.columns,
AccountCsvExportExample,
`${this.translate.instant(`account-example`)}.csv`
);
Expand All @@ -27,11 +29,9 @@ export class AccountExportService {
public downloadAccountCsvFile(dataSource: ViewUser[]): void {
this.csvExportService.export(
dataSource,
Object.keys(accountHeadersAndVerboseNames)
.map(key => ({
property: key as keyof ViewUser
}))
.sort((a, b) => accountColumnsWeight[a.property] - accountColumnsWeight[b.property]),
this.columns.map(key => ({
property: key as keyof ViewUser
})),
`${this.translate.instant(`Accounts`)}.csv`
);
}
Expand Down

0 comments on commit 91dd7f7

Please sign in to comment.