From e72bcc1eaf254657fc19f0a0ae3c226e95041cc7 Mon Sep 17 00:00:00 2001 From: Joshua Sangmeister Date: Tue, 25 Feb 2020 15:12:54 +0100 Subject: [PATCH] removed default group from 'entitled to vote' selection --- .../repositories/users/group-repository.service.ts | 10 ++++++++++ .../components/config-field/config-field.component.ts | 4 +++- .../polls/components/poll-form/poll-form.component.ts | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/client/src/app/core/repositories/users/group-repository.service.ts b/client/src/app/core/repositories/users/group-repository.service.ts index a0c40a638..b7cc1cfde 100644 --- a/client/src/app/core/repositories/users/group-repository.service.ts +++ b/client/src/app/core/repositories/users/group-repository.service.ts @@ -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 { + // since groups are sorted by id, default is always the first entry + return this.getViewModelListObservable().pipe(map(groups => groups.slice(1))); + } } diff --git a/client/src/app/site/config/components/config-field/config-field.component.ts b/client/src/app/site/config/components/config-field/config-field.component.ts index aa734cde1..d6df54966 100644 --- a/client/src/app/site/config/components/config-field/config-field.component.ts +++ b/client/src/app/site/config/components/config-field/config-field.component.ts @@ -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: [''], diff --git a/client/src/app/site/polls/components/poll-form/poll-form.component.ts b/client/src/app/site/polls/components/poll-form/poll-form.component.ts index 421baa499..7a6196357 100644 --- a/client/src/app/site/polls/components/poll-form/poll-form.component.ts +++ b/client/src/app/site/polls/components/poll-form/poll-form.component.ts @@ -102,7 +102,8 @@ export class PollFormComponent 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) {