From ed1c3eaa7a1399c43c87ee1b45c24150fbd11548 Mon Sep 17 00:00:00 2001 From: Sean Date: Mon, 5 Oct 2020 12:39:17 +0200 Subject: [PATCH] Add search and filter for vote delegation Adds a new filter "Vote delegation" to user list: Transferred vote right Received vote reight neither received not transferred vote right Adjusts the user list search and the global search to include vote deligations --- client/src/app/shared/models/users/user.ts | 4 ++++ .../user-list/user-list.component.ts | 2 +- client/src/app/site/users/models/view-user.ts | 22 ++++++++++++++++++- .../services/user-filter-list.service.ts | 14 +++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/client/src/app/shared/models/users/user.ts b/client/src/app/shared/models/users/user.ts index c45f2ffbf..3ee588b52 100644 --- a/client/src/app/shared/models/users/user.ts +++ b/client/src/app/shared/models/users/user.ts @@ -47,6 +47,10 @@ export class User extends BaseDecimalModel { return !!this.vote_delegated_to_id; } + public get hasVoteRightFromOthers(): boolean { + return this.vote_delegated_from_users_id?.length > 0; + } + public constructor(input?: Partial) { super(User.COLLECTIONSTRING, input); } diff --git a/client/src/app/site/users/components/user-list/user-list.component.ts b/client/src/app/site/users/components/user-list/user-list.component.ts index 014844e70..16ca275ec 100644 --- a/client/src/app/site/users/components/user-list/user-list.component.ts +++ b/client/src/app/site/users/components/user-list/user-list.component.ts @@ -147,7 +147,7 @@ export class UserListComponent extends BaseListViewComponent implement /** * Define extra filter properties */ - public filterProps = ['full_name', 'groups', 'structure_level', 'number']; + public filterProps = ['full_name', 'groups', 'structure_level', 'number', 'delegationName']; private selfPresentConfStr = 'users_allow_self_set_present'; diff --git a/client/src/app/site/users/models/view-user.ts b/client/src/app/site/users/models/view-user.ts index 7c42be6c3..d7eb4b0b4 100644 --- a/client/src/app/site/users/models/view-user.ts +++ b/client/src/app/site/users/models/view-user.ts @@ -14,6 +14,12 @@ export interface UserTitleInformation { number?: string; } +export enum DelegationType { + Transferred = 1, + Received, + Neither +} + export class ViewUser extends BaseProjectableViewModel implements UserTitleInformation, Searchable { public static COLLECTIONSTRING = User.COLLECTIONSTRING; @@ -45,6 +51,19 @@ export class ViewUser extends BaseProjectableViewModel implements UserTitl } } + public get delegationName(): string | undefined { + return this.voteDelegatedTo?.getFullName(); + } + + public get delegationType(): DelegationType { + if (this.user.isVoteRightDelegated) { + return DelegationType.Transferred; + } else if (this.user.hasVoteRightFromOthers) { + return DelegationType.Received; + } + return DelegationType.Neither; + } + // Will be set by the repository public getFullName: () => string; public getShortName: () => string; @@ -61,7 +80,8 @@ export class ViewUser extends BaseProjectableViewModel implements UserTitl { key: 'First name', value: this.first_name }, { key: 'Last name', value: this.last_name }, { key: 'Structure level', value: this.structure_level }, - { key: 'Number', value: this.number } + { key: 'Number', value: this.number }, + { key: 'Vote Delegation', value: this.delegationName } ]; return { properties, searchValue: properties.map(property => property.value) }; } diff --git a/client/src/app/site/users/services/user-filter-list.service.ts b/client/src/app/site/users/services/user-filter-list.service.ts index 58e35ceb6..e5179d5f5 100644 --- a/client/src/app/site/users/services/user-filter-list.service.ts +++ b/client/src/app/site/users/services/user-filter-list.service.ts @@ -6,7 +6,7 @@ import { OpenSlidesStatusService } from 'app/core/core-services/openslides-statu import { StorageService } from 'app/core/core-services/storage.service'; import { GroupRepositoryService } from 'app/core/repositories/users/group-repository.service'; import { BaseFilterListService, OsFilter } from 'app/core/ui-services/base-filter-list.service'; -import { ViewUser } from '../models/view-user'; +import { DelegationType, ViewUser } from '../models/view-user'; /** * Filter the user list @@ -93,6 +93,18 @@ export class UserFilterListService extends BaseFilterListService { { condition: false, label: this.translate.instant('Has changed vote weight') }, { condition: true, label: this.translate.instant('Has unchanged vote weight') } ] + }, + { + property: 'delegationType', + label: this.translate.instant('Vote delegation'), + options: [ + { condition: DelegationType.Transferred, label: this.translate.instant('Transferred vote right') }, + { condition: DelegationType.Received, label: this.translate.instant('Received vote right') }, + { + condition: DelegationType.Neither, + label: this.translate.instant('Neither received nor transferred vote right') + } + ] } ]; return staticFilterOptions.concat(this.userGroupFilterOptions);