diff --git a/client/src/app/site/modules/site-wrapper/services/voting-banner.service.ts b/client/src/app/site/modules/site-wrapper/services/voting-banner.service.ts index 8e47ba0096..ad25111bb1 100644 --- a/client/src/app/site/modules/site-wrapper/services/voting-banner.service.ts +++ b/client/src/app/site/modules/site-wrapper/services/voting-banner.service.ts @@ -9,6 +9,7 @@ import { VotingService } from 'src/app/site/pages/meetings/modules/poll/services import { ViewPoll } from 'src/app/site/pages/meetings/pages/polls'; import { ActiveMeetingService } from 'src/app/site/pages/meetings/services/active-meeting.service'; import { ActivePollsService } from 'src/app/site/pages/meetings/services/active-polls.service'; +import { MeetingSettingsService } from 'src/app/site/pages/meetings/services/meeting-settings.service'; import { OperatorService } from 'src/app/site/services/operator.service'; import { BannerDefinition, BannerService } from './banner.service'; @@ -37,7 +38,8 @@ export class VotingBannerService { private activeMeeting: ActiveMeetingService, private sendVotesService: VoteControllerService, private operator: OperatorService, - private activePolls: ActivePollsService + private activePolls: ActivePollsService, + private meetingSettingsService: MeetingSettingsService ) { combineLatest([ this.activeMeeting.meetingIdObservable.pipe(distinctUntilChanged()), @@ -48,7 +50,9 @@ export class VotingBannerService { return prevStarted.length === currStarted.length && currStarted.equals(prevStarted); }) - ) + ), + this.meetingSettingsService.get(`users_enable_vote_delegations`).pipe(distinctUntilChanged()), + this.meetingSettingsService.get(`users_forbid_delegator_to_vote`).pipe(distinctUntilChanged()) ]).subscribe(([_, polls]) => this.updateVotablePollSubscription(polls)); } @@ -60,7 +64,7 @@ export class VotingBannerService { }); } - private updateBanner(polls: ViewPoll[], voted: { [key: Id]: Id[] }) { + private updateBanner(polls: ViewPoll[], voted: { [key: Id]: Id[] }): void { if (this.activeMeeting.meetingId) { const checkUsers = [this.operator.user, ...(this.operator.user.vote_delegations_from() || [])]; this.pollsToVote = polls.filter( diff --git a/client/src/app/site/pages/meetings/modules/poll/components/base-poll-vote/base-poll-vote.component.ts b/client/src/app/site/pages/meetings/modules/poll/components/base-poll-vote/base-poll-vote.component.ts index 0b1a014f11..5df06f20de 100644 --- a/client/src/app/site/pages/meetings/modules/poll/components/base-poll-vote/base-poll-vote.component.ts +++ b/client/src/app/site/pages/meetings/modules/poll/components/base-poll-vote/base-poll-vote.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectorRef, Directive, inject, Input, OnInit } from '@angular/core'; import { UntypedFormControl, Validators } from '@angular/forms'; import { marker as _ } from '@colsen1991/ngx-translate-extract-marker'; -import { BehaviorSubject, debounceTime, Observable } from 'rxjs'; +import { BehaviorSubject, combineLatest, debounceTime, distinctUntilChanged, Observable } from 'rxjs'; import { Id } from 'src/app/domain/definitions/key-types'; import { GlobalVote, @@ -453,6 +453,16 @@ export abstract class BasePollVoteComponent e } }) ); + this.subscriptions.push( + combineLatest([ + this.meetingSettingsService.get(`users_enable_vote_delegations`).pipe(distinctUntilChanged()), + this.meetingSettingsService.get(`users_forbid_delegator_to_vote`).pipe(distinctUntilChanged()) + ]).subscribe(_ => { + for (const key of Object.keys(this._canVoteForSubjectMap)) { + this._canVoteForSubjectMap[+key].next(this.canVote(this._delegationsMap[+key])); + } + }) + ); } private setupDelegations(): void { diff --git a/client/src/app/site/pages/meetings/modules/poll/components/poll-cannot-vote-message/poll-cannot-vote-message.component.ts b/client/src/app/site/pages/meetings/modules/poll/components/poll-cannot-vote-message/poll-cannot-vote-message.component.ts index be479a7005..cd26eeab1a 100644 --- a/client/src/app/site/pages/meetings/modules/poll/components/poll-cannot-vote-message/poll-cannot-vote-message.component.ts +++ b/client/src/app/site/pages/meetings/modules/poll/components/poll-cannot-vote-message/poll-cannot-vote-message.component.ts @@ -1,5 +1,5 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input } from '@angular/core'; -import { debounceTime } from 'rxjs'; +import { combineLatest, debounceTime, distinctUntilChanged } from 'rxjs'; import { OperatorService } from 'src/app/site/services/operator.service'; import { BaseMeetingComponent } from '../../../../base/base-meeting.component'; @@ -45,6 +45,14 @@ export class PollCannotVoteMessageComponent extends BaseMeetingComponent { this.cd.markForCheck(); }) ); + this.subscriptions.push( + combineLatest([ + this.meetingSettingsService.get(`users_enable_vote_delegations`).pipe(distinctUntilChanged()), + this.meetingSettingsService.get(`users_forbid_delegator_to_vote`).pipe(distinctUntilChanged()) + ]).subscribe(_ => { + this.cd.markForCheck(); + }) + ); } public getVotingError(user: ViewUser = this.user): string {