2019-12-03 13:50:39 +01:00
|
|
|
import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
|
|
|
|
import {FormGroup} from '@angular/forms';
|
|
|
|
import {EnvProperties} from "../utils/properties/env-properties";
|
2020-06-23 22:50:46 +02:00
|
|
|
import {Observable} from "rxjs";
|
|
|
|
import {map, startWith} from "rxjs/operators";
|
2019-12-03 13:50:39 +01:00
|
|
|
|
|
|
|
@Component({
|
2020-06-23 22:50:46 +02:00
|
|
|
selector: 'contact-us',
|
|
|
|
templateUrl: './contact-us.component.html',
|
2020-10-23 19:46:13 +02:00
|
|
|
styleUrls: ['contact-us.component.css']
|
2019-12-03 13:50:39 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
export class ContactUsComponent implements OnInit {
|
2020-06-23 22:50:46 +02:00
|
|
|
@Input()
|
|
|
|
public contactForm: FormGroup;
|
|
|
|
@Input() formTitle: string;
|
|
|
|
@Input() properties: EnvProperties;
|
|
|
|
@Output() sendEmitter: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
@Input() errorMessage;
|
|
|
|
@Input()
|
|
|
|
public organizationTypes: string[];
|
2020-09-14 17:08:34 +02:00
|
|
|
@Input()
|
|
|
|
public right: boolean = true;
|
|
|
|
@Input()
|
|
|
|
public buttonClass: string;
|
2020-06-23 22:50:46 +02:00
|
|
|
public autoCompleteTypes: Observable<string[]>;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2020-09-14 17:08:34 +02:00
|
|
|
if(this.contactForm.get('organizationType')) {
|
|
|
|
this.autoCompleteTypes = this.contactForm.get('organizationType').valueChanges
|
|
|
|
.pipe(
|
|
|
|
startWith(''),
|
|
|
|
map(value => this._filter(value))
|
|
|
|
);
|
|
|
|
}
|
2020-06-23 22:50:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private _filter(value: string): string[] {
|
|
|
|
const filterValue = value.toLowerCase();
|
|
|
|
return this.organizationTypes.filter(option => option.toLowerCase().includes(filterValue));
|
|
|
|
}
|
|
|
|
|
|
|
|
public send() {
|
|
|
|
this.sendEmitter.emit({
|
|
|
|
valid: this.contactForm.valid
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public handleRecaptcha(captchaResponse: string) {
|
|
|
|
this.contactForm.get('recaptcha').setValue(captchaResponse);
|
|
|
|
}
|
2019-12-03 13:50:39 +01:00
|
|
|
}
|