1
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
2
|
import {FormGroup} from '@angular/forms';
|
3
|
import {EnvProperties} from "../utils/properties/env-properties";
|
4
|
import {Observable} from "rxjs";
|
5
|
import {map, startWith} from "rxjs/operators";
|
6
|
|
7
|
@Component({
|
8
|
selector: 'contact-us',
|
9
|
templateUrl: './contact-us.component.html',
|
10
|
styleUrls: ['contact-us.component.css']
|
11
|
})
|
12
|
|
13
|
export class ContactUsComponent implements OnInit {
|
14
|
@Input()
|
15
|
public contactForm: FormGroup;
|
16
|
@Input() formTitle: string;
|
17
|
@Input() properties: EnvProperties;
|
18
|
@Output() sendEmitter: EventEmitter<any> = new EventEmitter<any>();
|
19
|
@Input() errorMessage;
|
20
|
@Input()
|
21
|
public organizationTypes: string[];
|
22
|
@Input()
|
23
|
public right: boolean = true;
|
24
|
@Input()
|
25
|
public buttonClass: string;
|
26
|
public autoCompleteTypes: Observable<string[]>;
|
27
|
|
28
|
constructor() {
|
29
|
}
|
30
|
|
31
|
ngOnInit() {
|
32
|
if(this.contactForm.get('organizationType')) {
|
33
|
this.autoCompleteTypes = this.contactForm.get('organizationType').valueChanges
|
34
|
.pipe(
|
35
|
startWith(''),
|
36
|
map(value => this._filter(value))
|
37
|
);
|
38
|
}
|
39
|
}
|
40
|
|
41
|
private _filter(value: string): string[] {
|
42
|
const filterValue = value.toLowerCase();
|
43
|
return this.organizationTypes.filter(option => option.toLowerCase().includes(filterValue));
|
44
|
}
|
45
|
|
46
|
public send() {
|
47
|
this.sendEmitter.emit({
|
48
|
valid: this.contactForm.valid
|
49
|
});
|
50
|
}
|
51
|
|
52
|
public handleRecaptcha(captchaResponse: string) {
|
53
|
this.contactForm.get('recaptcha').setValue(captchaResponse);
|
54
|
}
|
55
|
}
|