remove Motion polls show global values

Motion polls were displaying global abstain, etc
This commit is contained in:
Sean 2021-05-06 14:21:04 +02:00
parent 2a7b55f11e
commit 3402928935
5 changed files with 24 additions and 6 deletions

View File

@ -1,4 +1,5 @@
<os-poll-form <os-poll-form
[pollClassType]="pollClassType.Assignment"
[data]="pollData" [data]="pollData"
[pollService]="assignmentPollService" [pollService]="assignmentPollService"
[pollMethods]="AssignmentPollMethodVerbose" [pollMethods]="AssignmentPollMethodVerbose"

View File

@ -1,4 +1,5 @@
<os-poll-form <os-poll-form
[pollClassType]="pollClassType.Motion"
[data]="pollData" [data]="pollData"
[pollService]="motionPollService" [pollService]="motionPollService"
[percentBases]="PercentBaseVerbose" [percentBases]="PercentBaseVerbose"

View File

@ -10,7 +10,7 @@ import { OneOfValidator } from 'app/shared/validators/one-of-validator';
import { BaseViewComponentDirective } from 'app/site/base/base-view'; import { BaseViewComponentDirective } from 'app/site/base/base-view';
import { PollFormComponent } from './poll-form/poll-form.component'; import { PollFormComponent } from './poll-form/poll-form.component';
import { PollService } from '../services/poll.service'; import { PollService } from '../services/poll.service';
import { ViewBasePoll } from '../models/view-base-poll'; import { PollClassType, ViewBasePoll } from '../models/view-base-poll';
/** /**
* A dialog for updating the values of a poll. * A dialog for updating the values of a poll.
@ -20,6 +20,7 @@ export abstract class BasePollDialogComponent<
S extends PollService S extends PollService
> extends BaseViewComponentDirective { > extends BaseViewComponentDirective {
public publishImmediately: boolean; public publishImmediately: boolean;
public pollClassType = PollClassType;
protected pollForm: PollFormComponent<T, S>; protected pollForm: PollFormComponent<T, S>;

View File

@ -89,7 +89,7 @@
</div> </div>
<!-- Amount of Votes and global options --> <!-- Amount of Votes and global options -->
<div class="global-options"> <div class="global-options" *ngIf="isAssignmentPoll">
<mat-checkbox formControlName="global_yes"> <mat-checkbox formControlName="global_yes">
{{ PollPropertyVerbose.global_yes | translate }} {{ PollPropertyVerbose.global_yes | translate }}
</mat-checkbox> </mat-checkbox>

View File

@ -64,6 +64,9 @@ export class PollFormComponent<T extends ViewBasePoll, S extends PollService>
@Input() @Input()
private pollService: S; private pollService: S;
@Input()
public pollClassType: PollClassType;
/** /**
* The different types the poll can accept. * The different types the poll can accept.
*/ */
@ -105,6 +108,10 @@ export class PollFormComponent<T extends ViewBasePoll, S extends PollService>
} }
} }
public get isAssignmentPoll(): boolean {
return this.pollClassType === PollClassType.Assignment;
}
public get isEVotingSelected(): boolean { public get isEVotingSelected(): boolean {
return this.pollTypeControl?.value !== PollType.Analog || false; return this.pollTypeControl?.value !== PollType.Analog || false;
} }
@ -140,6 +147,7 @@ export class PollFormComponent<T extends ViewBasePoll, S extends PollService>
) { ) {
super(title, translate, snackbar); super(title, translate, snackbar);
this.initContentForm(); this.initContentForm();
this.groupObservable = this.groupRepo.getViewModelListObservableWithoutDefaultGroup();
} }
/** /**
@ -147,9 +155,6 @@ export class PollFormComponent<T extends ViewBasePoll, S extends PollService>
* Sets the observable for groups. * Sets the observable for groups.
*/ */
public ngOnInit(): void { public ngOnInit(): void {
// without default group since default cant ever vote
this.groupObservable = this.groupRepo.getViewModelListObservableWithoutDefaultGroup();
if (this.data) { if (this.data) {
if (this.data.state) { if (this.data.state) {
this.disablePollType(); this.disablePollType();
@ -312,7 +317,7 @@ export class PollFormComponent<T extends ViewBasePoll, S extends PollService>
] ]
]; ];
// show pollmethod only for assignment polls // show pollmethod only for assignment polls
if (this.data.pollClassType === PollClassType.Assignment) { if (this.isAssignmentPoll) {
this.pollValues.push([ this.pollValues.push([
this.pollService.getVerboseNameForKey('pollmethod'), this.pollService.getVerboseNameForKey('pollmethod'),
this.pollService.getVerboseNameForValue('pollmethod', data.pollmethod) this.pollService.getVerboseNameForValue('pollmethod', data.pollmethod)
@ -375,6 +380,16 @@ export class PollFormComponent<T extends ViewBasePoll, S extends PollService>
global_yes: [false], global_yes: [false],
global_no: [false], global_no: [false],
global_abstain: [false] global_abstain: [false]
/**
* TODO, global is not required for motions, current logic does not
* survive changes after constructor due strickt access calls
* Change to observe
*/
// ...(this.isAssignmentPoll && {
// global_yes: [false],
// global_no: [false],
// global_abstain: [false]
// })
}); });
} }