Merge pull request #5281 from tsiegleauq/poll-list-filter
Filter only evoting polls, change filter options
This commit is contained in:
commit
af6c5faac8
@ -80,7 +80,7 @@
|
||||
</div>
|
||||
|
||||
<!-- The Vote -->
|
||||
<os-assignment-poll-vote *ngIf="poll.canBeVotedFor" [poll]="poll"></os-assignment-poll-vote>
|
||||
<os-assignment-poll-vote *ngIf="poll.canBeVotedFor()" [poll]="poll"></os-assignment-poll-vote>
|
||||
|
||||
<!-- More-Button -->
|
||||
<div class="poll-detail-button-wrapper">
|
||||
|
@ -1,5 +1,5 @@
|
||||
<os-head-bar>
|
||||
<div class="title-slot" translate>List of votes</div>
|
||||
<div class="title-slot" translate>List of electronic votes</div>
|
||||
</os-head-bar>
|
||||
|
||||
<os-list-view-table
|
||||
@ -30,11 +30,11 @@
|
||||
|
||||
<!-- Voted Indicator -->
|
||||
<div *pblNgridCellDef="'votability'; row as poll" class="cell-slot fill">
|
||||
<mat-icon *ngIf="poll.user_has_voted" color="accent" matTooltip="{{ 'You have already voted.' | translate }}">
|
||||
<mat-icon *ngIf="poll.hasVote" color="accent" matTooltip="{{ 'You have already voted.' | translate }}">
|
||||
check_circle
|
||||
</mat-icon>
|
||||
<mat-icon
|
||||
*ngIf="!poll.user_has_voted && poll.canBeVotedFor"
|
||||
*ngIf="!poll.hasVote && poll.hasVote !== null"
|
||||
color="warn"
|
||||
matTooltip="{{ 'Voting is currently in progress.' | translate }}"
|
||||
>
|
||||
|
@ -96,6 +96,16 @@ export abstract class ViewBasePoll<
|
||||
return MajorityMethodVerbose[this.majority_method];
|
||||
}
|
||||
|
||||
public get hasVote(): boolean | null {
|
||||
if (!this.user_has_voted && this.canBeVotedFor()) {
|
||||
return false;
|
||||
} else if (this.user_has_voted) {
|
||||
return true;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract get pollmethodVerbose(): string;
|
||||
|
||||
public abstract get percentBaseVerbose(): string;
|
||||
|
@ -53,7 +53,7 @@ export abstract class BasePollRepositoryService<
|
||||
protected createViewModelWithTitles(model: M): V {
|
||||
const viewModel = super.createViewModelWithTitles(model);
|
||||
Object.defineProperty(viewModel, 'canBeVotedFor', {
|
||||
get: () => this.votingService.canVote(viewModel)
|
||||
value: () => this.votingService.canVote(viewModel)
|
||||
});
|
||||
return viewModel;
|
||||
}
|
||||
|
@ -21,6 +21,14 @@ export class PollFilterListService extends BaseFilterListService<ViewBasePoll> {
|
||||
super(store, OSStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out analog polls
|
||||
* @param viewPoll All polls
|
||||
*/
|
||||
protected preFilter(viewPoll: ViewBasePoll[]): ViewBasePoll[] | void {
|
||||
return viewPoll.filter(poll => !poll.isAnalog);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the filter definition
|
||||
*/
|
||||
@ -37,19 +45,11 @@ export class PollFilterListService extends BaseFilterListService<ViewBasePoll> {
|
||||
]
|
||||
},
|
||||
{
|
||||
property: 'canBeVotedFor',
|
||||
label: this.translate.instant('Vote'),
|
||||
property: 'hasVote',
|
||||
label: this.translate.instant('Voting'),
|
||||
options: [
|
||||
{ condition: true, label: this.translate.instant('Vote currently possible') },
|
||||
{ condition: false, label: this.translate.instant('Vote not possible') }
|
||||
]
|
||||
},
|
||||
{
|
||||
property: 'user_has_voted',
|
||||
label: this.translate.instant('Vote finished'),
|
||||
options: [
|
||||
{ condition: true, label: this.translate.instant('Has been voted for') },
|
||||
{ condition: false, label: this.translate.instant('Has not been voted for') }
|
||||
{ condition: false, label: this.translate.instant('Voting is currently in progress.') },
|
||||
{ condition: true, label: this.translate.instant('You have already voted.') }
|
||||
]
|
||||
}
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user