Filter only evoting polls, change filter options
Pre filters all analog polls from poll list. Creates a filter to find thouse with open polls for the user
This commit is contained in:
parent
91be76a263
commit
14de67a09d
@ -80,7 +80,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- The Vote -->
|
<!-- 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 -->
|
<!-- More-Button -->
|
||||||
<div class="poll-detail-button-wrapper">
|
<div class="poll-detail-button-wrapper">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<os-head-bar>
|
<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-head-bar>
|
||||||
|
|
||||||
<os-list-view-table
|
<os-list-view-table
|
||||||
@ -30,11 +30,11 @@
|
|||||||
|
|
||||||
<!-- Voted Indicator -->
|
<!-- Voted Indicator -->
|
||||||
<div *pblNgridCellDef="'votability'; row as poll" class="cell-slot fill">
|
<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
|
check_circle
|
||||||
</mat-icon>
|
</mat-icon>
|
||||||
<mat-icon
|
<mat-icon
|
||||||
*ngIf="!poll.user_has_voted && poll.canBeVotedFor"
|
*ngIf="!poll.hasVote && poll.hasVote !== null"
|
||||||
color="warn"
|
color="warn"
|
||||||
matTooltip="{{ 'Voting is currently in progress.' | translate }}"
|
matTooltip="{{ 'Voting is currently in progress.' | translate }}"
|
||||||
>
|
>
|
||||||
|
@ -96,6 +96,16 @@ export abstract class ViewBasePoll<
|
|||||||
return MajorityMethodVerbose[this.majority_method];
|
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 pollmethodVerbose(): string;
|
||||||
|
|
||||||
public abstract get percentBaseVerbose(): string;
|
public abstract get percentBaseVerbose(): string;
|
||||||
|
@ -53,7 +53,7 @@ export abstract class BasePollRepositoryService<
|
|||||||
protected createViewModelWithTitles(model: M): V {
|
protected createViewModelWithTitles(model: M): V {
|
||||||
const viewModel = super.createViewModelWithTitles(model);
|
const viewModel = super.createViewModelWithTitles(model);
|
||||||
Object.defineProperty(viewModel, 'canBeVotedFor', {
|
Object.defineProperty(viewModel, 'canBeVotedFor', {
|
||||||
get: () => this.votingService.canVote(viewModel)
|
value: () => this.votingService.canVote(viewModel)
|
||||||
});
|
});
|
||||||
return viewModel;
|
return viewModel;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,14 @@ export class PollFilterListService extends BaseFilterListService<ViewBasePoll> {
|
|||||||
super(store, OSStatus);
|
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
|
* @returns the filter definition
|
||||||
*/
|
*/
|
||||||
@ -37,19 +45,11 @@ export class PollFilterListService extends BaseFilterListService<ViewBasePoll> {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
property: 'canBeVotedFor',
|
property: 'hasVote',
|
||||||
label: this.translate.instant('Vote'),
|
label: this.translate.instant('Voting'),
|
||||||
options: [
|
options: [
|
||||||
{ condition: true, label: this.translate.instant('Vote currently possible') },
|
{ condition: false, label: this.translate.instant('Voting is currently in progress.') },
|
||||||
{ condition: false, label: this.translate.instant('Vote not possible') }
|
{ condition: true, label: this.translate.instant('You have already voted.') }
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
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') }
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user