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
This commit is contained in:
Sean 2020-10-05 12:39:17 +02:00
parent 9607f05454
commit ed1c3eaa7a
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;
}
public get hasVoteRightFromOthers(): boolean {
return this.vote_delegated_from_users_id?.length > 0;
}
public constructor(input?: Partial<User>) {
super(User.COLLECTIONSTRING, input);
}

View File

@ -147,7 +147,7 @@ export class UserListComponent extends BaseListViewComponent<ViewUser> 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';

View File

@ -14,6 +14,12 @@ export interface UserTitleInformation {
number?: string;
}
export enum DelegationType {
Transferred = 1,
Received,
Neither
}
export class ViewUser extends BaseProjectableViewModel<User> implements UserTitleInformation, Searchable {
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
public getFullName: () => string;
public getShortName: () => string;
@ -61,7 +80,8 @@ export class ViewUser extends BaseProjectableViewModel<User> 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) };
}

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 { 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<ViewUser> {
{ 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);