diff --git a/client/src/app/core/ui-services/base-poll-dialog.service.ts b/client/src/app/core/ui-services/base-poll-dialog.service.ts index 0e45c36c1..902c01d1f 100644 --- a/client/src/app/core/ui-services/base-poll-dialog.service.ts +++ b/client/src/app/core/ui-services/base-poll-dialog.service.ts @@ -8,6 +8,7 @@ import { PollState, PollType } from 'app/shared/models/poll/base-poll'; import { mediumDialogSettings } from 'app/shared/utils/dialog-settings'; import { BasePollDialogComponent } from 'app/site/polls/components/base-poll-dialog.component'; import { ViewBasePoll } from 'app/site/polls/models/view-base-poll'; +import { PollService } from 'app/site/polls/services/poll.service'; /** * Abstract class for showing a poll dialog. Has to be subclassed to provide the right `PollService` @@ -15,8 +16,8 @@ import { ViewBasePoll } from 'app/site/polls/models/view-base-poll'; @Injectable({ providedIn: 'root' }) -export abstract class BasePollDialogService { - protected dialogComponent: ComponentType>; +export abstract class BasePollDialogService { + protected dialogComponent: ComponentType>; public constructor(private dialog: MatDialog, private mapper: CollectionStringMapperService) {} diff --git a/client/src/app/site/assignments/components/assignment-poll-dialog/assignment-poll-dialog.component.html b/client/src/app/site/assignments/components/assignment-poll-dialog/assignment-poll-dialog.component.html index b75d68271..b5c2245ce 100644 --- a/client/src/app/site/assignments/components/assignment-poll-dialog/assignment-poll-dialog.component.html +++ b/client/src/app/site/assignments/components/assignment-poll-dialog/assignment-poll-dialog.component.html @@ -1,5 +1,6 @@ implements OnInit { +export class AssignmentPollDialogComponent extends BasePollDialogComponent + implements OnInit { /** * The summary values that will have fields in the dialog */ @@ -44,7 +46,7 @@ export class AssignmentPollDialogComponent extends BasePollDialogComponent; + protected pollForm: PollFormComponent; /** * vote entries for each option in this component. Is empty if method @@ -80,7 +82,8 @@ export class AssignmentPollDialogComponent extends BasePollDialogComponent>, + public dialogRef: MatDialogRef>, + public assignmentPollService: AssignmentPollService, @Inject(MAT_DIALOG_DATA) public pollData: Partial ) { super(title, translate, matSnackbar, dialogRef); diff --git a/client/src/app/site/assignments/components/assignment-poll/assignment-poll.component.ts b/client/src/app/site/assignments/components/assignment-poll/assignment-poll.component.ts index 67ececee1..f34baf95d 100644 --- a/client/src/app/site/assignments/components/assignment-poll/assignment-poll.component.ts +++ b/client/src/app/site/assignments/components/assignment-poll/assignment-poll.component.ts @@ -25,7 +25,8 @@ import { ViewAssignmentPoll } from '../../models/view-assignment-poll'; templateUrl: './assignment-poll.component.html', styleUrls: ['./assignment-poll.component.scss'] }) -export class AssignmentPollComponent extends BasePollComponent implements OnInit { +export class AssignmentPollComponent extends BasePollComponent + implements OnInit { @Input() public set poll(value: ViewAssignmentPoll) { this.initPoll(value); diff --git a/client/src/app/site/assignments/services/assignment-poll-dialog.service.ts b/client/src/app/site/assignments/services/assignment-poll-dialog.service.ts index 5432c4863..86f1a65da 100644 --- a/client/src/app/site/assignments/services/assignment-poll-dialog.service.ts +++ b/client/src/app/site/assignments/services/assignment-poll-dialog.service.ts @@ -4,6 +4,7 @@ import { MatDialog } from '@angular/material'; import { CollectionStringMapperService } from 'app/core/core-services/collection-string-mapper.service'; import { BasePollDialogService } from 'app/core/ui-services/base-poll-dialog.service'; import { AssignmentPollDialogComponent } from 'app/site/assignments/components/assignment-poll-dialog/assignment-poll-dialog.component'; +import { AssignmentPollService } from './assignment-poll.service'; import { ViewAssignmentPoll } from '../models/view-assignment-poll'; /** @@ -12,7 +13,7 @@ import { ViewAssignmentPoll } from '../models/view-assignment-poll'; @Injectable({ providedIn: 'root' }) -export class AssignmentPollDialogService extends BasePollDialogService { +export class AssignmentPollDialogService extends BasePollDialogService { protected dialogComponent = AssignmentPollDialogComponent; public constructor(dialog: MatDialog, mapper: CollectionStringMapperService) { diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.html b/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.html index 1f01116f8..8485ec086 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.html +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.html @@ -1,4 +1,9 @@ - +
diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.ts b/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.ts index dc927389e..73b1f2724 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.ts +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component.ts @@ -7,6 +7,7 @@ import { TranslateService } from '@ngx-translate/core'; import { LOWEST_VOTE_VALUE } from 'app/shared/models/poll/base-poll'; import { ViewMotionPoll } from 'app/site/motions/models/view-motion-poll'; +import { MotionPollService } from 'app/site/motions/services/motion-poll.service'; import { BasePollDialogComponent } from 'app/site/polls/components/base-poll-dialog.component'; import { PollFormComponent } from 'app/site/polls/components/poll-form/poll-form.component'; import { PercentBaseVerbose } from 'app/site/polls/models/view-base-poll'; @@ -16,17 +17,19 @@ import { PercentBaseVerbose } from 'app/site/polls/models/view-base-poll'; templateUrl: './motion-poll-dialog.component.html', styleUrls: ['./motion-poll-dialog.component.scss'] }) -export class MotionPollDialogComponent extends BasePollDialogComponent implements OnInit { +export class MotionPollDialogComponent extends BasePollDialogComponent + implements OnInit { public PercentBaseVerbose = PercentBaseVerbose; @ViewChild('pollForm', { static: false }) - protected pollForm: PollFormComponent; + protected pollForm: PollFormComponent; public constructor( title: Title, translate: TranslateService, matSnackbar: MatSnackBar, - public dialogRef: MatDialogRef>, + public motionPollService: MotionPollService, + public dialogRef: MatDialogRef>, private formBuilder: FormBuilder, @Inject(MAT_DIALOG_DATA) public pollData: Partial ) { diff --git a/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.ts b/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.ts index 4bcd7516a..e891239e8 100644 --- a/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.ts +++ b/client/src/app/site/motions/modules/motion-poll/motion-poll/motion-poll.component.ts @@ -14,7 +14,7 @@ import { MotionPollDialogService } from 'app/site/motions/services/motion-poll-d import { MotionPollPdfService } from 'app/site/motions/services/motion-poll-pdf.service'; import { MotionPollService } from 'app/site/motions/services/motion-poll.service'; import { BasePollComponent } from 'app/site/polls/components/base-poll.component'; -import { PollService, PollTableData } from 'app/site/polls/services/poll.service'; +import { PollTableData } from 'app/site/polls/services/poll.service'; /** * Component to show a motion-poll. @@ -24,7 +24,7 @@ import { PollService, PollTableData } from 'app/site/polls/services/poll.service templateUrl: './motion-poll.component.html', styleUrls: ['./motion-poll.component.scss'] }) -export class MotionPollComponent extends BasePollComponent { +export class MotionPollComponent extends BasePollComponent { @Input() public set poll(value: ViewMotionPoll) { this.initPoll(value); @@ -41,11 +41,11 @@ export class MotionPollComponent extends BasePollComponent { } public get showChart(): boolean { - return this.motionPollService.showChart(this.poll); + return this.pollService.showChart(this.poll); } public get reducedPollTableData(): PollTableData[] { - return this.motionPollService + return this.pollService .generateTableData(this.poll) .filter(data => ['yes', 'no', 'abstain', 'votesinvalid'].includes(data.votingOption)); } @@ -63,6 +63,10 @@ export class MotionPollComponent extends BasePollComponent { return false; } + public get isEVotingEnabled(): boolean { + return this.pollService.isElectronicVotingEnabled; + } + /** * Constructor. * @@ -75,14 +79,13 @@ export class MotionPollComponent extends BasePollComponent { public constructor( titleService: Title, matSnackBar: MatSnackBar, - protected translate: TranslateService, - dialog: MatDialog, promptService: PromptService, - public pollRepo: MotionPollRepositoryService, pollDialog: MotionPollDialogService, - public pollService: PollService, + protected dialog: MatDialog, + protected pollRepo: MotionPollRepositoryService, + protected translate: TranslateService, + private pollService: MotionPollService, private pdfService: MotionPollPdfService, - private motionPollService: MotionPollService, private operator: OperatorService ) { super(titleService, matSnackBar, translate, dialog, promptService, pollRepo, pollDialog); diff --git a/client/src/app/site/motions/services/motion-poll-dialog.service.ts b/client/src/app/site/motions/services/motion-poll-dialog.service.ts index 8e83ced21..be5793528 100644 --- a/client/src/app/site/motions/services/motion-poll-dialog.service.ts +++ b/client/src/app/site/motions/services/motion-poll-dialog.service.ts @@ -4,6 +4,7 @@ import { MatDialog } from '@angular/material'; import { CollectionStringMapperService } from 'app/core/core-services/collection-string-mapper.service'; import { BasePollDialogService } from 'app/core/ui-services/base-poll-dialog.service'; import { MotionPollDialogComponent } from 'app/site/motions/modules/motion-poll/motion-poll-dialog/motion-poll-dialog.component'; +import { MotionPollService } from './motion-poll.service'; import { ViewMotionPoll } from '../models/view-motion-poll'; /** @@ -12,7 +13,7 @@ import { ViewMotionPoll } from '../models/view-motion-poll'; @Injectable({ providedIn: 'root' }) -export class MotionPollDialogService extends BasePollDialogService { +export class MotionPollDialogService extends BasePollDialogService { protected dialogComponent = MotionPollDialogComponent; public constructor(dialog: MatDialog, mapper: CollectionStringMapperService) { diff --git a/client/src/app/site/polls/components/base-poll-detail.component.ts b/client/src/app/site/polls/components/base-poll-detail.component.ts index ed4400d34..8530fa1b5 100644 --- a/client/src/app/site/polls/components/base-poll-detail.component.ts +++ b/client/src/app/site/polls/components/base-poll-detail.component.ts @@ -100,7 +100,7 @@ export abstract class BasePollDetailComponent, + protected pollDialog: BasePollDialogService, protected pollService: S, protected votesRepo: BaseRepository ) { diff --git a/client/src/app/site/polls/components/base-poll-dialog.component.ts b/client/src/app/site/polls/components/base-poll-dialog.component.ts index 99212eebd..9fd3032c4 100644 --- a/client/src/app/site/polls/components/base-poll-dialog.component.ts +++ b/client/src/app/site/polls/components/base-poll-dialog.component.ts @@ -10,15 +10,17 @@ import { VOTE_UNDOCUMENTED } from 'app/shared/models/poll/base-poll'; import { OneOfValidator } from 'app/shared/validators/one-of-validator'; import { BaseViewComponent } from 'app/site/base/base-view'; import { PollFormComponent } from './poll-form/poll-form.component'; +import { PollService } from '../services/poll.service'; import { ViewBasePoll } from '../models/view-base-poll'; /** * A dialog for updating the values of a poll. */ -export abstract class BasePollDialogComponent extends BaseViewComponent implements OnInit { +export abstract class BasePollDialogComponent extends BaseViewComponent + implements OnInit { public publishImmediately: boolean; - protected pollForm: PollFormComponent; + protected pollForm: PollFormComponent; public dialogVoteForm: FormGroup; @@ -26,7 +28,7 @@ export abstract class BasePollDialogComponent extends Ba title: Title, protected translate: TranslateService, matSnackbar: MatSnackBar, - public dialogRef: MatDialogRef> + public dialogRef: MatDialogRef> ) { super(title, translate, matSnackbar); } diff --git a/client/src/app/site/polls/components/base-poll.component.ts b/client/src/app/site/polls/components/base-poll.component.ts index 6bb93a1c9..6ad7220ef 100644 --- a/client/src/app/site/polls/components/base-poll.component.ts +++ b/client/src/app/site/polls/components/base-poll.component.ts @@ -11,9 +11,10 @@ import { ChartData } from 'app/shared/components/charts/charts.component'; import { PollState, PollType } from 'app/shared/models/poll/base-poll'; import { BaseViewComponent } from 'app/site/base/base-view'; import { BasePollRepositoryService } from '../services/base-poll-repository.service'; +import { PollService } from '../services/poll.service'; import { ViewBasePoll } from '../models/view-base-poll'; -export abstract class BasePollComponent extends BaseViewComponent { +export abstract class BasePollComponent extends BaseViewComponent { public chartDataSubject: BehaviorSubject = new BehaviorSubject([]); protected _poll: V; @@ -41,10 +42,10 @@ export abstract class BasePollComponent extends BaseView titleService: Title, matSnackBar: MatSnackBar, protected translate: TranslateService, - public dialog: MatDialog, + protected dialog: MatDialog, protected promptService: PromptService, protected repo: BasePollRepositoryService, - protected pollDialog: BasePollDialogService + protected pollDialog: BasePollDialogService ) { super(titleService, translate, matSnackBar); } diff --git a/client/src/app/site/polls/components/poll-form/poll-form.component.html b/client/src/app/site/polls/components/poll-form/poll-form.component.html index 443f66cd3..075654461 100644 --- a/client/src/app/site/polls/components/poll-form/poll-form.component.html +++ b/client/src/app/site/polls/components/poll-form/poll-form.component.html @@ -22,14 +22,16 @@ - + {{ option.value | translate }} This field is required. - {{ 'Not suitable for formal secret voting!' | translate }} + + {{ 'Not suitable for formal secret voting!' | translate }} @@ -84,7 +86,6 @@ formControlName="votes_amount" min="1" required - /> {{ PollPropertyVerbose.global_no | translate }} diff --git a/client/src/app/site/polls/components/poll-form/poll-form.component.spec.ts b/client/src/app/site/polls/components/poll-form/poll-form.component.spec.ts index 2131a3729..dd4365129 100644 --- a/client/src/app/site/polls/components/poll-form/poll-form.component.spec.ts +++ b/client/src/app/site/polls/components/poll-form/poll-form.component.spec.ts @@ -5,8 +5,8 @@ import { E2EImportsModule } from 'e2e-imports.module'; import { PollFormComponent } from './poll-form.component'; describe('PollFormComponent', () => { - let component: PollFormComponent; - let fixture: ComponentFixture>; + let component: PollFormComponent; + let fixture: ComponentFixture>; beforeEach(async(() => { TestBed.configureTestingModule({ 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 1640f47af..720ee9701 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 @@ -30,7 +30,8 @@ import { PollService } from '../../services/poll.service'; templateUrl: './poll-form.component.html', styleUrls: ['./poll-form.component.scss'] }) -export class PollFormComponent extends BaseViewComponent implements OnInit { +export class PollFormComponent extends BaseViewComponent + implements OnInit { /** * The form-group for the meta-info. */ @@ -54,6 +55,9 @@ export class PollFormComponent extends BaseViewComponent @Input() public data: Partial; + @Input() + private pollService: S; + /** * The different types the poll can accept. */ @@ -87,6 +91,14 @@ export class PollFormComponent extends BaseViewComponent public showNonNominalWarning = false; + public get isEVotingEnabled(): boolean { + if (this.pollService) { + return this.pollService.isElectronicVotingEnabled; + } else { + return false; + } + } + /** * Constructor. Retrieves necessary metadata from the pollService, * injects the poll itself @@ -97,7 +109,6 @@ export class PollFormComponent extends BaseViewComponent snackbar: MatSnackBar, private fb: FormBuilder, private groupRepo: GroupRepositoryService, - public pollService: PollService, private configService: ConfigService, private dialog: MatDialog ) { diff --git a/client/src/app/slides/assignments/assignment-poll/assignment-poll-slide.component.ts b/client/src/app/slides/assignments/assignment-poll/assignment-poll-slide.component.ts index 39a1ccc24..4318006d0 100644 --- a/client/src/app/slides/assignments/assignment-poll/assignment-poll-slide.component.ts +++ b/client/src/app/slides/assignments/assignment-poll/assignment-poll-slide.component.ts @@ -1,6 +1,7 @@ import { Component } from '@angular/core'; import { PollState } from 'app/shared/models/poll/base-poll'; +import { AssignmentPollService } from 'app/site/assignments/services/assignment-poll.service'; import { BasePollSlideComponent } from 'app/slides/polls/base-poll-slide.component'; import { AssignmentPollSlideData } from './assignment-poll-slide-data'; @@ -9,7 +10,10 @@ import { AssignmentPollSlideData } from './assignment-poll-slide-data'; templateUrl: './assignment-poll-slide.component.html', styleUrls: ['./assignment-poll-slide.component.scss'] }) -export class AssignmentPollSlideComponent extends BasePollSlideComponent { +export class AssignmentPollSlideComponent extends BasePollSlideComponent< + AssignmentPollSlideData, + AssignmentPollService +> { public PollState = PollState; public options = { maintainAspectRatio: false, responsive: true, legend: { position: 'right' } }; diff --git a/client/src/app/slides/motions/motion-poll/motion-poll-slide.component.ts b/client/src/app/slides/motions/motion-poll/motion-poll-slide.component.ts index 88388ec57..7c0e260ad 100644 --- a/client/src/app/slides/motions/motion-poll/motion-poll-slide.component.ts +++ b/client/src/app/slides/motions/motion-poll/motion-poll-slide.component.ts @@ -2,7 +2,7 @@ import { Component } from '@angular/core'; import { PollState } from 'app/shared/models/poll/base-poll'; import { MotionPollService } from 'app/site/motions/services/motion-poll.service'; -import { PollData, PollService, PollTableData } from 'app/site/polls/services/poll.service'; +import { PollData, PollTableData } from 'app/site/polls/services/poll.service'; import { BasePollSlideComponent } from 'app/slides/polls/base-poll-slide.component'; import { MotionPollSlideData } from './motion-poll-slide-data'; @@ -11,7 +11,7 @@ import { MotionPollSlideData } from './motion-poll-slide-data'; templateUrl: './motion-poll-slide.component.html', styleUrls: ['./motion-poll-slide.component.scss'] }) -export class MotionPollSlideComponent extends BasePollSlideComponent { +export class MotionPollSlideComponent extends BasePollSlideComponent { public PollState = PollState; public pollData: PollData; @@ -19,7 +19,7 @@ export class MotionPollSlideComponent extends BasePollSlideComponent { if (this.data && this.data.data) { @@ -33,10 +33,10 @@ export class MotionPollSlideComponent extends BasePollSlideComponent extends BaseSlideComponent { +export class BasePollSlideComponent extends BaseSlideComponent { public chartDataSubject: BehaviorSubject = new BehaviorSubject([]); @Input() @@ -29,7 +29,7 @@ export class BasePollSlideComponent extends BaseSli public constructor( @Inject(forwardRef(() => PollService)) - public pollService: PollService + public pollService: S ) { super(); } diff --git a/client/src/app/slides/services/slide-manager.service.ts b/client/src/app/slides/services/slide-manager.service.ts index abe929590..9da6ec3fb 100644 --- a/client/src/app/slides/services/slide-manager.service.ts +++ b/client/src/app/slides/services/slide-manager.service.ts @@ -76,11 +76,10 @@ export class SlideManager { } /** - * Asynchronically load the slide's component factory, which is used to create + * Asynchronously load the slide's component factory, which is used to create * the slide component. * * @param slideName The slide to search. - * @deprecated NgModuleFactoryLoader is deprecated and should be removed before version 9 */ public async getSlideFactory>( slideName: string