Fixes permissions for assignments
- There were some fields that user could see/click/handle, although the user has not the correct permission for the action
This commit is contained in:
parent
df1047fc76
commit
09b0d19de0
@ -108,7 +108,7 @@ export class PermsDirective implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
/**
|
||||
* COmes from the view.
|
||||
* Comes from the view.
|
||||
*/
|
||||
@Input('osPermsComplement')
|
||||
public set osPermsComplement(value: boolean) {
|
||||
|
@ -68,11 +68,25 @@ export abstract class BasePoll<T = any, O extends BaseOption<any> = any> extends
|
||||
return this.state === PollState.Published;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the state is finished.
|
||||
*/
|
||||
public get isFinished(): boolean {
|
||||
return this.state === PollState.Finished;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the state is published.
|
||||
*/
|
||||
public get isPublished(): boolean {
|
||||
return this.state === PollState.Published;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the state is finished or published
|
||||
*/
|
||||
public get stateHasVotes(): boolean {
|
||||
return this.state === PollState.Finished || this.state === PollState.Published;
|
||||
return this.isFinished || this.isPublished;
|
||||
}
|
||||
|
||||
protected getDecimalFields(): (keyof BasePoll<T, O>)[] {
|
||||
|
@ -70,9 +70,7 @@
|
||||
<!-- closed polls -->
|
||||
<ng-container *ngIf="assignment">
|
||||
<ng-container *ngFor="let poll of assignment.polls | reverse; trackBy: trackByIndex">
|
||||
<mat-card class="os-card">
|
||||
<os-assignment-poll [poll]="poll"> </os-assignment-poll>
|
||||
</mat-card>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</div>
|
||||
@ -143,12 +141,12 @@
|
||||
[input]="assignment.assignment_related_users"
|
||||
[live]="true"
|
||||
[count]="assignment.number_poll_candidates"
|
||||
[enable]="hasPerms('addOthers')"
|
||||
[enable]="hasPerms('manage')"
|
||||
(sortEvent)="onSortingChange($event)"
|
||||
>
|
||||
<!-- implicit item references into the component using ng-template slot -->
|
||||
<ng-template let-item>
|
||||
<span *ngIf="hasPerms('addOthers')">
|
||||
<span *ngIf="hasPerms('manage')">
|
||||
<button
|
||||
mat-icon-button
|
||||
matTooltip="{{ 'Remove candidate' | translate }}"
|
||||
@ -170,7 +168,6 @@
|
||||
>
|
||||
<mat-form-field>
|
||||
<os-search-value-selector
|
||||
class="search-bar"
|
||||
formControlName="userId"
|
||||
[multiple]="false"
|
||||
placeholder="{{ 'Select a new candidate' | translate }}"
|
||||
|
@ -39,13 +39,10 @@
|
||||
padding: 15px 25px 0 25px;
|
||||
width: auto;
|
||||
|
||||
.search-bar {
|
||||
display: grid;
|
||||
.mat-form-field {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ballot-controls-grid {
|
||||
|
@ -1,10 +1,30 @@
|
||||
<div class="assignment-poll-wrapper" *ngIf="poll">
|
||||
|
||||
<div class="">
|
||||
|
||||
<mat-card class="os-card" *ngIf="poll">
|
||||
<div class="assignment-poll-wrapper">
|
||||
<div class="assignment-poll-title-header">
|
||||
<mat-card-title>
|
||||
<a routerLink="/assignments/polls/{{ poll.id }}">
|
||||
{{ poll.title }}
|
||||
</a>
|
||||
</mat-card-title>
|
||||
<div class="poll-properties">
|
||||
<mat-chip
|
||||
*osPerms="'assignments.can_manage'"
|
||||
class="poll-state active"
|
||||
[disableRipple]="true"
|
||||
[matMenuTriggerFor]="triggerMenu"
|
||||
[ngClass]="poll.stateVerbose.toLowerCase()"
|
||||
>
|
||||
{{ poll.stateVerbose | translate }}
|
||||
</mat-chip>
|
||||
<mat-chip
|
||||
*ngIf="!canManage && poll.isPublished"
|
||||
[disableRipple]="true"
|
||||
class="poll-state active"
|
||||
[ngClass]="poll.stateVerbose.toLowerCase()"
|
||||
>
|
||||
{{ poll.stateVerbose | translate }}
|
||||
</mat-chip>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="poll-menu">
|
||||
<!-- Buttons -->
|
||||
<button
|
||||
@ -16,30 +36,14 @@
|
||||
<mat-icon>more_horiz</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<h3>
|
||||
<a routerLink="/assignments/polls/{{ poll.id }}">
|
||||
{{ poll.title }}
|
||||
</a>
|
||||
</h3>
|
||||
<div class="poll-properties">
|
||||
<mat-chip
|
||||
class="poll-state active"
|
||||
[matMenuTriggerFor]="triggerMenu"
|
||||
[ngClass]="poll.stateVerbose.toLowerCase()"
|
||||
>
|
||||
{{ poll.stateVerbose }}
|
||||
</mat-chip>
|
||||
</div>
|
||||
</div>
|
||||
<div *ngIf="poll.stateHasVotes">
|
||||
<div *ngIf="hasVotes">
|
||||
<os-charts [type]="chartType" [labels]="candidatesLabels" [data]="chartDataSubject"></os-charts>
|
||||
</div>
|
||||
</div>
|
||||
<os-assignment-poll-vote *ngIf="poll.canBeVotedFor" [poll]="poll"></os-assignment-poll-vote>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card>
|
||||
|
||||
<mat-menu #triggerMenu="matMenu">
|
||||
<ng-container *ngIf="poll">
|
||||
|
@ -11,6 +11,7 @@ import { AssignmentPollRepositoryService } from 'app/core/repositories/assignmen
|
||||
import { PromptService } from 'app/core/ui-services/prompt.service';
|
||||
import { ChartType } from 'app/shared/components/charts/charts.component';
|
||||
import { AssignmentPollMethods } from 'app/shared/models/assignments/assignment-poll';
|
||||
import { PollState } from 'app/shared/models/poll/base-poll';
|
||||
import { BasePollComponent } from 'app/site/polls/components/base-poll.component';
|
||||
import { PollService } from 'app/site/polls/services/poll.service';
|
||||
import { AssignmentPollDialogService } from '../../services/assignment-poll-dialog.service';
|
||||
@ -67,6 +68,10 @@ export class AssignmentPollComponent extends BasePollComponent<ViewAssignmentPol
|
||||
return this.operator.hasPerms('assignments.can_see');
|
||||
}
|
||||
|
||||
public get hasVotes(): boolean {
|
||||
return (this.canManage && this.poll.state === PollState.Finished) || this.poll.state === PollState.Published;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns true if the description on the form differs from the poll's description
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user