-
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
Reorder the user imports fields #3722
Conversation
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.
Add-on:
Please also change the order in the previews
In the account-import:
- swap pronoun and gender
Added the swap. I think the order of the fields in the preview is delivered by the backend. |
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.
As far as I can see the file src/app/domain/models/users/user.constants now is not used anywhere and should be deleted
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.
I am against separating these two header definitions, it's unnecessarily shaky, it would be better to implement a way to assign these properties a client-side weight separately and then do some column sorting in the import-list components. I'd suggest do it via the defaultColumns input of the import-list.component.ts
Adding weight to the datastructure would add complexity to the backend import component interface. And the interface would be uglier. I don't think @luisa-beerboom 's idea is a good idea. Having two definitions for two different imports should be no problem in my opinion. I think my solution is fine. @rrenkert what do you think? |
The easiest way would be to define two const lists of |
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.
Like I said: Don't transform the HeadersAndVerboseNames
objects. They have the expressed purpose of managing the header names and should be as unified as possible for the sake of consistency.
There are already client-side column configurations (see f.E. the AccountImportListComponent
: It's an attribute called columns
) add a new optional field weight
to those and make the BaseViaBackendImportListComponent
sort the columns by that if it is there.
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.
This is much better, some minor improvements though
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 comment
The reason will be displayed to describe this comment to others. Learn more.
If participantColumnsWeight
already contains all relevant fields, why even import participantHeadersAndVerboseNames
at all
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.
yes, changed it.
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 | ||
}; |
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.
Using an array with the index being the weight may also work, would spare you the work of having to re-sort the keys every time you need the keys in-order
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.
Now use an array.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
see comments in participant-csv-export.service.ts
and participant-import/definitions/index.ts
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.
@@ -114,7 +114,7 @@ describe(`CsvExportForBackendService`, () => { | |||
|
|||
it(`test dummy export method with default settings`, () => { | |||
service.dummyCSVExport( | |||
{ proper: `Fancy`, tea: `Tea`, strength: `Muscle` }, | |||
Object.keys({ proper: `Fancy`, tea: `Tea`, strength: `Muscle` }), |
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.
Updated: Use lists for the order config. Remove surplus import, no longer sort and simplify one test. |
please solve merge conflicts |
Resolve #3719