Show "unpublished" for finished polls in AP

Also: Change APs change detection to onPush.
This is the last possible option to enhance AP performance
This commit is contained in:
Sean 2021-05-26 11:58:47 +02:00 committed by Emanuel Schütze
parent 4d4a3bb0db
commit 6451cdf590
4 changed files with 26 additions and 4 deletions

View File

@ -10,7 +10,6 @@ import { ListOfSpeakersRepositoryService } from 'app/core/repositories/agenda/li
import { ProjectorRepositoryService } from 'app/core/repositories/projector/projector-repository.service'; import { ProjectorRepositoryService } from 'app/core/repositories/projector/projector-repository.service';
import { DetailNavigable, isDetailNavigable } from 'app/shared/models/base/detail-navigable'; import { DetailNavigable, isDetailNavigable } from 'app/shared/models/base/detail-navigable';
import { ProjectorElement } from 'app/shared/models/core/projector'; import { ProjectorElement } from 'app/shared/models/core/projector';
import { ListOfSpeakersComponent } from 'app/site/agenda/components/list-of-speakers/list-of-speakers.component';
import { ViewListOfSpeakers } from 'app/site/agenda/models/view-list-of-speakers'; import { ViewListOfSpeakers } from 'app/site/agenda/models/view-list-of-speakers';
import { BaseProjectableViewModel } from 'app/site/base/base-projectable-view-model'; import { BaseProjectableViewModel } from 'app/site/base/base-projectable-view-model';
import { BaseViewComponentDirective } from 'app/site/base/base-view'; import { BaseViewComponentDirective } from 'app/site/base/base-view';
@ -20,7 +19,8 @@ import { CurrentListOfSpeakersService } from 'app/site/projector/services/curren
@Component({ @Component({
selector: 'os-cinema', selector: 'os-cinema',
templateUrl: './cinema.component.html', templateUrl: './cinema.component.html',
styleUrls: ['./cinema.component.scss'] styleUrls: ['./cinema.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
}) })
export class CinemaComponent extends BaseViewComponentDirective implements OnInit { export class CinemaComponent extends BaseViewComponentDirective implements OnInit {
public listOfSpeakers: ViewListOfSpeakers; public listOfSpeakers: ViewListOfSpeakers;
@ -109,9 +109,11 @@ export class CinemaComponent extends BaseViewComponentDirective implements OnIni
} else { } else {
this.projectedViewModel = null; this.projectedViewModel = null;
} }
this.cd.markForCheck();
}), }),
this.closService.currentListOfSpeakersObservable.subscribe(clos => { this.closService.currentListOfSpeakersObservable.subscribe(clos => {
this.listOfSpeakers = clos; this.listOfSpeakers = clos;
this.cd.markForCheck();
}) })
); );
} }

View File

@ -12,8 +12,12 @@
<ng-template #pollArea let-poll="poll" let-last="last"> <ng-template #pollArea let-poll="poll" let-last="last">
<mat-card class="os-card"> <mat-card class="os-card">
<p class="subtitle-text"> <p>
<a [routerLink]="getPollDetailLink(poll)" [state]="{ back: 'true' }">{{ getPollVoteTitle(poll) }}</a> <a [routerLink]="getPollDetailLink(poll)" [state]="{ back: 'true' }" class="subtitle-text">
{{ getPollVoteTitle(poll) }}
</a>
<br>
<i *ngIf="canManagePoll(poll) && poll.isFinished" class="small">{{ 'finished (unpublished)' | translate }}</i>
</p> </p>
<os-poll-progress *ngIf="poll.canBeVotedFor()" [poll]="poll"></os-poll-progress> <os-poll-progress *ngIf="poll.canBeVotedFor()" [poll]="poll"></os-poll-progress>

View File

@ -112,6 +112,19 @@ export class PollCollectionComponent extends BaseViewComponentDirective implemen
} }
} }
/**
* TODO: Some non abstract base poll service was required
* @param poll
*/
public canManagePoll(poll: ViewBasePoll): boolean {
if (poll.pollClassType === PollClassType.Motion) {
return this.operator.hasPerms(this.permission.motionsCanManagePolls);
} else if (poll.pollClassType === PollClassType.Assignment) {
return this.operator.hasPerms(this.permission.assignmentsCanManage);
}
return false;
}
/** /**
* Helper function to detect new latest published polls and set them. * Helper function to detect new latest published polls and set them.
*/ */

View File

@ -33,6 +33,9 @@ export class PollProgressComponent extends BaseViewComponentDirective implements
return this.operator.hasPerms(this.permission.agendaCanManageListOfSpeakers); return this.operator.hasPerms(this.permission.agendaCanManageListOfSpeakers);
} }
/**
* TODO: some non apstract poll function service is required.
*/
private get canManagePoll(): boolean { private get canManagePoll(): boolean {
if (this.poll.pollClassType === PollClassType.Motion) { if (this.poll.pollClassType === PollClassType.Motion) {
return this.operator.hasPerms(this.permission.motionsCanManagePolls); return this.operator.hasPerms(this.permission.motionsCanManagePolls);