Remove pseudo-disabled values in poll form

Removed the previously disabled-looking poll options from the poll form
component.
I figguered that it would be more intuitive and closer to my
expectations if I could change the poll values even if the poll was
already created.
This commit is contained in:
Sean 2020-03-24 14:22:59 +01:00
parent 2fb372ead9
commit 7af2f70494
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