Merge pull request #6050 from tsiegleauq/assignment-analog-general-selection

Add General x to analog polls
This commit is contained in:
Emanuel Schütze 2021-05-05 14:08:01 +02:00 committed by GitHub
commit 7cf22b86ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 22 deletions

View File

@ -49,7 +49,7 @@
</div> </div>
</td> </td>
</tr> </tr>
<tr *ngIf="isPercentBaseEntitled" class="entitled-users-row"> <tr *ngIf="isPercentBaseEntitled && poll.entitled_users_at_stop" class="entitled-users-row">
<td>{{ 'Entitled users' | translate }}</td> <td>{{ 'Entitled users' | translate }}</td>
<td class="result"> <td class="result">
<div class="single-result"> <div class="single-result">

View File

@ -149,7 +149,7 @@
<os-sorting-list <os-sorting-list
[input]="assignment.assignment_related_users" [input]="assignment.assignment_related_users"
[live]="true" [live]="true"
[count]="assignment.number_poll_candidates" [count]="true"
[enable]="hasPerms('manage')" [enable]="hasPerms('manage')"
(sortEvent)="onSortingChange($event)" (sortEvent)="onSortingChange($event)"
> >

View File

@ -12,12 +12,12 @@
<!-- Candidates Values --> <!-- Candidates Values -->
<div formGroupName="options"> <div formGroupName="options">
<div *ngFor="let option of options" class="votes-grid"> <div *ngFor="let option of options" class="votes-grid">
<div> <div class="candidate">
<span *ngIf="option.user">{{ option.user.getFullName() }}</span> <span *ngIf="option.user">{{ option.user.getFullName() }}</span>
<i *ngIf="!option.user">{{ unknownUserLabel | translate }}</i> <i *ngIf="!option.user">{{ unknownUserLabel | translate }}</i>
</div> </div>
<div> <div class="amount">
<div *ngFor="let value of analogPollValues" [formGroupName]="option.user_id"> <div *ngFor="let value of analogPollValues" [formGroupName]="option.user_id">
<os-check-input <os-check-input
[placeholder]="voteValueVerbose[value] | translate" [placeholder]="voteValueVerbose[value] | translate"
@ -31,21 +31,10 @@
</div> </div>
</div> </div>
<!-- Sum Values -->
<div *ngFor="let value of sumValues" class="votes-grid">
<div></div>
<os-check-input
[placeholder]="generalValueVerbose[value] | translate"
[checkboxValue]="-1"
inputType="number"
[checkboxLabel]="'majority' | translate"
[formControlName]="value"
></os-check-input>
</div>
<!-- Global Values --> <!-- Global Values -->
<div> <div class="votes-grid">
<os-check-input <os-check-input
class="amount"
*ngIf="globalYesEnabled" *ngIf="globalYesEnabled"
placeholder="{{ PollPropertyVerbose.global_yes | translate }}" placeholder="{{ PollPropertyVerbose.global_yes | translate }}"
[checkboxValue]="-1" [checkboxValue]="-1"
@ -53,8 +42,11 @@
[checkboxLabel]="'majority' | translate" [checkboxLabel]="'majority' | translate"
formControlName="amount_global_yes" formControlName="amount_global_yes"
></os-check-input> ></os-check-input>
</div>
<div class="votes-grid">
<os-check-input <os-check-input
class="amount"
*ngIf="globalNoEnabled" *ngIf="globalNoEnabled"
placeholder="{{ PollPropertyVerbose.global_no | translate }}" placeholder="{{ PollPropertyVerbose.global_no | translate }}"
[checkboxValue]="-1" [checkboxValue]="-1"
@ -62,8 +54,11 @@
[checkboxLabel]="'majority' | translate" [checkboxLabel]="'majority' | translate"
formControlName="amount_global_no" formControlName="amount_global_no"
></os-check-input> ></os-check-input>
</div>
<div class="votes-grid">
<os-check-input <os-check-input
class="amount"
*ngIf="globalAbstainEnabled" *ngIf="globalAbstainEnabled"
placeholder="{{ PollPropertyVerbose.global_abstain | translate }}" placeholder="{{ PollPropertyVerbose.global_abstain | translate }}"
[checkboxValue]="-1" [checkboxValue]="-1"
@ -72,6 +67,18 @@
formControlName="amount_global_abstain" formControlName="amount_global_abstain"
></os-check-input> ></os-check-input>
</div> </div>
<!-- Sum Values -->
<div *ngFor="let value of sumValues" class="votes-grid">
<os-check-input
class="amount"
[placeholder]="generalValueVerbose[value] | translate"
[checkboxValue]="-1"
inputType="number"
[checkboxLabel]="'majority' | translate"
[formControlName]="value"
></os-check-input>
</div>
</form> </form>
<!-- Publish Check --> <!-- Publish Check -->

View File

@ -4,6 +4,16 @@
margin-bottom: 10px; margin-bottom: 10px;
align-items: baseline; align-items: baseline;
grid-template-columns: auto max-content; grid-template-columns: auto max-content;
grid-template-areas: 'candidate amount';
.candidate {
grid-area: candidate;
}
.amount {
grid-area: amount;
}
.mat-form-field { .mat-form-field {
width: 100%; width: 100%;
} }

View File

@ -228,7 +228,7 @@ export class AssignmentPollService extends PollService {
totalByBase = poll.votesvalid; totalByBase = poll.votesvalid;
break; break;
case AssignmentPollPercentBase.Entitled: case AssignmentPollPercentBase.Entitled:
totalByBase = poll.entitled_users_at_stop.length; totalByBase = poll?.entitled_users_at_stop?.length || 0;
break; break;
case AssignmentPollPercentBase.Cast: case AssignmentPollPercentBase.Cast:
totalByBase = poll.votescast; totalByBase = poll.votescast;

View File

@ -59,7 +59,7 @@
<ng-container formGroupName="votes_amount" *ngIf="isEVotingSelected"> <ng-container formGroupName="votes_amount" *ngIf="isEVotingSelected">
<!-- Min Amount of Votes --> <!-- Min Amount of Votes -->
<mat-form-field *ngIf="showAmountAndGlobal(data)"> <mat-form-field *ngIf="showMinMaxVotes(data)">
<input <input
type="number" type="number"
matInput matInput
@ -75,7 +75,7 @@
</mat-form-field> </mat-form-field>
<!-- Max Amount of Votes --> <!-- Max Amount of Votes -->
<mat-form-field *ngIf="showAmountAndGlobal(data)"> <mat-form-field *ngIf="showMinMaxVotes(data)">
<input <input
type="number" type="number"
matInput matInput
@ -89,7 +89,7 @@
</div> </div>
<!-- Amount of Votes and global options --> <!-- Amount of Votes and global options -->
<div class="global-options" *ngIf="isEVotingSelected && showAmountAndGlobal(data)"> <div class="global-options">
<mat-checkbox formControlName="global_yes"> <mat-checkbox formControlName="global_yes">
{{ PollPropertyVerbose.global_yes | translate }} {{ PollPropertyVerbose.global_yes | translate }}
</mat-checkbox> </mat-checkbox>

View File

@ -215,7 +215,7 @@ export class PollFormComponent<T extends ViewBasePoll, S extends PollService>
this.pollTypeControl.disable(); this.pollTypeControl.disable();
} }
public showAmountAndGlobal(data: any): boolean { public showMinMaxVotes(data: any): boolean {
const selectedPollMethod: AssignmentPollMethod = this.pollMethodControl.value; const selectedPollMethod: AssignmentPollMethod = this.pollMethodControl.value;
return (selectedPollMethod === 'Y' || selectedPollMethod === 'N') && (!data || !data.state || data.isCreated); return (selectedPollMethod === 'Y' || selectedPollMethod === 'N') && (!data || !data.state || data.isCreated);
} }