diff --git a/client/src/app/domain/models/users/user.constants.ts b/client/src/app/domain/models/users/user.constants.ts index 31f56cfbb4..1a9f8af567 100644 --- a/client/src/app/domain/models/users/user.constants.ts +++ b/client/src/app/domain/models/users/user.constants.ts @@ -7,12 +7,12 @@ export const userHeadersAndVerboseNames: { [key in keyof User]?: any } = { first_name: _(`Given name`), last_name: _(`Surname`), email: _(`Email`), + member_number: _(`Member number`), pronoun: _(`Pronoun`), gender: _(`Gender`), username: _(`Username`), default_password: _(`Initial password`), is_active: _(`Active`), is_physical_person: _(`Natural person`), - saml_id: _(`SSO identification`), - member_number: _(`Membership number`) + saml_id: _(`SSO identification`) }; diff --git a/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.spec.ts b/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.spec.ts index c5a9a36b29..af28c94b6e 100644 --- a/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.spec.ts +++ b/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.spec.ts @@ -113,11 +113,7 @@ describe(`CsvExportForBackendService`, () => { }); it(`test dummy export method with default settings`, () => { - service.dummyCSVExport( - { proper: `Fancy`, tea: `Tea`, strength: `Muscle` }, - toDummyExport, - `dummyAssortmentOfTeas` - ); + service.dummyCSVExport([`proper`, `tea`, `strength`], toDummyExport, `dummyAssortmentOfTeas`); expect(exportService.lastSavedFiles.length).toBe(1); expect(exportService.lastSavedFiles[0]).toEqual({ file: `proper,tea,strength\r\n"1","Earl Grey","5"\r\n,"Herbal tea",`, diff --git a/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.ts b/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.ts index ccb5189ef0..a20a764c6e 100644 --- a/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.ts +++ b/client/src/app/gateways/export/csv-export.service/csv-export-for-backend.service.ts @@ -101,14 +101,15 @@ export class CsvExportForBackendService { } } - public dummyCSVExport(headerAndVerboseNames: { [key in keyof I]: any }, rows: I[], filename: string): void { + public dummyCSVExport(headers: string[], rows: I[], filename: string): void { const separator = DEFAULT_COLUMN_SEPARATOR; const encoding: `utf-8` | `iso-8859-15` = DEFAULT_ENCODING as any; - const headerRow = [Object.keys(headerAndVerboseNames).join(separator)]; + const headerRow = [headers.join(separator)]; + const content = rows.map(row => - Object.keys(headerAndVerboseNames) + headers .map(key => { - let value = row[key as keyof I] || ``; + let value = row[key] || ``; if (typeof value === `number`) { value = value.toString(10); } else if (typeof value === `boolean`) { diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/services/topic-export.service/topic-export.service.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/services/topic-export.service/topic-export.service.ts index 32fe059035..5d198c0c6a 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/services/topic-export.service/topic-export.service.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/topics/pages/topic-import/services/topic-export.service/topic-export.service.ts @@ -27,7 +27,7 @@ export class TopicExportService { ]; this.csvExportService.dummyCSVExport( - topicHeadersAndVerboseNames, + Object.keys(topicHeadersAndVerboseNames), rows, `${this.translate.instant(`Agenda`)}-${this.translate.instant(`example`)}.csv` ); diff --git a/client/src/app/site/pages/meetings/pages/participants/export/participant-csv-export.service/participant-csv-export.service.ts b/client/src/app/site/pages/meetings/pages/participants/export/participant-csv-export.service/participant-csv-export.service.ts index 553df8fcb3..b3bd1b2b2d 100644 --- a/client/src/app/site/pages/meetings/pages/participants/export/participant-csv-export.service/participant-csv-export.service.ts +++ b/client/src/app/site/pages/meetings/pages/participants/export/participant-csv-export.service/participant-csv-export.service.ts @@ -5,7 +5,7 @@ import { CsvColumnDefinitionProperty, CsvColumnsDefinition } from 'src/app/gatew import { ViewUser } from 'src/app/site/pages/meetings/view-models/view-user'; import { MeetingCsvExportForBackendService } from '../../../../services/export/meeting-csv-export-for-backend.service'; -import { participantHeadersAndVerboseNames } from '../../pages/participant-import/definitions'; +import { participantColumns } from '../../pages/participant-import/definitions'; import { ParticipantExportModule } from '../participant-export.module'; import { participantsExportExample } from '../participants-export-example'; @@ -45,7 +45,7 @@ export class ParticipantCsvExportService { public export(participants: ViewUser[]): void { this.csvExport.export( participants, - Object.keys(participantHeadersAndVerboseNames).map(key => { + participantColumns.map(key => { return { property: key } as CsvColumnDefinitionProperty; @@ -57,7 +57,7 @@ export class ParticipantCsvExportService { public exportCsvExample(): void { const rows: UserExport[] = participantsExportExample; this.csvExport.dummyCSVExport( - participantHeadersAndVerboseNames, + participantColumns, rows, `${this.translate.instant(`participants-example`)}.csv` ); diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-import/components/participant-import-list/participant-import-list.component.ts b/client/src/app/site/pages/meetings/pages/participants/pages/participant-import/components/participant-import-list/participant-import-list.component.ts index ee9e210032..a52f9a9d51 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-import/components/participant-import-list/participant-import-list.component.ts +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-import/components/participant-import-list/participant-import-list.component.ts @@ -3,7 +3,7 @@ import { TranslateService } from '@ngx-translate/core'; import { BaseViaBackendImportListMeetingComponent } from 'src/app/site/base/base-via-backend-import-list-meeting.component'; import { ImportListHeaderDefinition } from 'src/app/ui/modules/import-list'; -import { participantHeadersAndVerboseNames } from '../../definitions'; +import { participantColumns, participantHeadersAndVerboseNames } from '../../definitions'; import { ParticipantImportService } from '../../services'; @Component({ @@ -12,9 +12,9 @@ import { ParticipantImportService } from '../../services'; styleUrls: [`./participant-import-list.component.scss`] }) export class ParticipantImportListComponent extends BaseViaBackendImportListMeetingComponent { - public possibleFields = Object.keys(participantHeadersAndVerboseNames); + public possibleFields = participantColumns; - public columns: ImportListHeaderDefinition[] = Object.keys(participantHeadersAndVerboseNames).map(header => ({ + public columns: ImportListHeaderDefinition[] = this.possibleFields.map(header => ({ property: header, label: (participantHeadersAndVerboseNames)[header], isTableColumn: true diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-import/definitions/index.ts b/client/src/app/site/pages/meetings/pages/participants/pages/participant-import/definitions/index.ts index 00b3ce9fd2..663ee73b74 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-import/definitions/index.ts +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-import/definitions/index.ts @@ -1,12 +1,33 @@ import { userHeadersAndVerboseNames } from 'src/app/domain/models/users/user.constants'; import { GeneralUser } from 'src/app/gateways/repositories/users'; -export const participantHeadersAndVerboseNames: { [key in keyof GeneralUser]?: string } = { +export const participantHeadersAndVerboseNames: { [key in keyof GeneralUser]?: any } = { ...userHeadersAndVerboseNames, - is_present: `Is present`, structure_level: `Structure levels`, + groups: `Groups`, number: `Participant number`, vote_weight: `Vote weight`, - groups: `Groups`, + is_present: `Is present`, comment: `Comment` }; + +export const participantColumns: (keyof GeneralUser)[] = [ + `title`, + `first_name`, + `last_name`, + `email`, + `member_number`, + `structure_level`, + `groups`, + `number`, + `vote_weight`, + `gender`, + `pronoun`, + `username`, + `default_password`, + `is_active`, + `is_physical_person`, + `is_present`, + `saml_id`, + `comment` +]; diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/account-import/components/account-import-list/account-import-list.component.ts b/client/src/app/site/pages/organization/pages/accounts/pages/account-import/components/account-import-list/account-import-list.component.ts index 344179e150..6246b34338 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/account-import/components/account-import-list/account-import-list.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/account-import/components/account-import-list/account-import-list.component.ts @@ -5,7 +5,7 @@ import { BaseViaBackendImportListComponent } from 'src/app/site/base/base-via-ba import { OrganizationSettingsService } from 'src/app/site/pages/organization/services/organization-settings.service'; import { ImportListHeaderDefinition } from 'src/app/ui/modules/import-list'; -import { accountHeadersAndVerboseNames } from '../../definitions'; +import { accountColumns, accountHeadersAndVerboseNames } from '../../definitions'; import { AccountImportService } from '../../services/account-import.service/account-import.service'; @Component({ @@ -14,9 +14,9 @@ import { AccountImportService } from '../../services/account-import.service/acco styleUrls: [`./account-import-list.component.scss`] }) export class AccountImportListComponent extends BaseViaBackendImportListComponent { - public possibleFields = Object.keys(accountHeadersAndVerboseNames); + public possibleFields = accountColumns; - public columns: ImportListHeaderDefinition[] = Object.keys(accountHeadersAndVerboseNames).map(header => ({ + public columns: ImportListHeaderDefinition[] = this.possibleFields.map(header => ({ property: header, label: (accountHeadersAndVerboseNames)[header], isTableColumn: true, diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/account-import/definitions/index.ts b/client/src/app/site/pages/organization/pages/accounts/pages/account-import/definitions/index.ts index fa1f9c6a3e..5a12b341ce 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/account-import/definitions/index.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/account-import/definitions/index.ts @@ -2,7 +2,23 @@ import { marker as _ } from '@colsen1991/ngx-translate-extract-marker'; import { User } from 'src/app/domain/models/users/user'; import { userHeadersAndVerboseNames } from 'src/app/domain/models/users/user.constants'; -export const accountHeadersAndVerboseNames: { [key in keyof User]?: string } = { +export const accountHeadersAndVerboseNames: { [key in keyof User]?: any } = { ...userHeadersAndVerboseNames, default_vote_weight: _(`Vote weight`) }; + +export const accountColumns: (keyof User)[] = [ + `title`, + `first_name`, + `last_name`, + `email`, + `member_number`, + `default_vote_weight`, + `gender`, + `pronoun`, + `username`, + `default_password`, + `is_active`, + `is_physical_person`, + `saml_id` +]; diff --git a/client/src/app/site/pages/organization/pages/accounts/services/account-export.service/account-export.service.ts b/client/src/app/site/pages/organization/pages/accounts/services/account-export.service/account-export.service.ts index 4c673c2e64..8083938413 100644 --- a/client/src/app/site/pages/organization/pages/accounts/services/account-export.service/account-export.service.ts +++ b/client/src/app/site/pages/organization/pages/accounts/services/account-export.service/account-export.service.ts @@ -5,7 +5,7 @@ import { CsvExportForBackendService } from 'src/app/gateways/export/csv-export.s import { ViewUser } from 'src/app/site/pages/meetings/view-models/view-user'; import { AccountCsvExportExample } from '../../export/csv-export-example'; -import { accountHeadersAndVerboseNames } from '../../pages/account-import/definitions'; +import { accountColumns } from '../../pages/account-import/definitions'; import { AccountExportServiceModule } from '../account-export-service.module'; @Injectable({ @@ -16,7 +16,7 @@ export class AccountExportService { public downloadCsvImportExample(): void { this.csvExportService.dummyCSVExport( - accountHeadersAndVerboseNames, + accountColumns, AccountCsvExportExample, `${this.translate.instant(`account-example`)}.csv` ); @@ -25,7 +25,7 @@ export class AccountExportService { public downloadAccountCsvFile(dataSource: ViewUser[]): void { this.csvExportService.export( dataSource, - Object.keys(accountHeadersAndVerboseNames).map(key => ({ + accountColumns.map(key => ({ property: key as keyof ViewUser })), `${this.translate.instant(`Accounts`)}.csv` diff --git a/client/src/app/site/pages/organization/pages/committees/pages/committee-import/services/committee-import.service/committee-import.service.ts b/client/src/app/site/pages/organization/pages/committees/pages/committee-import/services/committee-import.service/committee-import.service.ts index 294660e339..cfcd8c84d4 100644 --- a/client/src/app/site/pages/organization/pages/committees/pages/committee-import/services/committee-import.service/committee-import.service.ts +++ b/client/src/app/site/pages/organization/pages/committees/pages/committee-import/services/committee-import.service/committee-import.service.ts @@ -38,7 +38,7 @@ export class CommitteeImportService extends BaseBackendImportService { public downloadCsvExample(): void { this.exporter.dummyCSVExport( - committeeHeadersAndVerboseNames, + Object.keys(committeeHeadersAndVerboseNames), COMMITTEE_CSV_EXPORT_EXAMPLE, `${this.translate.instant(`committee-example`)}.csv` ); diff --git a/client/src/meta b/client/src/meta index 2e80fc0188..02a18f7498 160000 --- a/client/src/meta +++ b/client/src/meta @@ -1 +1 @@ -Subproject commit 2e80fc0188c6d0288447c07458f15b031dd89ce5 +Subproject commit 02a18f7498799948c352cd5aaa9f109d60f5f87e