Merge pull request #5608 from tsiegleauq/vote-delegation-search-filter

Add search and filter for vote delegation
This commit is contained in:
Emanuel Schütze 2020-10-06 22:13:20 +02:00 committed by GitHub
commit be3fafd907
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 3 deletions

View File

@ -47,6 +47,10 @@ export class User extends BaseDecimalModel<User> {
return !!this.vote_delegated_to_id; return !!this.vote_delegated_to_id;
} }
public get hasVoteRightFromOthers(): boolean {
return this.vote_delegated_from_users_id?.length > 0;
}
public constructor(input?: Partial<User>) { public constructor(input?: Partial<User>) {
super(User.COLLECTIONSTRING, input); super(User.COLLECTIONSTRING, input);
} }

View File

@ -147,7 +147,7 @@ export class UserListComponent extends BaseListViewComponent<ViewUser> implement
/** /**
* Define extra filter properties * 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'; private selfPresentConfStr = 'users_allow_self_set_present';

View File

@ -14,6 +14,12 @@ export interface UserTitleInformation {
number?: string; number?: string;
} }
export enum DelegationType {
Transferred = 1,
Received,
Neither
}
export class ViewUser extends BaseProjectableViewModel<User> implements UserTitleInformation, Searchable { export class ViewUser extends BaseProjectableViewModel<User> implements UserTitleInformation, Searchable {
public static COLLECTIONSTRING = User.COLLECTIONSTRING; public static COLLECTIONSTRING = User.COLLECTIONSTRING;
@ -45,6 +51,19 @@ export class ViewUser extends BaseProjectableViewModel<User> 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 // Will be set by the repository
public getFullName: () => string; public getFullName: () => string;
public getShortName: () => string; public getShortName: () => string;
@ -61,7 +80,8 @@ export class ViewUser extends BaseProjectableViewModel<User> implements UserTitl
{ key: 'First name', value: this.first_name }, { key: 'First name', value: this.first_name },
{ key: 'Last name', value: this.last_name }, { key: 'Last name', value: this.last_name },
{ key: 'Structure level', value: this.structure_level }, { 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) }; return { properties, searchValue: properties.map(property => property.value) };
} }

View File

@ -6,7 +6,7 @@ import { OpenSlidesStatusService } from 'app/core/core-services/openslides-statu
import { StorageService } from 'app/core/core-services/storage.service'; import { StorageService } from 'app/core/core-services/storage.service';
import { GroupRepositoryService } from 'app/core/repositories/users/group-repository.service'; import { GroupRepositoryService } from 'app/core/repositories/users/group-repository.service';
import { BaseFilterListService, OsFilter } from 'app/core/ui-services/base-filter-list.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 * Filter the user list
@ -93,6 +93,18 @@ export class UserFilterListService extends BaseFilterListService<ViewUser> {
{ condition: false, label: this.translate.instant('Has changed vote weight') }, { condition: false, label: this.translate.instant('Has changed vote weight') },
{ condition: true, label: this.translate.instant('Has unchanged 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); return staticFilterOptions.concat(this.userGroupFilterOptions);