Merge pull request #5609 from tsiegleauq/show-delegations-in-single-vote-table

Add "represented by" to single votes table
This commit is contained in:
Emanuel Schütze 2020-10-07 17:35:20 +02:00 committed by GitHub
commit 25d83b4419
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 81 additions and 5 deletions

View File

@ -650,6 +650,8 @@ export class ListViewTableComponent<V extends BaseViewModel | BaseViewModelWithC
private changeRowHeight(): void {
if (this.vScrollFixed > 0) {
document.documentElement.style.setProperty('--pbl-height', this.vScrollFixed + 'px');
} else {
document.documentElement.style.removeProperty('--pbl-height');
}
}

View File

@ -71,12 +71,23 @@
<div *ngIf="vote.user">
{{ vote.user.getShortName() }}
<div class="user-subtitle">
<!-- Level and number -->
<div *ngIf="vote.user.getLevelAndNumber()">
{{ vote.user.getLevelAndNumber() }}
</div>
<!-- Vote weight -->
<div *ngIf="isVoteWeightActive">
{{ 'Vote weight' | translate }}: {{ vote.user.vote_weight }}
</div>
<!-- Delegation -->
<div *ngIf="userHasVoteDelegation(vote.user)">
<span>
({{ 'represented by' | translate }}
{{ getUsersVoteDelegation(vote.user).getShortName().trim() }})
</span>
</div>
</div>
</div>
<div *ngIf="!vote.user">

View File

@ -50,10 +50,22 @@ export class AssignmentPollDetailComponent extends BasePollDetailComponentDirect
configService: ConfigService,
protected pollService: AssignmentPollService,
votesRepo: AssignmentVoteRepositoryService,
private operator: OperatorService,
protected operator: OperatorService,
private router: Router
) {
super(title, translate, matSnackbar, repo, route, groupRepo, prompt, pollDialog, pollService, votesRepo);
super(
title,
translate,
matSnackbar,
repo,
route,
groupRepo,
prompt,
pollDialog,
pollService,
votesRepo,
operator
);
configService
.get<boolean>('users_activate_vote_weight')
.subscribe(active => (this.isVoteWeightActive = active));

View File

@ -58,14 +58,25 @@
<div *pblNgridCellDef="'user'; row as vote">
<div *ngIf="vote.user">
{{ vote.user.getShortName() }}
<div class="user-subtitle">
<!-- Level and number -->
<div *ngIf="vote.user.getLevelAndNumber()">
{{ vote.user.getLevelAndNumber() }}
</div>
<!-- Vote weight -->
<div *ngIf="isVoteWeightActive">
{{ 'Vote weight' | translate }}: {{ vote.user.vote_weight }}
</div>
<!-- Delegation -->
<div *ngIf="userHasVoteDelegation(vote.user)">
<span>
({{ 'represented by' | translate }}
{{ getUsersVoteDelegation(vote.user).getShortName().trim() }})
</span>
</div>
</div>
</div>
<div *ngIf="!vote.user">{{ 'Anonymous' | translate }}</div>

View File

@ -56,10 +56,22 @@ export class MotionPollDetailComponent extends BasePollDetailComponentDirective<
pollService: MotionPollService,
votesRepo: MotionVoteRepositoryService,
configService: ConfigService,
private operator: OperatorService,
protected operator: OperatorService,
private router: Router
) {
super(title, translate, matSnackbar, repo, route, groupRepo, prompt, pollDialog, pollService, votesRepo);
super(
title,
translate,
matSnackbar,
repo,
route,
groupRepo,
prompt,
pollDialog,
pollService,
votesRepo,
operator
);
configService
.get<boolean>('users_activate_vote_weight')
.subscribe(active => (this.isVoteWeightActive = active));

View File

@ -8,6 +8,7 @@ import { Label } from 'ng2-charts';
import { BehaviorSubject, from, Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { OperatorService } from 'app/core/core-services/operator.service';
import { Deferred } from 'app/core/promises/deferred';
import { BaseRepository } from 'app/core/repositories/base-repository';
import { GroupRepositoryService } from 'app/core/repositories/users/group-repository.service';
@ -104,7 +105,8 @@ export abstract class BasePollDetailComponentDirective<V extends ViewBasePoll, S
protected promptService: PromptService,
protected pollDialog: BasePollDialogService<V, S>,
protected pollService: S,
protected votesRepo: BaseRepository<ViewBaseVote, BaseVote, object>
protected votesRepo: BaseRepository<ViewBaseVote, BaseVote, object>,
protected operator: OperatorService
) {
super(title, translate, matSnackbar);
this.setup();
@ -211,4 +213,30 @@ export abstract class BasePollDetailComponentDirective<V extends ViewBasePoll, S
);
}
}
protected userHasVoteDelegation(user: ViewUser): boolean {
/**
* This will be false if the operator does not have "can_see_extra_data"
*/
if (user.isVoteRightDelegated) {
return true;
} else if (this.operator.viewUser.canVoteFor(user)) {
return true;
}
return false;
}
protected getUsersVoteDelegation(user: ViewUser): ViewUser {
/**
* This will be false if the operator does not have "can_see_extra_data"
*/
if (!!user.voteDelegatedTo) {
return user.voteDelegatedTo;
}
if (this.operator.viewUser.canVoteFor(user)) {
return this.operator.viewUser;
}
}
}