improved shared poll list

This commit is contained in:
Joshua Sangmeister 2020-01-30 12:01:59 +01:00 committed by FinnStutzenstein
parent a0c3a28456
commit 1de73d5701
4 changed files with 25 additions and 19 deletions

View File

@ -3,6 +3,7 @@ import { BehaviorSubject } from 'rxjs';
import { ChartData } from 'app/shared/components/charts/charts.component';
import { AssignmentPoll, AssignmentPollMethods } from 'app/shared/models/assignments/assignment-poll';
import { PollColor } from 'app/shared/models/poll/base-poll';
import { BaseViewModel } from 'app/site/base/base-view-model';
import { ProjectorElementBuildDeskriptor } from 'app/site/base/projectable';
import { ViewBasePoll } from 'app/site/polls/models/view-base-poll';
import { ViewAssignment } from './view-assignment';
@ -29,6 +30,10 @@ export class ViewAssignmentPoll extends ViewBasePoll<AssignmentPoll> implements
return AssignmentPollMethodsVerbose[this.pollmethod];
}
public getContentObject(): BaseViewModel {
return this.assignment;
}
public getSlide(): ProjectorElementBuildDeskriptor {
// TODO: update to new voting system?
return {

View File

@ -1,6 +1,7 @@
import { ChartData } from 'app/shared/components/charts/charts.component';
import { MotionPoll, MotionPollMethods } from 'app/shared/models/motions/motion-poll';
import { PollColor } from 'app/shared/models/poll/base-poll';
import { BaseViewModel } from 'app/site/base/base-view-model';
import { ProjectorElementBuildDeskriptor } from 'app/site/base/projectable';
import { ViewMotionOption } from 'app/site/motions/models/view-motion-option';
import { ViewBasePoll } from 'app/site/polls/models/view-base-poll';
@ -32,6 +33,10 @@ export class ViewMotionPoll extends ViewBasePoll<MotionPoll> implements MotionPo
return ['Votes'];
}
public getContentObject(): BaseViewModel {
return this.motion;
}
public generateTableData(): {}[] {
let tableData = this.options.flatMap(vote => this.tableKeys.map(key => ({ key: key, value: vote[key] })));
tableData.push(...this.voteKeys.map(key => ({ key: key, value: this[key] })));

View File

@ -11,28 +11,25 @@
[listObservableProvider]="polls"
[vScrollFixed]="64"
[columns]="tableColumnDefinition"
[listStorageKey]="'polls'"
listStorageKey="polls"
[filterProps]="filterProps"
[filterService]="filterService"
>
<div *pblNgridCellDef="'title'; row as poll; rowContext as context" class="cell-slot fill">
<a
class="detail-link"
(click)="saveScrollIndex('polls', rowContext?.identity)"
[routerLink]="poll.parentLink"
*ngIf="!isMultiSelect"
></a>
<div *pblNgridCellDef="'title'; row as poll; rowContext as context;" class="cell-slot fill">
<a class="detail-link" [routerLink]="poll.parentLink" *ngIf="!isMultiSelect"></a>
<span>{{ poll.title }}</span>
</div>
<div *pblNgridCellDef="'classType'; row as poll" class="cell-slot fill">
<span>{{ poll.pollClassTypeVerbose }}</span>
<div *pblNgridCellDef="'classType'; row as poll;" class="cell-slot fill">
<a class="detail-link" [routerLink]="poll.parentLink" *ngIf="!isMultiSelect"></a>
<span>{{ poll.getContentObject().getListTitle() }}</span>
</div>
<div *pblNgridCellDef="'state'; row as poll" class="cell-slot fill">
<div *pblNgridCellDef="'state'; row as poll;" class="cell-slot fill">
<a class="detail-link" [routerLink]="poll.parentLink" *ngIf="!isMultiSelect"></a>
<span>{{ poll.stateVerbose }}</span>
</div>
<div *pblNgridCellDef="'votability'; row as poll" class="cell-slot fill">
<mat-icon *ngIf="poll.user_has_voted" color="accent">check_circle</mat-icon>
<mat-icon *ngIf="!poll.user_has_voted && poll.canBeVotedFor" color="warn">warning</mat-icon>
<div *pblNgridCellDef="'votability'; row as poll;" class="cell-slot fill">
<mat-icon *ngIf="poll.user_has_voted" color="accent" matTooltip="{{ 'You have already voted on this poll. Good job!' | translate }}">check_circle</mat-icon>
<mat-icon *ngIf="!poll.user_has_voted && poll.canBeVotedFor" color="warn" matTooltip="{{ 'You still have to vote on this poll.' | translate }}">warning</mat-icon>
</div>
</os-list-view-table>

View File

@ -1,11 +1,10 @@
import { ChartData } from 'app/shared/components/charts/charts.component';
import { BasePoll, PollState } from 'app/shared/models/poll/base-poll';
import { ViewAssignmentOption } from 'app/site/assignments/models/view-assignment-option';
import { ViewAssignmentPoll } from 'app/site/assignments/models/view-assignment-poll';
import { BaseProjectableViewModel } from 'app/site/base/base-projectable-view-model';
import { BaseViewModel } from 'app/site/base/base-view-model';
import { ProjectorElementBuildDeskriptor } from 'app/site/base/projectable';
import { ViewMotionOption } from 'app/site/motions/models/view-motion-option';
import { ViewMotionPoll } from 'app/site/motions/models/view-motion-poll';
import { ViewGroup } from 'app/site/users/models/view-group';
import { ViewUser } from 'app/site/users/models/view-user';
@ -71,9 +70,7 @@ export abstract class ViewBasePoll<M extends BasePoll<M, any> = any> extends Bas
}
public get parentLink(): string {
return this.pollClassType === 'motion'
? `/motions/${(<ViewMotionPoll>(<any>this)).poll.motion_id}`
: `/assignments/${(<ViewAssignmentPoll>(<any>this)).poll.assignment_id}/`;
return `/${this.pollClassType}s/${this.getContentObject().id}`;
}
public get stateVerbose(): string {
@ -111,6 +108,8 @@ export abstract class ViewBasePoll<M extends BasePoll<M, any> = any> extends Bas
public abstract getSlide(): ProjectorElementBuildDeskriptor;
public abstract getContentObject(): BaseViewModel;
/**
* Initializes labels for a chart.
*/