From 32ab76a225ac13641740185b174d3bb6e683ffe0 Mon Sep 17 00:00:00 2001 From: Bastian Rihm Date: Fri, 30 Aug 2024 10:43:21 +0200 Subject: [PATCH 1/3] Add participants via member number --- .../search-users-presenter.service.ts | 1 + .../participant-create-wizard.component.html | 26 ++++++++++++++----- .../participant-create-wizard.component.ts | 1 + 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/client/src/app/gateways/presenter/search-users-presenter.service.ts b/client/src/app/gateways/presenter/search-users-presenter.service.ts index 56210c17a1..0cf86bfccd 100644 --- a/client/src/app/gateways/presenter/search-users-presenter.service.ts +++ b/client/src/app/gateways/presenter/search-users-presenter.service.ts @@ -71,6 +71,7 @@ export class SearchUsersPresenterService { permissionScope, permissionRelatedId, searchCriteria: users.map(entry => ({ + member_number: entry.member_number, username: entry.username, first_name: entry.first_name, last_name: entry.last_name, diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.html b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.html index dcd75187b4..6431f187d8 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.html +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.html @@ -57,12 +57,26 @@

{{ 'Personal information' | translate }}

- - - {{ 'Email' | translate }} - - {{ 'Please enter a valid email address!' | translate }} - +
+ + + {{ 'Email' | translate }} + + {{ 'Please enter a valid email address!' | translate }} + + + + + {{ 'Membership number' | translate }} + + +
{{ 'Username' | translate }} diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.ts b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.ts index c96f25cb1a..af42444849 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.ts +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/pages/participant-detail-manage/components/participant-create-wizard/participant-create-wizard.component.ts @@ -173,6 +173,7 @@ export class ParticipantCreateWizardComponent extends BaseMeetingComponent imple username: [``], first_name: [``], last_name: [``], + member_number: [``], email: [``, createEmailValidator()] }, { From 03c9e166a08ec7e30e6d0be8bac83a8b60485285 Mon Sep 17 00:00:00 2001 From: Bastian Rihm Date: Fri, 30 Aug 2024 10:52:03 +0200 Subject: [PATCH 2/3] Update test --- .../search-users-presenter.service.spec.ts | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/client/src/app/gateways/presenter/search-users-presenter.service.spec.ts b/client/src/app/gateways/presenter/search-users-presenter.service.spec.ts index 3b70487a66..126697e309 100644 --- a/client/src/app/gateways/presenter/search-users-presenter.service.spec.ts +++ b/client/src/app/gateways/presenter/search-users-presenter.service.spec.ts @@ -11,9 +11,27 @@ describe(`SearchUsersPresenterService`, () => { let presenter: MockPresenterService; const testUsers = [ - { id: 2, username: `johnDoe`, email: `john.doe@email.en`, first_name: `John`, last_name: `Doe` }, - { id: 3, username: `jd`, email: `joanna.doe@email.en`, first_name: `Joanna`, last_name: `Doe` }, - { id: 4, username: `johnsSecondAccount`, email: `john.doe@email.en`, first_name: `John`, last_name: `Doe` }, + { + id: 2, + username: `johnDoe`, + email: `john.doe@email.en`, + first_name: `John`, + last_name: `Doe` + }, + { + id: 3, + username: `jd`, + email: `joanna.doe@email.en`, + first_name: `Joanna`, + last_name: `Doe` + }, + { + id: 4, + username: `johnsSecondAccount`, + email: `john.doe@email.en`, + first_name: `John`, + last_name: `Doe` + }, { id: 5, username: `rando`, first_name: `Rando`, last_name: `Mized` } ]; @@ -37,7 +55,10 @@ describe(`SearchUsersPresenterService`, () => { !search || typeof search !== `object` || Object.keys(search).some( - key => ![`username`, `saml_id`, `first_name`, `last_name`, `email`].includes(key) + key => + ![`username`, `saml_id`, `first_name`, `last_name`, `email`, `member_number`].includes( + key + ) ) ) ) { From b88d9e179516a5599e5f0d596019c2c58352f239 Mon Sep 17 00:00:00 2001 From: Bastian Rihm Date: Wed, 4 Sep 2024 10:05:47 +0200 Subject: [PATCH 3/3] Fix participant create without member number --- .../repositories/users/user-repository.service.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/client/src/app/gateways/repositories/users/user-repository.service.ts b/client/src/app/gateways/repositories/users/user-repository.service.ts index 155d569371..2ebf4111ac 100644 --- a/client/src/app/gateways/repositories/users/user-repository.service.ts +++ b/client/src/app/gateways/repositories/users/user-repository.service.ts @@ -146,7 +146,7 @@ export class UserRepositoryService extends BaseRepository { const data = usersToCreate.map(user => { const meetingUsers = user.meeting_users as Partial[]; return { - user: this.sanitizePayload(this.getBaseUserPayload(user)), + user: this.sanitizePayload(this.getBaseUserPayload(user), true), ...(meetingUsers && meetingUsers.length ? { first_meeting_user: this.sanitizePayload( @@ -516,9 +516,9 @@ export class UserRepositoryService extends BaseRepository { return this.createAction(UserAction.MERGE_TOGETHER, payload); } - private sanitizePayload(payload: any): any { + private sanitizePayload(payload: any, create: boolean = false): any { const temp = { ...payload }; - for (const key of Object.keys(temp).filter(field => !this.isFieldAllowedToBeEmpty(field))) { + for (const key of Object.keys(temp).filter(field => !this.isFieldAllowedToBeEmpty(field, create))) { if (typeof temp[key] === `string` && !temp[key].trim().length) { payload[key] = undefined; } else if (Array.isArray(temp[key])) { @@ -533,7 +533,7 @@ export class UserRepositoryService extends BaseRepository { return { ...payload }; } - private isFieldAllowedToBeEmpty(field: string): boolean { + private isFieldAllowedToBeEmpty(field: string, create?: boolean): boolean { const fields: string[] = [ `title`, `email`, @@ -542,9 +542,12 @@ export class UserRepositoryService extends BaseRepository { `comment`, `about_me`, `number`, - `structure_level`, - `member_number` + `structure_level` ]; + if (!create) { + fields.push(`member_number`); + } + return fields.includes(field); }