From 51a289eb146b29588945ac3fcce8f00027c64883 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Wed, 7 Aug 2024 11:18:52 +0200 Subject: [PATCH 01/24] Update gender related domain/models files --- client/src/app/domain/models/gender/gender.ts | 21 +++++++++++++++++++ .../models/organizations/organization.ts | 4 ++-- client/src/app/domain/models/users/user.ts | 6 +++--- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 client/src/app/domain/models/gender/gender.ts diff --git a/client/src/app/domain/models/gender/gender.ts b/client/src/app/domain/models/gender/gender.ts new file mode 100644 index 0000000000..3046600b1f --- /dev/null +++ b/client/src/app/domain/models/gender/gender.ts @@ -0,0 +1,21 @@ +import { Id } from '../../definitions/key-types'; +import { BaseModel } from '../base/base-model'; +/** + * Representation of a gender. + * @ignore + */ + +export class Gender extends BaseModel { + public static COLLECTION = `gender`; + + public readonly name!: string; + public organization_id!: Id; // (organization/gender_ids)[] + public user_ids!: Id[]; // user/gender_id + + public constructor(input?: Partial) { + super(Gender.COLLECTION, input); + } + + public static readonly REQUESTABLE_FIELDS: (keyof Gender)[] = [`id`, `name`, `organization_id`, `user_ids`]; +} +export interface Gender {} diff --git a/client/src/app/domain/models/organizations/organization.ts b/client/src/app/domain/models/organizations/organization.ts index 25151d8c97..614808d314 100644 --- a/client/src/app/domain/models/organizations/organization.ts +++ b/client/src/app/domain/models/organizations/organization.ts @@ -34,7 +34,6 @@ export class OrganizationSetting { public saml_metadata_idp!: string; public saml_metadata_sp!: string; public saml_private_key!: string; - public genders!: string[]; } export class Organization extends BaseModel { @@ -52,6 +51,7 @@ export class Organization extends BaseModel { public archived_meeting_ids!: Id[]; // (meeting/is_archived_in_organization_id)[]; public template_meeting_ids!: Id[]; // (meeting/template_for_organization_id)[]; public mediafile_ids!: Id[]; + public gender_ids!: Id[]; // (gender/organization_id); public constructor(input?: any) { super(Organization.COLLECTION, input); @@ -65,7 +65,7 @@ export class Organization extends BaseModel { `privacy_policy`, `login_text`, `reset_password_verbose_errors`, - `genders`, + `gender_ids`, `enable_electronic_voting`, `enable_chat`, `limit_of_meetings`, diff --git a/client/src/app/domain/models/users/user.ts b/client/src/app/domain/models/users/user.ts index efde0d5100..4389fdd324 100644 --- a/client/src/app/domain/models/users/user.ts +++ b/client/src/app/domain/models/users/user.ts @@ -29,7 +29,6 @@ export class User extends BaseDecimalModel { public readonly is_physical_person!: boolean; public readonly default_password!: string; public readonly can_change_own_password!: boolean; - public readonly gender!: string; public readonly email!: string; public readonly last_email_sent!: number; // comes in seconds public readonly last_login!: number; // comes in seconds @@ -52,6 +51,7 @@ export class User extends BaseDecimalModel { public organization_management_level!: keyof OMLMapping; public committee_management_ids!: Id[]; + public gender_id: Id; // (gender/user_ids)[] public constructor(input?: Partial) { super(User.COLLECTION, input); @@ -64,8 +64,8 @@ export class User extends BaseDecimalModel { public static readonly REQUESTABLE_FIELDS: (keyof User)[] = [ `id`, `username`, - `saml_id`, `member_number`, + `saml_id`, `pronoun`, `title`, `first_name`, @@ -74,12 +74,12 @@ export class User extends BaseDecimalModel { `is_physical_person`, `default_password`, `can_change_own_password`, - `gender`, `email`, `default_vote_weight`, `last_email_sent`, `is_demo_user`, `last_login`, + `gender_id`, `organization_management_level`, `is_present_in_meeting_ids`, `committee_ids`, From 54126754374c7235376ada175553162ccef6fde6 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Wed, 7 Aug 2024 12:53:06 +0200 Subject: [PATCH 02/24] Add ViewGender and GenderRepositoryService --- .../gender/gender-repository.service.spec.ts | 16 +++++++ .../gender/gender-repository.service.ts | 48 +++++++++++++++++++ .../repositories/gender/gender.action.ts | 5 ++ .../pages/gender/view-models/view-gender.ts | 19 ++++++++ 4 files changed, 88 insertions(+) create mode 100644 client/src/app/gateways/repositories/gender/gender-repository.service.spec.ts create mode 100644 client/src/app/gateways/repositories/gender/gender-repository.service.ts create mode 100644 client/src/app/gateways/repositories/gender/gender.action.ts create mode 100644 client/src/app/site/pages/organization/pages/gender/view-models/view-gender.ts diff --git a/client/src/app/gateways/repositories/gender/gender-repository.service.spec.ts b/client/src/app/gateways/repositories/gender/gender-repository.service.spec.ts new file mode 100644 index 0000000000..14d24c0351 --- /dev/null +++ b/client/src/app/gateways/repositories/gender/gender-repository.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { GenderRepositoryService } from './gender-repository.service'; + +xdescribe(`GenderRepositoryService`, () => { + let service: GenderRepositoryService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(GenderRepositoryService); + }); + + it(`should be created`, () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/gateways/repositories/gender/gender-repository.service.ts b/client/src/app/gateways/repositories/gender/gender-repository.service.ts new file mode 100644 index 0000000000..c9db24df1e --- /dev/null +++ b/client/src/app/gateways/repositories/gender/gender-repository.service.ts @@ -0,0 +1,48 @@ +import { Injectable } from '@angular/core'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { Identifiable } from 'src/app/domain/interfaces'; +import { Gender } from 'src/app/domain/models/gender/gender'; +import { BaseRepository } from 'src/app/gateways/repositories/base-repository'; +import { ViewGender } from 'src/app/site/pages/organization/pages/gender/view-models/view-gender'; +import { Fieldsets } from 'src/app/site/services/model-request-builder'; + +import { RepositoryServiceCollectorService } from '../repository-service-collector.service'; +import { GenderAction } from './gender.action'; + +@Injectable({ + providedIn: `root` +}) +export class GenderRepositoryService extends BaseRepository { + public constructor(repositoryServiceCollector: RepositoryServiceCollectorService) { + super(repositoryServiceCollector, Gender); + } + + public getVerboseName = (plural?: boolean): string => (plural ? `Genders` : `Gender`); + public getTitle = (viewModel: ViewGender): string => viewModel.name; + public override getFieldsets(): Fieldsets { + const baseFields: (keyof Gender)[] = []; + const requiredFields: (keyof Gender)[] = baseFields.concat([`name`]); + return { + ...super.getFieldsets(), + required: requiredFields + }; + } + + public create(...genders: any[]): Promise { + const payload = genders; + return this.sendBulkActionToBackend(GenderAction.CREATE, payload); + } + + public update(update: any, id: Id): Promise { + const payload = { + id, + ...update + }; + return this.sendActionToBackend(GenderAction.UPDATE, payload); + } + + public delete(...ids: Id[]): Promise { + const payload = ids.map(id => ({ id })); + return this.sendBulkActionToBackend(GenderAction.DELETE, payload); + } +} diff --git a/client/src/app/gateways/repositories/gender/gender.action.ts b/client/src/app/gateways/repositories/gender/gender.action.ts new file mode 100644 index 0000000000..9707ea7e70 --- /dev/null +++ b/client/src/app/gateways/repositories/gender/gender.action.ts @@ -0,0 +1,5 @@ +export class GenderAction { + public static readonly CREATE = `gender.create`; + public static readonly UPDATE = `gender.update`; + public static readonly DELETE = `gender.delete`; +} diff --git a/client/src/app/site/pages/organization/pages/gender/view-models/view-gender.ts b/client/src/app/site/pages/organization/pages/gender/view-models/view-gender.ts new file mode 100644 index 0000000000..620aa52b40 --- /dev/null +++ b/client/src/app/site/pages/organization/pages/gender/view-models/view-gender.ts @@ -0,0 +1,19 @@ +import { Gender } from 'src/app/domain/models/gender/gender'; +import { BaseViewModel } from 'src/app/site/base/base-view-model'; +import { ViewUser } from 'src/app/site/pages/meetings/view-models/view-user'; +import { ViewOrganization } from 'src/app/site/pages/organization/view-models/view-organization'; + +export class ViewGender extends BaseViewModel { + public static readonly COLLECTION = Gender.COLLECTION; + protected _collection = Gender.COLLECTION; + + public get gender(): Gender { + return this._model; + } +} + +interface IGenderRelations { + organization: ViewOrganization; + users: ViewUser[]; +} +export interface ViewGender extends Gender, IGenderRelations {} From 524cd658a2135e7bc77fe2319a29820cae9b128a Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Wed, 7 Aug 2024 13:39:08 +0200 Subject: [PATCH 03/24] Add gender-list dummy component --- .../gender/gender-repository.service.ts | 2 +- .../gender-list/gender-list.component.html | 1 + .../gender-list/gender-list.component.scss | 0 .../gender-list/gender-list.component.spec.ts | 22 +++++++++++++ .../gender-list/gender-list.component.ts | 9 ++++++ .../gender-list/gender-list-routing.module.ts | 17 ++++++++++ .../pages/gender-list/gender-list.module.ts | 32 +++++++++++++++++++ .../pages}/gender/view-models/view-gender.ts | 0 8 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html create mode 100644 client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.scss create mode 100644 client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.spec.ts create mode 100644 client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts create mode 100644 client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list-routing.module.ts create mode 100644 client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list.module.ts rename client/src/app/site/pages/organization/pages/{ => accounts/pages}/gender/view-models/view-gender.ts (100%) diff --git a/client/src/app/gateways/repositories/gender/gender-repository.service.ts b/client/src/app/gateways/repositories/gender/gender-repository.service.ts index c9db24df1e..7dec6f007c 100644 --- a/client/src/app/gateways/repositories/gender/gender-repository.service.ts +++ b/client/src/app/gateways/repositories/gender/gender-repository.service.ts @@ -3,7 +3,7 @@ import { Id } from 'src/app/domain/definitions/key-types'; import { Identifiable } from 'src/app/domain/interfaces'; import { Gender } from 'src/app/domain/models/gender/gender'; import { BaseRepository } from 'src/app/gateways/repositories/base-repository'; -import { ViewGender } from 'src/app/site/pages/organization/pages/gender/view-models/view-gender'; +import { ViewGender } from 'src/app/site/pages/organization/pages/accounts/pages/gender/view-models/view-gender'; import { Fieldsets } from 'src/app/site/services/model-request-builder'; import { RepositoryServiceCollectorService } from '../repository-service-collector.service'; diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html new file mode 100644 index 0000000000..261eed81e8 --- /dev/null +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html @@ -0,0 +1 @@ +

gender-list works!

diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.scss b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.spec.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.spec.ts new file mode 100644 index 0000000000..2953d2bc36 --- /dev/null +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.spec.ts @@ -0,0 +1,22 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { GenderListComponent } from './gender-list.component'; + +describe(`GenderListComponent`, () => { + let component: GenderListComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [GenderListComponent] + }).compileComponents(); + + fixture = TestBed.createComponent(GenderListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it(`should create`, () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts new file mode 100644 index 0000000000..b0ee1322b6 --- /dev/null +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts @@ -0,0 +1,9 @@ +import { ChangeDetectionStrategy, Component } from '@angular/core'; + +@Component({ + selector: `os-gender-list`, + templateUrl: `./gender-list.component.html`, + styleUrl: `./gender-list.component.scss`, + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class GenderListComponent {} diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list-routing.module.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list-routing.module.ts new file mode 100644 index 0000000000..213ae3f90d --- /dev/null +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list-routing.module.ts @@ -0,0 +1,17 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; + +import { GenderListComponent } from './components/gender-list/gender-list.component'; + +const routes: Routes = [ + { + path: ``, + component: GenderListComponent + } +]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule] +}) +export class GenderListRoutingModule {} diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list.module.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list.module.ts new file mode 100644 index 0000000000..1d5238f74a --- /dev/null +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list.module.ts @@ -0,0 +1,32 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { MatButtonModule } from '@angular/material/button'; +import { MatDividerModule } from '@angular/material/divider'; +import { MatIconModule } from '@angular/material/icon'; +import { MatMenuModule } from '@angular/material/menu'; +import { OpenSlidesTranslationModule } from 'src/app/site/modules/translations'; +import { ChipModule } from 'src/app/ui/modules/chip'; +import { HeadBarModule } from 'src/app/ui/modules/head-bar/head-bar.module'; +import { ListModule } from 'src/app/ui/modules/list'; +import { PromptDialogModule } from 'src/app/ui/modules/prompt-dialog'; + +import { GenderListComponent } from './components/gender-list/gender-list.component'; +import { GenderListRoutingModule } from './gender-list-routing.module'; + +@NgModule({ + declarations: [GenderListComponent], + imports: [ + CommonModule, + GenderListRoutingModule, + PromptDialogModule, + HeadBarModule, + ListModule, + ChipModule, + OpenSlidesTranslationModule.forChild(), + MatIconModule, + MatMenuModule, + MatButtonModule, + MatDividerModule + ] +}) +export class GenderListModule {} diff --git a/client/src/app/site/pages/organization/pages/gender/view-models/view-gender.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/view-models/view-gender.ts similarity index 100% rename from client/src/app/site/pages/organization/pages/gender/view-models/view-gender.ts rename to client/src/app/site/pages/organization/pages/accounts/pages/gender/view-models/view-gender.ts From c403ed31e0a4bb46ac9be495cbe1ad8883158363 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Wed, 7 Aug 2024 15:05:36 +0200 Subject: [PATCH 04/24] Add gender route in accounts-routing --- .../organization/pages/accounts/accounts-routing.module.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/src/app/site/pages/organization/pages/accounts/accounts-routing.module.ts b/client/src/app/site/pages/organization/pages/accounts/accounts-routing.module.ts index 461452d1c9..9ec6f2ba30 100644 --- a/client/src/app/site/pages/organization/pages/accounts/accounts-routing.module.ts +++ b/client/src/app/site/pages/organization/pages/accounts/accounts-routing.module.ts @@ -39,6 +39,11 @@ const routes: Routes = [ loadChildren: () => import(`./pages/account-import/account-import.module`).then(m => m.AccountImportModule) }, + { + path: `gender`, + loadChildren: () => + import(`./pages/gender/pages/gender-list/gender-list.module`).then(m => m.GenderListModule) + }, { path: `:id`, loadChildren: () => From 59117efd7589a935d5afd503ba6190a4ed95428b Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Thu, 8 Aug 2024 10:37:19 +0200 Subject: [PATCH 05/24] Add the genders button to the account-list --- .../organization/pages/accounts/accounts-routing.module.ts | 2 +- .../components/account-list/account-list.component.html | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/app/site/pages/organization/pages/accounts/accounts-routing.module.ts b/client/src/app/site/pages/organization/pages/accounts/accounts-routing.module.ts index 9ec6f2ba30..a6d96dcc3a 100644 --- a/client/src/app/site/pages/organization/pages/accounts/accounts-routing.module.ts +++ b/client/src/app/site/pages/organization/pages/accounts/accounts-routing.module.ts @@ -40,7 +40,7 @@ const routes: Routes = [ import(`./pages/account-import/account-import.module`).then(m => m.AccountImportModule) }, { - path: `gender`, + path: `genders`, loadChildren: () => import(`./pages/gender/pages/gender-list/gender-list.module`).then(m => m.GenderListModule) }, diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/account-list/components/account-list/account-list.component.html b/client/src/app/site/pages/organization/pages/accounts/pages/account-list/components/account-list/account-list.component.html index 710ac7856e..a822d22ab4 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/account-list/components/account-list/account-list.component.html +++ b/client/src/app/site/pages/organization/pages/accounts/pages/account-list/components/account-list/account-list.component.html @@ -175,6 +175,10 @@

cloud_upload {{ 'Import' | translate }} + } @if (isMultiSelect) { From 10337fde4c7c42acac72aa03a33701ed2bccfac4 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Thu, 8 Aug 2024 13:56:24 +0200 Subject: [PATCH 06/24] Add gender-controller --- .../gender-controller.service.spec.ts | 16 +++++++++ .../services/gender-controller.service.ts | 33 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.spec.ts create mode 100644 client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.spec.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.spec.ts new file mode 100644 index 0000000000..96f3ff757b --- /dev/null +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { GenderControllerService } from './gender-controller.service'; + +xdescribe(`GenderControllerService`, () => { + let service: GenderControllerService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(GenderControllerService); + }); + + it(`should be created`, () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts new file mode 100644 index 0000000000..b07a15bfe1 --- /dev/null +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts @@ -0,0 +1,33 @@ +import { Injectable } from '@angular/core'; +import { Id } from 'src/app/domain/definitions/key-types'; +import { Identifiable } from 'src/app/domain/interfaces'; +import { Gender } from 'src/app/domain/models/gender/gender'; +import { GenderRepositoryService } from 'src/app/gateways/repositories/gender/gender-repository.service'; +import { BaseController } from 'src/app/site/base/base-controller'; +import { ControllerServiceCollectorService } from 'src/app/site/services/controller-service-collector.service'; + +import { ViewGender } from '../view-models/view-gender'; + +@Injectable({ + providedIn: `root` +}) +export class GenderControllerService extends BaseController { + public constructor( + controllerServiceCollector: ControllerServiceCollectorService, + protected override repo: GenderRepositoryService + ) { + super(controllerServiceCollector, Gender, repo); + } + + public create(...models: Partial[]): Promise { + return this.repo.create(...models); + } + + public update(update: Partial, viewGenderId: Id): Promise { + return this.repo.update(update, viewGenderId); + } + + public delete(...ids: Id[]): Promise { + return this.repo.delete(...ids); + } +} From fcb1fe7c267fb253ba31ea11d80f63d4c9678525 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Fri, 9 Aug 2024 10:44:38 +0200 Subject: [PATCH 07/24] Add list and dialog part to gender-list --- .../gender-list/gender-list.component.html | 110 ++++++++++++++++- .../gender-list/gender-list.component.ts | 111 +++++++++++++++++- .../pages/gender-list/gender-list.module.ts | 11 +- 3 files changed, 228 insertions(+), 4 deletions(-) diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html index 261eed81e8..072cf2a7c6 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html @@ -1 +1,109 @@ -

gender-list works!

+ + +
+

{{ 'Gender' | translate }}

+
+ + + + + + + + + + {{ selectedRows.length }} {{ 'selected' | translate }} + +
+ + +
+
+ {{ gender.name }} +
+
+
+ +
+
+ +
+
+ + + @if (!isMultiSelect) { +
+ +
+ } + @if (isMultiSelect) { +
+ + + + +
+ } +
+ + + +

+ {{ 'Gender' | translate }} +

+ +
+ + + {{ 'Name' | translate }} + + + {{ 'A name is required' | translate }} + + +
+
+ + + + + +
diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts index b0ee1322b6..51e201ddbc 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts @@ -1,4 +1,12 @@ -import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { ChangeDetectionStrategy, Component, TemplateRef, ViewChild } from '@angular/core'; +import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; +import { MatDialog, MatDialogRef } from '@angular/material/dialog'; +import { TranslateService } from '@ngx-translate/core'; +import { infoDialogSettings } from 'src/app/infrastructure/utils/dialog-settings'; +import { BaseListViewComponent } from 'src/app/site/base/base-list-view.component'; + +import { GenderControllerService } from '../../../../services/gender-controller.service'; +import { ViewGender } from '../../../../view-models/view-gender'; @Component({ selector: `os-gender-list`, @@ -6,4 +14,103 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; styleUrl: `./gender-list.component.scss`, changeDetection: ChangeDetectionStrategy.OnPush }) -export class GenderListComponent {} +export class GenderListComponent extends BaseListViewComponent { + @ViewChild(`genderDialog`, { static: true }) + private genderDialog: TemplateRef | null = null; + + private dialogRef: MatDialogRef | null = null; + + /** + * Holds the create form + */ + public genderForm: UntypedFormGroup; + private currentGender: ViewGender; + + public constructor( + protected override translate: TranslateService, + public repo: GenderControllerService, + private dialog: MatDialog, + private formBuilder: UntypedFormBuilder + ) { + super(); + this.setTitle(`Gender`); + this.canMultiSelect = true; + this.genderForm = this.formBuilder.group({ + name: [``, Validators.required] + }); + } + + public createGender(): void { + this.editGender(); + } + + public editGender(genderView?: ViewGender): void { + this.openGenderDialog(genderView); + } + + public openGenderDialog(gender?: ViewGender): void { + this.currentGender = gender; + this.genderForm.reset(); + this.genderForm.get(`name`)!.setValue(gender ? gender.name : ``); + this.dialogRef = this.dialog.open(this.genderDialog!, infoDialogSettings); + this.dialogRef.afterClosed().subscribe(res => { + if (res) { + this.save(); + } + }); + } + + public async deleteGenders(...genders: ViewGender[]): Promise { + console.log(`XXX delete Gender`, genders); + } + + public deleteSelectedGenders(): void { + this.deleteGenders(...this.selectedRows); + } + + /** + * clicking Enter will save automatically + * clicking Escape will cancel the process + * + * @param event has the code + */ + public onKeyDown(event: KeyboardEvent): void { + if (event.key === `Enter`) { + this.save(); + this.dialogRef!.close(); + } + if (event.key === `Escape`) { + this.dialogRef!.close(); + } + } + + private updateGenderHelper(): void { + if (this.currentGender) { + const data = this.genderForm.value; + this.repo.update(data, this.currentGender.id).catch(this.raiseError); + } + } + + private createGenderHelper(): void { + this.repo.create(this.genderForm.value).catch(this.raiseError); + } + + private deleteStructureLevel(gender: ViewGender): void { + this.repo + .delete(gender.id) + //.then(() => this.cd.detectChanges()) + .catch(this.raiseError); + } + + private save(): void { + if (!this.genderForm.value || !this.genderForm.valid) { + return; + } + if (this.currentGender) { + this.updateGenderHelper(); + } else { + this.createGenderHelper(); + } + this.genderForm.reset(); + } +} diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list.module.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list.module.ts index 1d5238f74a..f7ed7d0fe1 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list.module.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/gender-list.module.ts @@ -1,8 +1,12 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatDividerModule } from '@angular/material/divider'; +import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; +import { MatInputModule } from '@angular/material/input'; import { MatMenuModule } from '@angular/material/menu'; import { OpenSlidesTranslationModule } from 'src/app/site/modules/translations'; import { ChipModule } from 'src/app/ui/modules/chip'; @@ -26,7 +30,12 @@ import { GenderListRoutingModule } from './gender-list-routing.module'; MatIconModule, MatMenuModule, MatButtonModule, - MatDividerModule + MatDividerModule, + MatDialogModule, + MatInputModule, + FormsModule, + ReactiveFormsModule, + MatFormFieldModule ] }) export class GenderListModule {} From 9365451a3ba0279c15784d7756ab8718a0de199a Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Fri, 6 Sep 2024 09:22:34 +0200 Subject: [PATCH 08/24] Draft version, add TODO-G for open points --- client/src/app/domain/fieldsets/user.ts | 2 +- .../src/app/domain/models/users/user.constants.ts | 2 +- .../gender/gender-repository.service.ts | 13 +++++++------ .../repositories/organization-repository.service.ts | 3 +-- .../repositories/users/user-repository.service.ts | 6 +++--- .../user-detail-view.component.html | 4 ++-- .../pages/participant-import/definitions/index.ts | 2 +- .../participant-list-filter.service.ts | 5 ++--- .../site/pages/meetings/view-models/view-user.ts | 5 +++++ .../account-import-list.component.ts | 8 +++----- .../pages/account-import/definitions/index.ts | 2 +- .../components/gender-list/gender-list.component.ts | 12 +++++------- .../gender/services/gender-controller.service.ts | 13 ++++++------- .../services/common/account-filter.service.ts | 4 ++-- 14 files changed, 40 insertions(+), 41 deletions(-) diff --git a/client/src/app/domain/fieldsets/user.ts b/client/src/app/domain/fieldsets/user.ts index 5c630d00b7..165b4c4c32 100644 --- a/client/src/app/domain/fieldsets/user.ts +++ b/client/src/app/domain/fieldsets/user.ts @@ -2,7 +2,7 @@ import { BaseSimplifiedModelRequest } from 'src/app/site/services/model-request- export class UserFieldsets { public static readonly FullNameSubscription: BaseSimplifiedModelRequest = { - fieldset: [`title`, `first_name`, `last_name`, `pronoun`, `username`, `gender`, `default_vote_weight`] + fieldset: [`title`, `first_name`, `last_name`, `pronoun`, `username`, `default_vote_weight`, `gender_id`] }; } diff --git a/client/src/app/domain/models/users/user.constants.ts b/client/src/app/domain/models/users/user.constants.ts index 1a9f8af567..c150501d56 100644 --- a/client/src/app/domain/models/users/user.constants.ts +++ b/client/src/app/domain/models/users/user.constants.ts @@ -9,7 +9,7 @@ export const userHeadersAndVerboseNames: { [key in keyof User]?: any } = { email: _(`Email`), member_number: _(`Member number`), pronoun: _(`Pronoun`), - gender: _(`Gender`), + // TODO-G gender: _(`Gender`), username: _(`Username`), default_password: _(`Initial password`), is_active: _(`Active`), diff --git a/client/src/app/gateways/repositories/gender/gender-repository.service.ts b/client/src/app/gateways/repositories/gender/gender-repository.service.ts index 7dec6f007c..f6c4619ea5 100644 --- a/client/src/app/gateways/repositories/gender/gender-repository.service.ts +++ b/client/src/app/gateways/repositories/gender/gender-repository.service.ts @@ -6,6 +6,7 @@ import { BaseRepository } from 'src/app/gateways/repositories/base-repository'; import { ViewGender } from 'src/app/site/pages/organization/pages/accounts/pages/gender/view-models/view-gender'; import { Fieldsets } from 'src/app/site/services/model-request-builder'; +import { Action } from '../../actions'; import { RepositoryServiceCollectorService } from '../repository-service-collector.service'; import { GenderAction } from './gender.action'; @@ -28,21 +29,21 @@ export class GenderRepositoryService extends BaseRepository }; } - public create(...genders: any[]): Promise { + public create(...genders: any[]): Action { const payload = genders; - return this.sendBulkActionToBackend(GenderAction.CREATE, payload); + return this.createAction(GenderAction.CREATE, payload); } - public update(update: any, id: Id): Promise { + public update(update: any, id: Id): Action { const payload = { id, ...update }; - return this.sendActionToBackend(GenderAction.UPDATE, payload); + return this.createAction(GenderAction.UPDATE, payload); } - public delete(...ids: Id[]): Promise { + public delete(...ids: Id[]): Action { const payload = ids.map(id => ({ id })); - return this.sendBulkActionToBackend(GenderAction.DELETE, payload); + return this.createAction(GenderAction.DELETE, payload); } } diff --git a/client/src/app/gateways/repositories/organization-repository.service.ts b/client/src/app/gateways/repositories/organization-repository.service.ts index 4ff8d2d92d..894cb0cece 100644 --- a/client/src/app/gateways/repositories/organization-repository.service.ts +++ b/client/src/app/gateways/repositories/organization-repository.service.ts @@ -44,8 +44,7 @@ export class OrganizationRepositoryService extends BaseRepository { `last_name`, `pronoun`, `username` /* Required! To getShortName */, - `gender`, + `gender_id`, `default_vote_weight`, `is_physical_person`, `is_active`, @@ -222,7 +222,7 @@ export class UserRepositoryService extends BaseRepository { email: update.email, username: update.username, pronoun: update.pronoun, - gender: update.gender + gender_id: update.gender_id }; return this.sendActionToBackend(UserAction.UPDATE_SELF, payload); } @@ -255,7 +255,7 @@ export class UserRepositoryService extends BaseRepository { is_active: partialUser.is_active, is_physical_person: partialUser.is_physical_person, default_password: partialUser.default_password, - gender: partialUser.gender, + gender_id: partialUser.gender_id, email: partialUser.email, default_vote_weight: toDecimal(partialUser.default_vote_weight, false) as any, organization_management_level: partialUser.organization_management_level, diff --git a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html index 424f6587cc..83811f3b93 100644 --- a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html +++ b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html @@ -84,11 +84,11 @@

{{ 'Personal information' | translate }}

{{ 'Gender' | translate }} - - @for (gender of genders; track gender) { + 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 663ee73b74..8c9d5f3e21 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 @@ -21,7 +21,7 @@ export const participantColumns: (keyof GeneralUser)[] = [ `groups`, `number`, `vote_weight`, - `gender`, + // TODO-G `gender`, `pronoun`, `username`, `default_password`, diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-list/services/participant-list-filter/participant-list-filter.service.ts b/client/src/app/site/pages/meetings/pages/participants/pages/participant-list/services/participant-list-filter/participant-list-filter.service.ts index ea956b9e9b..994bfc64c1 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-list/services/participant-list-filter/participant-list-filter.service.ts +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-list/services/participant-list-filter/participant-list-filter.service.ts @@ -2,7 +2,6 @@ import { Injectable } from '@angular/core'; import { marker as _ } from '@colsen1991/ngx-translate-extract-marker'; import { TranslateService } from '@ngx-translate/core'; import { Permission } from 'src/app/domain/definitions/permission'; -import { GENDER_FITLERABLE, GENDERS } from 'src/app/domain/models/users/user'; import { OsFilter, OsHideFilterSetting } from 'src/app/site/base/base-filter.service'; import { BaseMeetingFilterListService } from 'src/app/site/pages/meetings/base/base-meeting-filter-list.service'; import { MeetingActiveFiltersService } from 'src/app/site/pages/meetings/services/meeting-active-filters.service'; @@ -131,7 +130,7 @@ export class ParticipantListFilterService extends BaseMeetingFilterListService /* implements Searchable */ { } } + public get gender(): string { + // TODO-G + return `TEST`; + } + public get delegationType(): DelegationType { if (this.isVoteRightDelegated) { return DelegationType.Transferred; 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 6246b34338..300a90436a 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 @@ -19,8 +19,8 @@ export class AccountImportListComponent extends BaseViaBackendImportListComponen public columns: ImportListHeaderDefinition[] = this.possibleFields.map(header => ({ property: header, label: (accountHeadersAndVerboseNames)[header], - isTableColumn: true, - customInfo: header === `gender` ? this.getTranslatedGenderInfoObservable() : undefined + isTableColumn: true + // TODO-G customInfo: header === `gender` ? this.getTranslatedGenderInfoObservable() : undefined })); public constructor( @@ -32,8 +32,6 @@ export class AccountImportListComponent extends BaseViaBackendImportListComponen } private getTranslatedGenderInfoObservable(): Observable { - return this.translate - .get(`Possible options`) - .pipe(map(framework => framework + `: ` + this.orgaSettings.instant(`genders`).join(`, `))); + return this.translate.get(`Possible options`).pipe(map(framework => framework)); // TODO-G + `: ` + this.orgaSettings.instant(`genders`).join(`, `))); } } 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 5a12b341ce..6fbb0d5ac9 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 @@ -14,7 +14,7 @@ export const accountColumns: (keyof User)[] = [ `email`, `member_number`, `default_vote_weight`, - `gender`, + // TODO-G `gender`, `pronoun`, `username`, `default_password`, diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts index 51e201ddbc..faceb6b6ee 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts @@ -87,19 +87,17 @@ export class GenderListComponent extends BaseListViewComponent { private updateGenderHelper(): void { if (this.currentGender) { const data = this.genderForm.value; - this.repo.update(data, this.currentGender.id).catch(this.raiseError); + this.repo.update(data, this.currentGender.id); } } private createGenderHelper(): void { - this.repo.create(this.genderForm.value).catch(this.raiseError); + this.repo.create(this.genderForm.value); } - private deleteStructureLevel(gender: ViewGender): void { - this.repo - .delete(gender.id) - //.then(() => this.cd.detectChanges()) - .catch(this.raiseError); + private deleteGender(gender: ViewGender): void { + this.repo.delete(gender.id); + //.then(() => this.cd.detectChanges()) } private save(): void { diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts index b07a15bfe1..8895638263 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts @@ -1,6 +1,5 @@ import { Injectable } from '@angular/core'; import { Id } from 'src/app/domain/definitions/key-types'; -import { Identifiable } from 'src/app/domain/interfaces'; import { Gender } from 'src/app/domain/models/gender/gender'; import { GenderRepositoryService } from 'src/app/gateways/repositories/gender/gender-repository.service'; import { BaseController } from 'src/app/site/base/base-controller'; @@ -19,15 +18,15 @@ export class GenderControllerService extends BaseController super(controllerServiceCollector, Gender, repo); } - public create(...models: Partial[]): Promise { - return this.repo.create(...models); + public create(...models: Partial[]): void { + this.repo.create(...models).resolve(); } - public update(update: Partial, viewGenderId: Id): Promise { - return this.repo.update(update, viewGenderId); + public update(update: Partial, viewGenderId: Id): void { + this.repo.update(update, viewGenderId).resolve(); } - public delete(...ids: Id[]): Promise { - return this.repo.delete(...ids); + public delete(...ids: Id[]): void { + this.repo.delete(...ids).resolve(); } } diff --git a/client/src/app/site/pages/organization/pages/accounts/services/common/account-filter.service.ts b/client/src/app/site/pages/organization/pages/accounts/services/common/account-filter.service.ts index db2105bf78..758453fdfd 100644 --- a/client/src/app/site/pages/organization/pages/accounts/services/common/account-filter.service.ts +++ b/client/src/app/site/pages/organization/pages/accounts/services/common/account-filter.service.ts @@ -131,7 +131,7 @@ export class AccountFilterService extends BaseFilterListService { { condition: [false, null], label: _(`Is no natural person`) } ] }, - { + /* TODO-G { property: `gender`, label: _(`Gender`), options: [ @@ -141,7 +141,7 @@ export class AccountFilterService extends BaseFilterListService { { condition: `non-binary`, label: _(`non-binary`) }, { condition: null, label: _(`not specified`) } ] - }, + }, */ { property: `hasEmail`, label: _(`Email address`), From 7ab969da096db35e04b6f639baee7da017186ed8 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Fri, 6 Sep 2024 11:17:47 +0200 Subject: [PATCH 09/24] add organization/gender relation and app config --- .../definitions/relations/relations.ts | 8 ++++++++ .../services/app-load.service.ts | 4 +++- .../pages/accounts/accounts.subscription.ts | 3 ++- .../account-main/account-main.component.ts | 9 +++++++++ .../accounts/pages/gender/genders.config.ts | 16 ++++++++++++++++ .../view-models/view-organization.ts | 2 ++ 6 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 client/src/app/site/pages/organization/pages/accounts/pages/gender/genders.config.ts diff --git a/client/src/app/infrastructure/definitions/relations/relations.ts b/client/src/app/infrastructure/definitions/relations/relations.ts index ed1e487918..9aa5211d38 100644 --- a/client/src/app/infrastructure/definitions/relations/relations.ts +++ b/client/src/app/infrastructure/definitions/relations/relations.ts @@ -20,6 +20,7 @@ import { import { ViewPollCandidate } from 'src/app/site/pages/meetings/pages/polls/view-models/view-poll-candidate'; import { ViewPollCandidateList } from 'src/app/site/pages/meetings/pages/polls/view-models/view-poll-candidate-list'; import { ViewMeetingUser } from 'src/app/site/pages/meetings/view-models/view-meeting-user'; +import { ViewGender } from 'src/app/site/pages/organization/pages/accounts/pages/gender/view-models/view-gender'; import { ViewResource } from 'src/app/site/pages/organization/pages/resources'; import { BaseViewModel, ViewModelConstructor } from '../../../site/base/base-view-model'; @@ -165,6 +166,13 @@ export const RELATIONS: Relation[] = [ AField: `theme`, BField: `theme_for_organization` }), + ...makeM2O({ + OViewModel: ViewOrganization, + MViewModel: ViewGender, + OField: `genders`, + MField: `organization`, + isFullList: true + }), // ########## Organization tags ...makeGenericM2M({ viewModel: ViewOrganizationTag, diff --git a/client/src/app/openslides-main-module/services/app-load.service.ts b/client/src/app/openslides-main-module/services/app-load.service.ts index a4ee678f2b..89bc53c8c9 100644 --- a/client/src/app/openslides-main-module/services/app-load.service.ts +++ b/client/src/app/openslides-main-module/services/app-load.service.ts @@ -16,6 +16,7 @@ import { MotionsAppConfig } from 'src/app/site/pages/meetings/pages/motions'; import { PollsAppConfig } from 'src/app/site/pages/meetings/pages/polls/polls.config'; import { ProjectorAppConfig } from 'src/app/site/pages/meetings/pages/projectors/projector.config'; import { MainMenuService } from 'src/app/site/pages/meetings/services/main-menu.service'; +import { GendersAppConfig } from 'src/app/site/pages/organization/pages/accounts/pages/gender/genders.config'; import { CollectionMapperService } from 'src/app/site/services/collection-mapper.service'; import { FallbackRoutesService } from 'src/app/site/services/fallback-routes.service'; import { ModelRequestBuilderService } from 'src/app/site/services/model-request-builder'; @@ -53,7 +54,8 @@ const appConfigs: AppConfig[] = [ MeetingSettingsAppConfig, ChatAppConfig, ActionWorkerAppConfig, - MeetingUserAppConfig + MeetingUserAppConfig, + GendersAppConfig ]; @Injectable({ diff --git a/client/src/app/site/pages/organization/pages/accounts/accounts.subscription.ts b/client/src/app/site/pages/organization/pages/accounts/accounts.subscription.ts index 6f4a0ae2ee..05a6e96736 100644 --- a/client/src/app/site/pages/organization/pages/accounts/accounts.subscription.ts +++ b/client/src/app/site/pages/organization/pages/accounts/accounts.subscription.ts @@ -18,7 +18,8 @@ export const getAccountDetailSubscriptionConfig: SubscriptionConfigGenerator = ( idField: `meeting_ids`, follow: [{ idField: `group_ids`, fieldset: [`name`], isFullList: false }], fieldset: [`name`, `committee_id`] - } + }, + { idField: `gender_id`, fieldset: [`name`] } ] }, subscriptionName: ACCOUNT_DETAIL_SUBSCRIPTION_NAME diff --git a/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts b/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts index b173d852e4..cee19a0840 100644 --- a/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts @@ -80,6 +80,11 @@ export class AccountMainComponent extends BaseModelRequestHandlerComponent { fieldset: [`name`] } ] + }, + { + idField: `gender_ids`, + fieldset: [`name`], + isFulllist: true } ] }, @@ -103,6 +108,10 @@ export class AccountMainComponent extends BaseModelRequestHandlerComponent { fieldset: [`name`] } ] + }, + { + idField: `gender_id`, + fieldset: [`name`] } ] }, diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/genders.config.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/genders.config.ts new file mode 100644 index 0000000000..d6e066b207 --- /dev/null +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/genders.config.ts @@ -0,0 +1,16 @@ +import { Gender } from 'src/app/domain/models/gender/gender'; +import { GenderRepositoryService } from 'src/app/gateways/repositories/gender/gender-repository.service'; +import { AppConfig } from 'src/app/infrastructure/definitions/app-config'; + +import { ViewGender } from './view-models/view-gender'; + +export const GendersAppConfig: AppConfig = { + name: `gender`, + models: [ + { + model: Gender, + viewModel: ViewGender, + repository: GenderRepositoryService + } + ] +}; diff --git a/client/src/app/site/pages/organization/view-models/view-organization.ts b/client/src/app/site/pages/organization/view-models/view-organization.ts index 1b6fc3399e..eb7d08ced6 100644 --- a/client/src/app/site/pages/organization/view-models/view-organization.ts +++ b/client/src/app/site/pages/organization/view-models/view-organization.ts @@ -4,6 +4,7 @@ import { BaseViewModel, ViewModelRelations } from '../../../base/base-view-model import { ViewMediafile } from '../../meetings/pages/mediafiles'; import { ViewMeeting } from '../../meetings/view-models/view-meeting'; import { ViewUser } from '../../meetings/view-models/view-user'; +import { ViewGender } from '../pages/accounts/pages/gender/view-models/view-gender'; import { ViewCommittee } from '../pages/committees'; import { ViewTheme } from '../pages/designs'; import { ViewOrganizationTag } from '../pages/organization-tags'; @@ -27,5 +28,6 @@ interface IOrganizationRelations { theme: ViewTheme; themes: ViewTheme[]; users: ViewUser[]; + genders: ViewGender[]; } export interface ViewOrganization extends Organization, ViewModelRelations {} From 1e9fb92dc09b64e3eba01f75731450fc10dc15ce Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Fri, 6 Sep 2024 13:39:47 +0200 Subject: [PATCH 10/24] Update gender-list deleteGenders --- .../components/gender-list/gender-list.component.ts | 9 +++++---- .../pages/gender/services/gender-controller.service.ts | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts index faceb6b6ee..49c398da9a 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, TemplateRef, ViewChild } from '@angular/core'; +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, TemplateRef, ViewChild } from '@angular/core'; import { UntypedFormBuilder, UntypedFormGroup, Validators } from '@angular/forms'; import { MatDialog, MatDialogRef } from '@angular/material/dialog'; import { TranslateService } from '@ngx-translate/core'; @@ -30,7 +30,8 @@ export class GenderListComponent extends BaseListViewComponent { protected override translate: TranslateService, public repo: GenderControllerService, private dialog: MatDialog, - private formBuilder: UntypedFormBuilder + private formBuilder: UntypedFormBuilder, + private cd: ChangeDetectorRef ) { super(); this.setTitle(`Gender`); @@ -60,8 +61,8 @@ export class GenderListComponent extends BaseListViewComponent { }); } - public async deleteGenders(...genders: ViewGender[]): Promise { - console.log(`XXX delete Gender`, genders); + public async deleteGenders(...genders: ViewGender[]): Promise { + return this.repo.delete(...genders.map(g => g.id)).then(() => this.cd.detectChanges()); } public deleteSelectedGenders(): void { diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts index 8895638263..9e3e895f97 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service.ts @@ -26,7 +26,7 @@ export class GenderControllerService extends BaseController this.repo.update(update, viewGenderId).resolve(); } - public delete(...ids: Id[]): void { - this.repo.delete(...ids).resolve(); + public delete(...ids: Id[]): Promise { + return this.repo.delete(...ids).resolve(); } } From 0cbd30c38df108de55011977473e164a38fcd437 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Mon, 9 Sep 2024 13:27:08 +0200 Subject: [PATCH 11/24] Link user and gender, allow selection in user-detail --- .../definitions/relations/relations.ts | 6 ++++++ .../user-detail-view/user-detail-view.component.html | 12 ++++++------ .../user-detail-view/user-detail-view.component.ts | 12 ++++++++---- .../list-of-speakers/view-models/view-speaker.ts | 2 +- .../app/site/pages/meetings/view-models/view-user.ts | 7 ++----- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/client/src/app/infrastructure/definitions/relations/relations.ts b/client/src/app/infrastructure/definitions/relations/relations.ts index 9aa5211d38..8deffec244 100644 --- a/client/src/app/infrastructure/definitions/relations/relations.ts +++ b/client/src/app/infrastructure/definitions/relations/relations.ts @@ -280,6 +280,12 @@ export const RELATIONS: Relation[] = [ AField: `meeting_users`, BField: `structure_levels` }), + ...makeM2O({ + MViewModel: ViewUser, + OViewModel: ViewGender, + MField: `gender`, + OField: `users` + }), // Vote delegations // vote_delegated_to_id -> vote_delegations_from_ids { diff --git a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html index 83811f3b93..2a16416f50 100644 --- a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html +++ b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html @@ -82,13 +82,13 @@

{{ 'Personal information' | translate }}

{{ 'Gender' | translate }} - + - - + } @@ -230,7 +230,7 @@

{{ 'Name' | translate }}

@if (user.gender) {

{{ 'Gender' | translate }}

- {{ user.gender | translate }} + {{ user.gender?.name | translate }}
} diff --git a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts index 5062731ff4..1008c40427 100644 --- a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts +++ b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts @@ -21,10 +21,11 @@ import { } from '@angular/forms'; import { Subscription } from 'rxjs'; import { createEmailValidator } from 'src/app/infrastructure/utils/validators/email'; +import { GenderControllerService } from 'src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service'; +import { ViewGender } from 'src/app/site/pages/organization/pages/accounts/pages/gender/view-models/view-gender'; import { OperatorService } from 'src/app/site/services/operator.service'; import { BaseUiComponent } from 'src/app/ui/base/base-ui-component'; -import { GENDERS } from '../../../../../domain/models/users/user'; import { ViewUser } from '../../../../../site/pages/meetings/view-models/view-user'; import { OneOfValidator } from '../../validators'; @@ -123,12 +124,14 @@ export class UserDetailViewComponent extends BaseUiComponent implements OnInit, public personalInfoForm!: UntypedFormGroup; - public genders = GENDERS; - public get isSelf(): boolean { return this.operator.operatorId === this._user?.id; } + public get genders(): ViewGender[] { + return this.genderRepo.getViewModelList(); + } + private set _initialState(state: any | null) { this._initialStateString = JSON.stringify(state); } @@ -153,6 +156,7 @@ export class UserDetailViewComponent extends BaseUiComponent implements OnInit, public constructor( private fb: UntypedFormBuilder, private operator: OperatorService, + private genderRepo: GenderControllerService, private cd: ChangeDetectorRef ) { super(); @@ -306,7 +310,7 @@ export class UserDetailViewComponent extends BaseUiComponent implements OnInit, title: [``], first_name: [``], last_name: [``], - gender: [``], + gender_id: [``], email: [``, [createEmailValidator()]], last_email_sent: [``], default_password: [``], diff --git a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/view-models/view-speaker.ts b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/view-models/view-speaker.ts index 2eaf8f8403..a548875f9d 100644 --- a/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/view-models/view-speaker.ts +++ b/client/src/app/site/pages/meetings/pages/agenda/modules/list-of-speakers/view-models/view-speaker.ts @@ -117,7 +117,7 @@ export class ViewSpeaker extends BaseHasMeetingUserViewModel { } public get gender(): string { - return this.user ? this.user.gender : ``; + return this.user ? this.user.gender?.name : ``; } public get contentType(): string { diff --git a/client/src/app/site/pages/meetings/view-models/view-user.ts b/client/src/app/site/pages/meetings/view-models/view-user.ts index 84752f602c..8f41ae5f5c 100644 --- a/client/src/app/site/pages/meetings/view-models/view-user.ts +++ b/client/src/app/site/pages/meetings/view-models/view-user.ts @@ -2,6 +2,7 @@ import { User } from 'src/app/domain/models/users/user'; import { BaseViewModel, ViewModelRelations } from 'src/app/site/base/base-view-model'; import { Id } from '../../../../domain/definitions/key-types'; +import { ViewGender } from '../../organization/pages/accounts/pages/gender/view-models/view-gender'; import { ViewCommittee } from '../../organization/pages/committees'; import { ViewOrganization } from '../../organization/view-models/view-organization'; import { ViewGroup } from '../pages/participants/modules/groups/view-models/view-group'; @@ -75,11 +76,6 @@ export class ViewUser extends BaseViewModel /* implements Searchable */ { } } - public get gender(): string { - // TODO-G - return `TEST`; - } - public get delegationType(): DelegationType { if (this.isVoteRightDelegated) { return DelegationType.Transferred; @@ -343,6 +339,7 @@ interface IUserRelations { options: ViewOption[]; votes: ViewVote[]; poll_candidates: ViewPollCandidate[]; + gender?: ViewGender; } export interface ViewUser extends User, ViewModelRelations {} From 707ac7920b9c881c0a7246407bfdf607cf6d45d2 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Mon, 9 Sep 2024 14:40:14 +0200 Subject: [PATCH 12/24] Add subscription to gender list --- .../participant-detail.component.ts | 2 ++ .../participants/participants.subscription.ts | 12 ++++++++++- .../pages/gender/gender.subscription.ts | 20 +++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 client/src/app/site/pages/organization/pages/accounts/pages/gender/gender.subscription.ts diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts index 4fb19bee8b..3c744b7d85 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts @@ -1,5 +1,6 @@ import { Component } from '@angular/core'; import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; +import { getGenderListSubscriptionConfig } from 'src/app/site/pages/organization/pages/accounts/pages/gender/gender.subscription'; import { getParticipantDetailSubscription } from '../../../../participants.subscription'; @@ -13,6 +14,7 @@ export class ParticipantDetailComponent extends BaseModelRequestHandlerComponent if (params[`id`]) { this.subscribeTo(getParticipantDetailSubscription(+params[`id`]), { hideWhenDestroyed: true }); } + this.subscribeTo(getGenderListSubscriptionConfig()); } protected override onParamsChanged(params: any, oldParams: any): void { diff --git a/client/src/app/site/pages/meetings/pages/participants/participants.subscription.ts b/client/src/app/site/pages/meetings/pages/participants/participants.subscription.ts index 5187a92018..443f7aa2ae 100644 --- a/client/src/app/site/pages/meetings/pages/participants/participants.subscription.ts +++ b/client/src/app/site/pages/meetings/pages/participants/participants.subscription.ts @@ -89,7 +89,13 @@ export const getParticipantMinimalSubscriptionConfig: SubscriptionConfigGenerato { idField: `user_id`, fieldset: `participantListMinimal`, - additionalFields: [`is_present_in_meeting_ids`] + additionalFields: [`is_present_in_meeting_ids`], + follow: [ + { + idField: `gender_id`, + fieldset: [`name`] + } + ] }, { idField: `structure_level_ids`, fieldset: [`name`] } ] @@ -108,6 +114,10 @@ export const getParticipantDetailSubscription: SubscriptionConfigGenerator = (id { idField: `meeting_user_ids`, fieldset: DEFAULT_FIELDSET + }, + { + idField: `gender_id`, + fieldset: [`name`] } ] }, diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/gender.subscription.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/gender.subscription.ts new file mode 100644 index 0000000000..46095f87e9 --- /dev/null +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/gender.subscription.ts @@ -0,0 +1,20 @@ +import { SubscriptionConfigGenerator } from 'src/app/domain/interfaces/subscription-config'; + +import { ORGANIZATION_ID } from '../../../../services/organization.service'; +import { ViewOrganization } from '../../../../view-models/view-organization'; + +export const GENDER_LIST_SUBSCRIPTION = `gender_list`; + +export const getGenderListSubscriptionConfig: SubscriptionConfigGenerator = () => ({ + modelRequest: { + viewModelCtor: ViewOrganization, + ids: [ORGANIZATION_ID], + follow: [ + { + idField: `gender_ids`, + fieldset: [`name`] + } + ] + }, + subscriptionName: GENDER_LIST_SUBSCRIPTION +}); From da72300be104aea6768f7b3bec32658ff980180d Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Tue, 10 Sep 2024 13:42:40 +0200 Subject: [PATCH 13/24] Add gender delete prompt --- .../gender-list/gender-list.component.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts index 49c398da9a..719d6e1671 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts @@ -4,6 +4,7 @@ import { MatDialog, MatDialogRef } from '@angular/material/dialog'; import { TranslateService } from '@ngx-translate/core'; import { infoDialogSettings } from 'src/app/infrastructure/utils/dialog-settings'; import { BaseListViewComponent } from 'src/app/site/base/base-list-view.component'; +import { PromptService } from 'src/app/ui/modules/prompt-dialog'; import { GenderControllerService } from '../../../../services/gender-controller.service'; import { ViewGender } from '../../../../view-models/view-gender'; @@ -31,7 +32,8 @@ export class GenderListComponent extends BaseListViewComponent { public repo: GenderControllerService, private dialog: MatDialog, private formBuilder: UntypedFormBuilder, - private cd: ChangeDetectorRef + private cd: ChangeDetectorRef, + private promptService: PromptService ) { super(); this.setTitle(`Gender`); @@ -62,7 +64,14 @@ export class GenderListComponent extends BaseListViewComponent { } public async deleteGenders(...genders: ViewGender[]): Promise { - return this.repo.delete(...genders.map(g => g.id)).then(() => this.cd.detectChanges()); + const title = + genders.length === 1 + ? this.translate.instant(`Are you sure you want to delete this gender?`) + : this.translate.instant(`Are you sure you want to delete all selected genders?`); + const content = genders.length === 1 ? genders[0].name : ``; + if (await this.promptService.open(title, content)) { + return this.repo.delete(...genders.map(g => g.id)).then(() => this.cd.detectChanges()); + } } public deleteSelectedGenders(): void { @@ -96,11 +105,6 @@ export class GenderListComponent extends BaseListViewComponent { this.repo.create(this.genderForm.value); } - private deleteGender(gender: ViewGender): void { - this.repo.delete(gender.id); - //.then(() => this.cd.detectChanges()) - } - private save(): void { if (!this.genderForm.value || !this.genderForm.valid) { return; From 38fce9623ff59c77eaa3864b7722003a205b547e Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Tue, 10 Sep 2024 14:11:25 +0200 Subject: [PATCH 14/24] Allow sort accounts by gender --- client/src/app/site/pages/meetings/view-models/view-user.ts | 4 ++++ .../account-list-sort.service/account-sort.service.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/app/site/pages/meetings/view-models/view-user.ts b/client/src/app/site/pages/meetings/view-models/view-user.ts index 8f41ae5f5c..2a6f32f6e1 100644 --- a/client/src/app/site/pages/meetings/view-models/view-user.ts +++ b/client/src/app/site/pages/meetings/view-models/view-user.ts @@ -109,6 +109,10 @@ export class ViewUser extends BaseViewModel /* implements Searchable */ { return !!this.member_number; } + public get gender_name(): string { + return this.gender?.name ?? ``; + } + // Will be set by the repository public getName!: () => string; public getShortName!: () => string; diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/account-list/services/account-list-sort.service/account-sort.service.ts b/client/src/app/site/pages/organization/pages/accounts/pages/account-list/services/account-list-sort.service/account-sort.service.ts index 18cd39a820..a4351d3e94 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/account-list/services/account-list-sort.service/account-sort.service.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/account-list/services/account-list-sort.service/account-sort.service.ts @@ -21,7 +21,7 @@ export class AccountSortService extends BaseSortListService { { property: `member_number`, label: _(`Membership number`) }, { property: `is_active`, label: _(`Is active`) }, { property: `default_vote_weight`, label: _(`Vote weight`) }, - { property: `gender`, label: _(`Gender`) }, + { property: `gender_name`, label: _(`Gender`) }, { property: `id`, label: _(`Sequential number`) }, { property: `numberOfMeetings`, label: _(`Amount of meetings`), baseKeys: [`meeting_ids`] }, { property: `last_email_sent`, label: _(`Last email sent`) }, From 7215080f03abd80f8c5c25429ef63d43962f7c40 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Tue, 10 Sep 2024 14:33:22 +0200 Subject: [PATCH 15/24] Add gender filter options to account list --- .../services/common/account-filter.service.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/client/src/app/site/pages/organization/pages/accounts/services/common/account-filter.service.ts b/client/src/app/site/pages/organization/pages/accounts/services/common/account-filter.service.ts index dfdea34440..4ee1462367 100644 --- a/client/src/app/site/pages/organization/pages/accounts/services/common/account-filter.service.ts +++ b/client/src/app/site/pages/organization/pages/accounts/services/common/account-filter.service.ts @@ -10,6 +10,8 @@ import { ActiveFiltersService } from 'src/app/site/services/active-filters.servi import { OperatorService } from 'src/app/site/services/operator.service'; import { UserControllerService } from 'src/app/site/services/user-controller.service'; +import { GenderControllerService } from '../../pages/gender/services/gender-controller.service'; + type Email = string; type Name = string; @@ -24,6 +26,12 @@ export class AccountFilterService extends BaseFilterListService { private userNameMap = new Map(); private userInMeetingMap = new Map(); + private genderFilterOption: OsFilter = { + property: `gender_id`, + label: _(`Gender`), + options: [] + }; + /** * @return Observable data for the filtered output subject */ @@ -55,13 +63,19 @@ export class AccountFilterService extends BaseFilterListService { store: ActiveFiltersService, private operator: OperatorService, private controller: UserControllerService, - private meetingRepo: MeetingControllerService + private meetingRepo: MeetingControllerService, + private genderRepo: GenderControllerService ) { super(store); this.controller.getViewModelListObservable().subscribe(users => { this.updateUserMaps(users); }); + this.updateFilterForRepo({ + repo: genderRepo, + filter: this.genderFilterOption, + noneOptionLabel: _(`not specified`) + }); } public filterMeeting(id: Id): void { @@ -131,17 +145,7 @@ export class AccountFilterService extends BaseFilterListService { { condition: [false, null], label: _(`Is no natural person`) } ] }, - /* TODO-G { - property: `gender`, - label: _(`Gender`), - options: [ - { condition: `female`, label: _(`female`) }, - { condition: `male`, label: _(`male`) }, - { condition: `diverse`, label: _(`diverse`) }, - { condition: `non-binary`, label: _(`non-binary`) }, - { condition: null, label: _(`not specified`) } - ] - }, */ + this.genderFilterOption, { property: `hasEmail`, label: _(`Email address`), From 27e0d379795dba8e60e519821a3e4602c54c2c31 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Tue, 10 Sep 2024 14:56:28 +0200 Subject: [PATCH 16/24] Add gender filter/sort to participant list --- .../participant-list-filter.service.ts | 25 +++++++------ .../participant-list-sort.service.ts | 1 + .../participants/participants.subscription.ts | 36 +++++++++++-------- 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-list/services/participant-list-filter/participant-list-filter.service.ts b/client/src/app/site/pages/meetings/pages/participants/pages/participant-list/services/participant-list-filter/participant-list-filter.service.ts index ba7165df05..59f39b1c88 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-list/services/participant-list-filter/participant-list-filter.service.ts +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-list/services/participant-list-filter/participant-list-filter.service.ts @@ -7,6 +7,7 @@ import { MeetingActiveFiltersService } from 'src/app/site/pages/meetings/service import { MeetingSettingsService } from 'src/app/site/pages/meetings/services/meeting-settings.service'; import { DelegationType } from 'src/app/site/pages/meetings/view-models/delegation-type'; import { ViewUser } from 'src/app/site/pages/meetings/view-models/view-user'; +import { GenderControllerService } from 'src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service'; import { OperatorService } from 'src/app/site/services/operator.service'; import { GroupControllerService } from '../../../../modules/groups/services/group-controller.service'; @@ -34,6 +35,12 @@ export class ParticipantListFilterService extends BaseMeetingFilterListService = { + property: `gender_id`, + label: _(`Gender`), + options: [] + }; + private _voteWeightEnabled: boolean; private _voteDelegationEnabled: boolean; @@ -41,6 +48,7 @@ export class ParticipantListFilterService extends BaseMeetingFilterListService (this._voteWeightEnabled = value)); this.meetingSettings .get(`users_enable_vote_delegations`) @@ -128,17 +141,7 @@ export class ParticipantListFilterService extends BaseMeetingFilterListService { { property: [`last_name`, `first_name`], label: _(`Surname`) }, { property: `is_present_in_meeting_ids`, label: _(`Presence`) }, { property: `member_number`, label: _(`Membership number`) }, + { property: `gender_name`, label: _(`Gender`) }, { property: `is_active`, label: _(`Is active`) }, { property: `is_physical_person`, label: _(`Is a natural person`) }, { property: `number`, label: _(`Participant number`), foreignBaseKeys: { meeting_user: [`number`] } }, diff --git a/client/src/app/site/pages/meetings/pages/participants/participants.subscription.ts b/client/src/app/site/pages/meetings/pages/participants/participants.subscription.ts index 443f7aa2ae..66709e2d1d 100644 --- a/client/src/app/site/pages/meetings/pages/participants/participants.subscription.ts +++ b/client/src/app/site/pages/meetings/pages/participants/participants.subscription.ts @@ -62,20 +62,28 @@ export const getParticipantIsPresentSubscriptionConfig: SubscriptionConfigGenera subscriptionName: PARTICIPANT_IS_PRESENT_LIST_SUBSCRIPTION }); -export const getParticipantListSubscriptionConfig: SubscriptionConfigGenerator = (id: Id) => ({ - modelRequest: { - viewModelCtor: ViewMeeting, - ids: [id], - follow: [ - { - idField: `meeting_user_ids`, - fieldset: `participantListMinimal`, - follow: [{ idField: `user_id`, fieldset: `participantList` }] - } - ] - }, - subscriptionName: PARTICIPANT_LIST_SUBSCRIPTION -}); +export const getParticipantListSubscriptionConfig: SubscriptionConfigGenerator = (id: Id) => { + return { + modelRequest: { + viewModelCtor: ViewMeeting, + ids: [id], + follow: [ + { + idField: `meeting_user_ids`, + fieldset: `participantListMinimal`, + follow: [ + { + idField: `user_id`, + fieldset: `participantList`, + follow: [{ idField: `gender_id`, fieldset: [`name`] }] + } + ] + } + ] + }, + subscriptionName: PARTICIPANT_LIST_SUBSCRIPTION + }; +}; export const getParticipantMinimalSubscriptionConfig: SubscriptionConfigGenerator = (id: Id) => ({ modelRequest: { From 7336de4d59fc2380c828b736cebc387f952cd6b9 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Wed, 11 Sep 2024 08:10:25 +0200 Subject: [PATCH 17/24] Update account and participant import (gender) --- client/src/app/domain/models/users/user.constants.ts | 4 ++-- .../pages/participant-import/definitions/index.ts | 2 +- .../account-import-list/account-import-list.component.ts | 6 ------ .../accounts/pages/account-import/definitions/index.ts | 6 +++--- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/client/src/app/domain/models/users/user.constants.ts b/client/src/app/domain/models/users/user.constants.ts index 2f79b2672c..aac477bdea 100644 --- a/client/src/app/domain/models/users/user.constants.ts +++ b/client/src/app/domain/models/users/user.constants.ts @@ -2,14 +2,14 @@ import { marker as _ } from '@colsen1991/ngx-translate-extract-marker'; import { User } from './user'; -export const userHeadersAndVerboseNames: { [key in keyof User]?: any } = { +export const userHeadersAndVerboseNames: { [key in keyof User | 'gender']?: any } = { title: _(`Title`), first_name: _(`Given name`), last_name: _(`Surname`), email: _(`Email`), member_number: _(`Membership number`), pronoun: _(`Pronoun`), - // TODO-G gender: _(`Gender`), + gender: _(`Gender`), username: _(`Username`), default_password: _(`Initial password`), is_active: _(`Active`), 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 8c9d5f3e21..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 @@ -21,7 +21,7 @@ export const participantColumns: (keyof GeneralUser)[] = [ `groups`, `number`, `vote_weight`, - // TODO-G `gender`, + `gender`, `pronoun`, `username`, `default_password`, 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 300a90436a..5e90daee76 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 @@ -1,6 +1,5 @@ import { Component } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; -import { map, Observable } from 'rxjs'; import { BaseViaBackendImportListComponent } from 'src/app/site/base/base-via-backend-import-list.component'; import { OrganizationSettingsService } from 'src/app/site/pages/organization/services/organization-settings.service'; import { ImportListHeaderDefinition } from 'src/app/ui/modules/import-list'; @@ -20,7 +19,6 @@ export class AccountImportListComponent extends BaseViaBackendImportListComponen property: header, label: (accountHeadersAndVerboseNames)[header], isTableColumn: true - // TODO-G customInfo: header === `gender` ? this.getTranslatedGenderInfoObservable() : undefined })); public constructor( @@ -30,8 +28,4 @@ export class AccountImportListComponent extends BaseViaBackendImportListComponen ) { super(importer); } - - private getTranslatedGenderInfoObservable(): Observable { - return this.translate.get(`Possible options`).pipe(map(framework => framework)); // TODO-G + `: ` + this.orgaSettings.instant(`genders`).join(`, `))); - } } 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 6fbb0d5ac9..a4b9dae215 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,19 +2,19 @@ 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 } = { +export const accountHeadersAndVerboseNames: { [key in keyof User | 'gender']?: any } = { ...userHeadersAndVerboseNames, default_vote_weight: _(`Vote weight`) }; -export const accountColumns: (keyof User)[] = [ +export const accountColumns: (keyof User | 'gender')[] = [ `title`, `first_name`, `last_name`, `email`, `member_number`, `default_vote_weight`, - // TODO-G `gender`, + `gender`, `pronoun`, `username`, `default_password`, From ecac6879d5558f6bad06c19267acb28fcebe947a Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Fri, 13 Sep 2024 11:02:01 +0200 Subject: [PATCH 18/24] Use repo-search-selector and update subscriptions --- .../user-detail-view.component.html | 14 ++++++-------- .../user-detail-view/user-detail-view.component.ts | 8 +++----- .../user-components/user-components.module.ts | 2 ++ .../participant-detail.component.ts | 2 -- .../account-main/account-main.component.ts | 13 ++++--------- .../repo-search-selector.component.ts | 5 +++++ 6 files changed, 20 insertions(+), 24 deletions(-) diff --git a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html index 2a16416f50..89bf0ecb00 100644 --- a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html +++ b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.html @@ -82,14 +82,12 @@

{{ 'Personal information' | translate }}

{{ 'Gender' | translate }} - - - - @for (gender of genders; track gender.name) { - - {{ gender.name | translate }} - - } - + diff --git a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts index 1008c40427..d91d12e30a 100644 --- a/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts +++ b/client/src/app/site/modules/user-components/components/user-detail-view/user-detail-view.component.ts @@ -21,8 +21,8 @@ import { } from '@angular/forms'; import { Subscription } from 'rxjs'; import { createEmailValidator } from 'src/app/infrastructure/utils/validators/email'; +import { getGenderListSubscriptionConfig } from 'src/app/site/pages/organization/pages/accounts/pages/gender/gender.subscription'; import { GenderControllerService } from 'src/app/site/pages/organization/pages/accounts/pages/gender/services/gender-controller.service'; -import { ViewGender } from 'src/app/site/pages/organization/pages/accounts/pages/gender/view-models/view-gender'; import { OperatorService } from 'src/app/site/services/operator.service'; import { BaseUiComponent } from 'src/app/ui/base/base-ui-component'; @@ -128,9 +128,7 @@ export class UserDetailViewComponent extends BaseUiComponent implements OnInit, return this.operator.operatorId === this._user?.id; } - public get genders(): ViewGender[] { - return this.genderRepo.getViewModelList(); - } + public genderListSubscriptionConfig = getGenderListSubscriptionConfig(); private set _initialState(state: any | null) { this._initialStateString = JSON.stringify(state); @@ -156,7 +154,7 @@ export class UserDetailViewComponent extends BaseUiComponent implements OnInit, public constructor( private fb: UntypedFormBuilder, private operator: OperatorService, - private genderRepo: GenderControllerService, + public genderRepo: GenderControllerService, private cd: ChangeDetectorRef ) { super(); diff --git a/client/src/app/site/modules/user-components/user-components.module.ts b/client/src/app/site/modules/user-components/user-components.module.ts index 446fb57b1f..9edd9460b6 100644 --- a/client/src/app/site/modules/user-components/user-components.module.ts +++ b/client/src/app/site/modules/user-components/user-components.module.ts @@ -14,6 +14,7 @@ import { MatMenuModule } from '@angular/material/menu'; import { MatSelectModule } from '@angular/material/select'; import { MatTooltipModule } from '@angular/material/tooltip'; import { IconContainerModule } from 'src/app/ui/modules/icon-container'; +import { SearchSelectorModule } from 'src/app/ui/modules/search-selector'; import { OpenSlidesTranslationModule } from '../../../site/modules/translations/openslides-translation.module'; import { PasswordFormComponent } from './components/password-form/password-form.component'; @@ -51,6 +52,7 @@ const MODULES = [MatInputModule, MatMenuModule]; MatFormFieldModule, MatCardModule, MatSelectModule, + SearchSelectorModule, ...MODULES ] }) diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts index 3c744b7d85..4fb19bee8b 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail/participant-detail.component.ts @@ -1,6 +1,5 @@ import { Component } from '@angular/core'; import { BaseModelRequestHandlerComponent } from 'src/app/site/base/base-model-request-handler.component'; -import { getGenderListSubscriptionConfig } from 'src/app/site/pages/organization/pages/accounts/pages/gender/gender.subscription'; import { getParticipantDetailSubscription } from '../../../../participants.subscription'; @@ -14,7 +13,6 @@ export class ParticipantDetailComponent extends BaseModelRequestHandlerComponent if (params[`id`]) { this.subscribeTo(getParticipantDetailSubscription(+params[`id`]), { hideWhenDestroyed: true }); } - this.subscribeTo(getGenderListSubscriptionConfig()); } protected override onParamsChanged(params: any, oldParams: any): void { diff --git a/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts b/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts index cee19a0840..b7a766bfeb 100644 --- a/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts @@ -25,6 +25,10 @@ const accountListSubsciptionContent = { follow: [{ idField: `committee_id`, fieldset: [`manager_ids`] }] } ] + }, + { + idField: `gender_id`, + fieldset: [`name`] } ] }; @@ -80,11 +84,6 @@ export class AccountMainComponent extends BaseModelRequestHandlerComponent { fieldset: [`name`] } ] - }, - { - idField: `gender_ids`, - fieldset: [`name`], - isFulllist: true } ] }, @@ -108,10 +107,6 @@ export class AccountMainComponent extends BaseModelRequestHandlerComponent { fieldset: [`name`] } ] - }, - { - idField: `gender_id`, - fieldset: [`name`] } ] }, diff --git a/client/src/app/ui/modules/search-selector/components/repo-search-selector/repo-search-selector.component.ts b/client/src/app/ui/modules/search-selector/components/repo-search-selector/repo-search-selector.component.ts index 2e623f0a0c..7c5c7f9018 100644 --- a/client/src/app/ui/modules/search-selector/components/repo-search-selector/repo-search-selector.component.ts +++ b/client/src/app/ui/modules/search-selector/components/repo-search-selector/repo-search-selector.component.ts @@ -53,6 +53,11 @@ export class RepoSearchSelectorComponent extends BaseSearchSelectorComponent imp ) { super(ngControl); this.shouldPropagateOnRegistering = false; + this.noneItem = { + getListTitle: (): string => this.noneTitle, + getTitle: (): string => this.noneTitle, + id: null + }; } public override ngOnInit(): void { From db744a8ecfee37aee63474829dd9b8f19e9b5fc3 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Mon, 16 Sep 2024 10:16:30 +0200 Subject: [PATCH 19/24] Move 0 -> null change to save functions --- .../components/account-dialog/account-dialog.component.ts | 8 ++++++-- .../participant-detail-view.component.ts | 3 +++ .../participant-create-wizard.component.ts | 3 +++ .../components/account-detail/account-detail.component.ts | 7 +++++++ .../repo-search-selector.component.ts | 5 ----- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.ts b/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.ts index 8df09e61e3..ab16c596d5 100644 --- a/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.ts +++ b/client/src/app/site/modules/global-headbar/components/account-dialog/account-dialog.component.ts @@ -193,10 +193,14 @@ export class AccountDialogComponent extends BaseUiComponent implements OnInit { public async saveUserChanges(): Promise { if (this.self) { + const payload = this.userPersonalForm; + if (payload.gender_id === 0) { + payload.gender_id = null; + } if (this.operator.hasPerms(Permission.userCanUpdate) && this._isUserInScope) { - await this.repo.update(this.userPersonalForm, this.self).resolve(); + await this.repo.update(payload, this.self).resolve(); } else { - await this.repo.updateSelf(this.userPersonalForm, this.self); + await this.repo.updateSelf(payload, this.self); } } this.isUserFormValid = false; diff --git a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail-view/participant-detail-view.component.ts b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail-view/participant-detail-view.component.ts index a961f6f871..de825074e8 100644 --- a/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail-view/participant-detail-view.component.ts +++ b/client/src/app/site/pages/meetings/pages/participants/pages/participant-detail/components/participant-detail-view/participant-detail-view.component.ts @@ -374,6 +374,9 @@ export class ParticipantDetailViewComponent extends BaseMeetingComponent { if (payload.member_number === ``) { payload.member_number = null; } + if (payload.gender_id === 0) { + payload.gender_id = null; + } const title = _(`This action will remove you from one or more groups.`); const content = _( `This may diminish your ability to do things in this meeting and you may not be able to revert it by youself. Are you sure you want to do this?` 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 af42444849..cb3bfa7e34 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 @@ -274,6 +274,9 @@ export class ParticipantCreateWizardComponent extends BaseMeetingComponent imple .filter((id: Id | undefined) => !!id) : [] }; + if (payload.gender_id === 0) { + payload.gender_id = null; + } if (this._accountId) { this.repo .update(payload, { diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.ts b/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.ts index e1d9456dee..dc6c9b7df6 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/account-detail/components/account-detail/account-detail.component.ts @@ -333,6 +333,13 @@ export class AccountDetailComponent extends BaseComponent implements OnInit { payload.member_number = null; } } + if (payload.gender_id === 0) { + if (isCreate) { + delete payload.gender_id; + } else { + payload.gender_id = null; + } + } return payload; } diff --git a/client/src/app/ui/modules/search-selector/components/repo-search-selector/repo-search-selector.component.ts b/client/src/app/ui/modules/search-selector/components/repo-search-selector/repo-search-selector.component.ts index 7c5c7f9018..2e623f0a0c 100644 --- a/client/src/app/ui/modules/search-selector/components/repo-search-selector/repo-search-selector.component.ts +++ b/client/src/app/ui/modules/search-selector/components/repo-search-selector/repo-search-selector.component.ts @@ -53,11 +53,6 @@ export class RepoSearchSelectorComponent extends BaseSearchSelectorComponent imp ) { super(ngControl); this.shouldPropagateOnRegistering = false; - this.noneItem = { - getListTitle: (): string => this.noneTitle, - getTitle: (): string => this.noneTitle, - id: null - }; } public override ngOnInit(): void { From f6be8e21849d5173fbc10166d60bd58330b227fb Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Mon, 16 Sep 2024 14:49:57 +0200 Subject: [PATCH 20/24] X out gender list test Like the other tests, this component test is 'xdescribe'. --- .../components/gender-list/gender-list.component.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.spec.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.spec.ts index 2953d2bc36..9466069a2a 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.spec.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.spec.ts @@ -2,7 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { GenderListComponent } from './gender-list.component'; -describe(`GenderListComponent`, () => { +xdescribe(`GenderListComponent`, () => { let component: GenderListComponent; let fixture: ComponentFixture; From f41da09a858e8ab9edc1797c8ae296e9f286fe6c Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Fri, 20 Sep 2024 14:17:34 +0200 Subject: [PATCH 21/24] Add missing subscription, disallow edit/del for some gender.id --- .../account-main/account-main.component.ts | 4 ++++ .../gender-list/gender-list.component.html | 16 ++++++++++------ .../gender-list/gender-list.component.ts | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts b/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts index b7a766bfeb..b228ec9c4a 100644 --- a/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/components/account-main/account-main.component.ts @@ -84,6 +84,10 @@ export class AccountMainComponent extends BaseModelRequestHandlerComponent { fieldset: [`name`] } ] + }, + { + idField: `gender_ids`, + fieldset: [`name`] } ] }, diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html index 072cf2a7c6..1c8a60ecc8 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html @@ -36,14 +36,18 @@

{{ 'Gender' | translate }}

- + @if (gender.id > 4) { + + }
- + @if (gender.id > 4) { + + }
diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts index 719d6e1671..b9b007d174 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.ts @@ -70,7 +70,7 @@ export class GenderListComponent extends BaseListViewComponent { : this.translate.instant(`Are you sure you want to delete all selected genders?`); const content = genders.length === 1 ? genders[0].name : ``; if (await this.promptService.open(title, content)) { - return this.repo.delete(...genders.map(g => g.id)).then(() => this.cd.detectChanges()); + return this.repo.delete(...genders.map(g => g.id).filter(id => id > 4)).then(() => this.cd.detectChanges()); } } From 136061becee62e52c7f62c7630c4eba7f0397da6 Mon Sep 17 00:00:00 2001 From: Ludwig Reiter Date: Wed, 25 Sep 2024 14:31:24 +0200 Subject: [PATCH 22/24] Disable delete menu depending on filtered genders --- .../components/gender-list/gender-list.component.html | 7 ++++--- .../components/gender-list/gender-list.component.ts | 10 +++++++++- .../gender/pages/gender-list/gender-list.module.ts | 4 +++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html index 1c8a60ecc8..c234023efc 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html @@ -36,14 +36,14 @@

{{ 'Gender' | translate }}

- @if (gender.id > 4) { + @if (gender.id > 4 && !isMultiSelect) { }
- @if (gender.id > 4) { + @if (gender.id > 4 && !isMultiSelect) { @@ -74,7 +74,8 @@

{{ 'Gender' | translate }}

} diff --git a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html index 6febd044a0..1ac27a692a 100644 --- a/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html +++ b/client/src/app/site/pages/organization/pages/accounts/pages/gender/pages/gender-list/components/gender-list/gender-list.component.html @@ -2,11 +2,11 @@ [hasMainButton]="true" [mainActionTooltip]="'New gender' | translate" [multiSelectMode]="isMultiSelect" - (mainEvent)="createGender()" + (mainEvent)="openGenderDialog()" >
-

{{ 'Gender' | translate }}

+

{{ 'Genders' | translate }}

@@ -37,7 +37,7 @@

{{ 'Gender' | translate }}

@if (gender.id > 4 && !isMultiSelect) { - } @@ -59,8 +59,7 @@

{{ 'Gender' | translate }}

{{ 'Multiselect' | translate }}
- } - @if (isMultiSelect) { + } @else {