Add "represented by" to single votes table

Adds a "represented by" field to the single votes table, to indicate a
vote delegation.
Also fixes an height issue that occured in large single vote tables when
the user was navigating from a list view table to a single vote table
This commit is contained in:
Sean 2020-10-05 16:22:22 +02:00
parent 9607f05454
commit 2162f2b049
6 changed files with 81 additions and 5 deletions

View File

@ -649,6 +649,8 @@ export class ListViewTableComponent<V extends BaseViewModel | BaseViewModelWithC
private changeRowHeight(): void { private changeRowHeight(): void {
if (this.vScrollFixed > 0) { if (this.vScrollFixed > 0) {
document.documentElement.style.setProperty('--pbl-height', this.vScrollFixed + 'px'); 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"> <div *ngIf="vote.user">
{{ vote.user.getShortName() }} {{ vote.user.getShortName() }}
<div class="user-subtitle"> <div class="user-subtitle">
<!-- Level and number -->
<div *ngIf="vote.user.getLevelAndNumber()"> <div *ngIf="vote.user.getLevelAndNumber()">
{{ vote.user.getLevelAndNumber() }} {{ vote.user.getLevelAndNumber() }}
</div> </div>
<!-- Vote weight -->
<div *ngIf="isVoteWeightActive"> <div *ngIf="isVoteWeightActive">
{{ 'Vote weight' | translate }}: {{ vote.user.vote_weight }} {{ 'Vote weight' | translate }}: {{ vote.user.vote_weight }}
</div> </div>
<!-- Delegation -->
<div *ngIf="userHasVoteDelegation(vote.user)">
<span>
({{ 'represented by' | translate }}
{{ getUsersVoteDelegation(vote.user).getShortName().trim() }})
</span>
</div>
</div> </div>
</div> </div>
<div *ngIf="!vote.user"> <div *ngIf="!vote.user">

View File

@ -50,10 +50,22 @@ export class AssignmentPollDetailComponent extends BasePollDetailComponentDirect
configService: ConfigService, configService: ConfigService,
protected pollService: AssignmentPollService, protected pollService: AssignmentPollService,
votesRepo: AssignmentVoteRepositoryService, votesRepo: AssignmentVoteRepositoryService,
private operator: OperatorService, protected operator: OperatorService,
private router: Router 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 configService
.get<boolean>('users_activate_vote_weight') .get<boolean>('users_activate_vote_weight')
.subscribe(active => (this.isVoteWeightActive = active)); .subscribe(active => (this.isVoteWeightActive = active));

View File

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

View File

@ -56,10 +56,22 @@ export class MotionPollDetailComponent extends BasePollDetailComponentDirective<
pollService: MotionPollService, pollService: MotionPollService,
votesRepo: MotionVoteRepositoryService, votesRepo: MotionVoteRepositoryService,
configService: ConfigService, configService: ConfigService,
private operator: OperatorService, protected operator: OperatorService,
private router: Router 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 configService
.get<boolean>('users_activate_vote_weight') .get<boolean>('users_activate_vote_weight')
.subscribe(active => (this.isVoteWeightActive = active)); .subscribe(active => (this.isVoteWeightActive = active));

View File

@ -8,6 +8,7 @@ import { Label } from 'ng2-charts';
import { BehaviorSubject, from, Observable } from 'rxjs'; import { BehaviorSubject, from, Observable } from 'rxjs';
import { filter, map } from 'rxjs/operators'; import { filter, map } from 'rxjs/operators';
import { OperatorService } from 'app/core/core-services/operator.service';
import { Deferred } from 'app/core/promises/deferred'; import { Deferred } from 'app/core/promises/deferred';
import { BaseRepository } from 'app/core/repositories/base-repository'; import { BaseRepository } from 'app/core/repositories/base-repository';
import { GroupRepositoryService } from 'app/core/repositories/users/group-repository.service'; 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 promptService: PromptService,
protected pollDialog: BasePollDialogService<V, S>, protected pollDialog: BasePollDialogService<V, S>,
protected pollService: S, protected pollService: S,
protected votesRepo: BaseRepository<ViewBaseVote, BaseVote, object> protected votesRepo: BaseRepository<ViewBaseVote, BaseVote, object>,
protected operator: OperatorService
) { ) {
super(title, translate, matSnackbar); super(title, translate, matSnackbar);
this.setup(); 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;
}
}
} }