Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 10x 8x 2x | import { CommonModule } from '@angular/common'; import { ChangeDetectionStrategy, Component, Input, NgModule, OnInit } from '@angular/core'; import { AbstractControl, FormGroup } from '@angular/forms'; import { TranslateModule } from '@ngx-translate/core'; import { RecaptchaModule } from 'ng-recaptcha'; import { Observable } from 'rxjs'; import { CaptchaFacade } from '../../facades/captcha.facade'; /** * The Captcha V2 Component * * Displays a captcha form control (V2) and saves the response token in the given form. It should only be used by {@link CaptchaComponent} */ @Component({ selector: 'ish-captcha-v2', templateUrl: './captcha-v2.component.html', changeDetection: ChangeDetectionStrategy.Default, }) export class CaptchaV2Component implements OnInit { @Input({ required: true }) parentForm: FormGroup; @Input() cssClass: string; captchaSiteKey$: Observable<string>; constructor(private captchaFacade: CaptchaFacade) {} ngOnInit() { this.captchaSiteKey$ = this.captchaFacade.captchaSiteKey$; this.parentForm.get('captchaAction').setValue(undefined); this.formControl.updateValueAndValidity(); } /** * writes the captcha response token in the captcha form field */ resolved(captchaResponse: string) { this.formControl.setValue(captchaResponse); } private get formControl(): AbstractControl { return this.parentForm?.get('captcha'); } get hasError(): boolean { return this.formControl?.invalid && this?.formControl.dirty; } } @NgModule({ declarations: [CaptchaV2Component], imports: [CommonModule, RecaptchaModule, TranslateModule], }) export class CaptchaV2ComponentModule {} |