]>
Commit | Line | Data |
---|---|---|
40360c17 K |
1 | import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' |
2 | import { FormGroup } from '@angular/forms' | |
5c5bcea2 | 3 | import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' |
9589907c | 4 | import { REGISTER_REASON_VALIDATOR, REGISTER_TERMS_VALIDATOR } from '../shared' |
40360c17 K |
5 | |
6 | @Component({ | |
7 | selector: 'my-register-step-terms', | |
8 | templateUrl: './register-step-terms.component.html', | |
6f03f944 | 9 | styleUrls: [ './step.component.scss' ] |
40360c17 K |
10 | }) |
11 | export class RegisterStepTermsComponent extends FormReactive implements OnInit { | |
12 | @Input() hasCodeOfConduct = false | |
9589907c | 13 | @Input() requiresApproval: boolean |
1f256e7d | 14 | @Input() minimumAge = 16 |
9589907c | 15 | @Input() instanceName: string |
40360c17 K |
16 | |
17 | @Output() formBuilt = new EventEmitter<FormGroup>() | |
18 | @Output() termsClick = new EventEmitter<void>() | |
19 | @Output() codeOfConductClick = new EventEmitter<void>() | |
20 | ||
21 | constructor ( | |
5c5bcea2 | 22 | protected formReactiveService: FormReactiveService |
40360c17 K |
23 | ) { |
24 | super() | |
25 | } | |
26 | ||
27 | get instanceHost () { | |
28 | return window.location.host | |
29 | } | |
30 | ||
31 | ngOnInit () { | |
32 | this.buildForm({ | |
9589907c C |
33 | terms: REGISTER_TERMS_VALIDATOR, |
34 | ||
35 | registrationReason: this.requiresApproval | |
36 | ? REGISTER_REASON_VALIDATOR | |
37 | : null | |
40360c17 K |
38 | }) |
39 | ||
40 | setTimeout(() => this.formBuilt.emit(this.form)) | |
41 | } | |
42 | ||
43 | onTermsClick (event: Event) { | |
44 | event.preventDefault() | |
45 | this.termsClick.emit() | |
46 | } | |
47 | ||
48 | onCodeOfConductClick (event: Event) { | |
49 | event.preventDefault() | |
50 | this.codeOfConductClick.emit() | |
51 | } | |
52 | } |