Merge pull request #5276 from tsiegleauq/changeable-created-polls

Remove pseudo-disabled values in poll form
This commit is contained in:
Emanuel Schütze 2020-03-24 16:01:17 +01:00 committed by GitHub
commit 91be76a263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 12 deletions

View File

@ -66,7 +66,13 @@ export class CheckInputComponent extends BaseViewComponent implements OnInit, Co
* Subscribes to value-changes of the form-control.
*/
public ngOnInit(): void {
this.subscriptions.push(this.contentForm.valueChanges.subscribe(value => this.sendValue(value)));
this.subscriptions.push(
this.contentForm.valueChanges.subscribe(value => {
if (value) {
this.sendValue(value);
}
})
);
}
/**

View File

@ -8,17 +8,6 @@
</mat-form-field>
</form>
<!-- TODO: rather disable forms than duplicate them -->
<div *ngIf="data && data.state" class="poll-preview-meta-info">
<span class="short-description" *ngFor="let value of pollValues">
<span class="short-description-label subtitle">
{{ value[0] }}
</span>
<span class="short-description-value">
{{ value[1] }}
</span>
</span>
</div>
<form [formGroup]="contentForm" class="poll-preview-meta-info-form">
<ng-container *ngIf="!data || !data.state || data.isCreated">
<!-- Poll Type -->

View File

@ -125,6 +125,10 @@ export class PollFormComponent<T extends ViewBasePoll, S extends PollService> ex
this.groupObservable = this.groupRepo.getViewModelListObservableWithoutDefaultGroup();
if (this.data) {
if (this.data.state) {
this.disablePollType();
}
if (this.data instanceof ViewAssignmentPoll) {
if (this.data.assignment && !this.data.votes_amount) {
this.data.votes_amount = this.data.assignment.open_posts;
@ -164,6 +168,10 @@ export class PollFormComponent<T extends ViewBasePoll, S extends PollService> ex
);
}
private disablePollType(): void {
this.contentForm.get('type').disable();
}
/**
* updates the available percent bases according to the pollmethod
* @param method the currently chosen pollmethod