removed default group from 'entitled to vote' selection

This commit is contained in:
Joshua Sangmeister 2020-02-25 15:12:54 +01:00 committed by FinnStutzenstein
parent 97a5bb4aa6
commit e72bcc1eaf
3 changed files with 15 additions and 2 deletions

View File

@ -1,6 +1,8 @@
import { Injectable } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { HttpService } from 'app/core/core-services/http.service';
import { RelationManagerService } from 'app/core/core-services/relation-manager.service';
@ -194,4 +196,12 @@ export class GroupRepositoryService extends BaseRepository<ViewGroup, Group, Gro
}
});
}
/**
* Returns an Observable for all groups except the default group.
*/
public getViewModelListObservableWithoutDefaultGroup(): Observable<ViewGroup[]> {
// since groups are sorted by id, default is always the first entry
return this.getViewModelListObservable().pipe(map(groups => groups.slice(1)));
}
}

View File

@ -147,7 +147,9 @@ export class ConfigFieldComponent extends BaseComponent implements OnInit, OnDes
*/
public ngOnInit(): void {
// filter out empty results in group observable. We never have no groups and it messes up the settings change detection
this.groupObservable = this.groupRepo.getViewModelListObservable().pipe(filter(groups => !!groups.length));
this.groupObservable = this.groupRepo
.getViewModelListObservableWithoutDefaultGroup()
.pipe(filter(groups => !!groups.length));
this.form = this.formBuilder.group({
value: [''],

View File

@ -102,7 +102,8 @@ export class PollFormComponent<T extends ViewBasePoll> extends BaseViewComponent
* Sets the observable for groups.
*/
public ngOnInit(): void {
this.groupObservable = this.groupRepo.getViewModelListObservable();
// without default group since default cant ever vote
this.groupObservable = this.groupRepo.getViewModelListObservableWithoutDefaultGroup();
if (this.data) {
if (this.data instanceof ViewAssignmentPoll) {