-
Notifications
You must be signed in to change notification settings - Fork 33
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
Reorder the user imports fields #3722
Changes from 4 commits
9266fa5
313f634
788065d
48e62fb
ccb22c4
aacdc8e
7921c8f
91dd7f7
e9f39fd
c0064a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { marker as _ } from '@colsen1991/ngx-translate-extract-marker'; | ||
|
||
import { User } from './user'; | ||
|
||
export const userHeadersAndVerboseNames: { [key in keyof User]?: any } = { | ||
title: _(`Title`), | ||
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`) | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,10 @@ 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 { | ||
participantColumnsWeight, | ||
participantHeadersAndVerboseNames | ||
} from '../../pages/participant-import/definitions'; | ||
import { ParticipantExportModule } from '../participant-export.module'; | ||
import { participantsExportExample } from '../participants-export-example'; | ||
|
||
|
@@ -40,12 +43,16 @@ export class ParticipantCsvExportService { | |
// ] | ||
// ]); | ||
|
||
public columns = Object.keys(participantHeadersAndVerboseNames).sort( | ||
(a, b) => participantColumnsWeight[a] - participantColumnsWeight[b] | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, changed it. |
||
|
||
public constructor(private csvExport: MeetingCsvExportForBackendService, private translate: TranslateService) {} | ||
|
||
public export(participants: ViewUser[]): void { | ||
this.csvExport.export( | ||
participants, | ||
Object.keys(participantHeadersAndVerboseNames).map(key => { | ||
this.columns.map(key => { | ||
return { | ||
property: key | ||
} as CsvColumnDefinitionProperty<ViewUser>; | ||
|
@@ -57,7 +64,7 @@ export class ParticipantCsvExportService { | |
public exportCsvExample(): void { | ||
const rows: UserExport[] = participantsExportExample; | ||
this.csvExport.dummyCSVExport<UserExport>( | ||
participantHeadersAndVerboseNames, | ||
this.columns, | ||
rows, | ||
`${this.translate.instant(`participants-example`)}.csv` | ||
); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { participantColumnsWeight, participantHeadersAndVerboseNames } from '../../definitions'; | ||
import { ParticipantImportService } from '../../services'; | ||
|
||
@Component({ | ||
|
@@ -12,9 +12,11 @@ import { ParticipantImportService } from '../../services'; | |
styleUrls: [`./participant-import-list.component.scss`] | ||
}) | ||
export class ParticipantImportListComponent extends BaseViaBackendImportListMeetingComponent { | ||
public possibleFields = Object.keys(participantHeadersAndVerboseNames); | ||
public possibleFields = Object.keys(participantHeadersAndVerboseNames).sort( | ||
(a, b) => participantColumnsWeight[a] - participantColumnsWeight[b] | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comments in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
public columns: ImportListHeaderDefinition[] = Object.keys(participantHeadersAndVerboseNames).map(header => ({ | ||
public columns: ImportListHeaderDefinition[] = this.possibleFields.map(header => ({ | ||
property: header, | ||
label: (<any>participantHeadersAndVerboseNames)[header], | ||
isTableColumn: true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
import { marker as _ } from '@colsen1991/ngx-translate-extract-marker'; | ||
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]?: any } = { | ||
title: _(`Title`), | ||
first_name: _(`Given name`), | ||
last_name: _(`Surname`), | ||
email: _(`Email`), | ||
member_number: _(`Member number`), | ||
...userHeadersAndVerboseNames, | ||
structure_level: `Structure levels`, | ||
groups: `Groups`, | ||
number: `Participant number`, | ||
vote_weight: `Vote weight`, | ||
gender: _(`Gender`), | ||
pronoun: _(`Pronoun`), | ||
username: _(`Username`), | ||
default_password: _(`Initial password`), | ||
is_active: _(`Active`), | ||
is_physical_person: _(`Natural person`), | ||
is_present: `Is present`, | ||
saml_id: _(`SSO identification`), | ||
comment: `Comment` | ||
}; | ||
|
||
export const participantColumnsWeight: { [key in keyof GeneralUser]?: any } = { | ||
title: 1, | ||
first_name: 2, | ||
last_name: 3, | ||
email: 4, | ||
member_number: 5, | ||
structure_level: 6, | ||
groups: 7, | ||
number: 8, | ||
vote_weight: 9, | ||
gender: 10, | ||
pronoun: 11, | ||
username: 12, | ||
default_password: 13, | ||
is_active: 14, | ||
is_physical_person: 15, | ||
is_present: 16, | ||
saml_id: 17, | ||
comment: 18 | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
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]?: any } = { | ||
title: _(`Title`), | ||
first_name: _(`Given name`), | ||
last_name: _(`Surname`), | ||
email: _(`Email`), | ||
member_number: _(`Member number`), | ||
default_vote_weight: _(`Vote weight`), | ||
gender: _(`Gender`), | ||
pronoun: _(`Pronoun`), | ||
username: _(`Username`), | ||
default_password: _(`Initial password`), | ||
is_active: _(`Active`), | ||
is_physical_person: _(`Natural person`), | ||
saml_id: _(`SSO identification`) | ||
...userHeadersAndVerboseNames, | ||
default_vote_weight: _(`Vote weight`) | ||
}; | ||
|
||
export const accountColumnsWeight: { [key in keyof User]?: any } = { | ||
title: 1, | ||
first_name: 2, | ||
last_name: 3, | ||
email: 4, | ||
member_number: 5, | ||
default_vote_weight: 6, | ||
gender: 7, | ||
pronoun: 8, | ||
username: 9, | ||
default_password: 10, | ||
is_active: 11, | ||
is_physical_person: 12, | ||
saml_id: 13 | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use the list of keys at this point, no use keeping this as an object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.