From 1caea6b31f11eff785153ce484aa2ed8b56cd1be Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Tue, 3 Dec 2019 12:50:39 +0000 Subject: [PATCH] [Library]: Create Contact us component, delete contact us from class git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57794 d315682c-612b-4755-9ff5-7f18f6832af3 --- contact-us/contact-us.component.html | 67 ++++++++++++++++++++++++++++ contact-us/contact-us.component.ts | 39 ++++++++++++++++ contact-us/contact-us.module.ts | 23 ++++++++++ utils/email/composer.ts | 3 +- utils/email/contact-form.ts | 9 ---- 5 files changed, 130 insertions(+), 11 deletions(-) create mode 100644 contact-us/contact-us.component.html create mode 100644 contact-us/contact-us.component.ts create mode 100644 contact-us/contact-us.module.ts delete mode 100644 utils/email/contact-form.ts diff --git a/contact-us/contact-us.component.html b/contact-us/contact-us.component.html new file mode 100644 index 00000000..ca102796 --- /dev/null +++ b/contact-us/contact-us.component.html @@ -0,0 +1,67 @@ +
{{formTitle}}
+ +
+
+ *Required fields +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
diff --git a/contact-us/contact-us.component.ts b/contact-us/contact-us.component.ts new file mode 100644 index 00000000..98cf0b96 --- /dev/null +++ b/contact-us/contact-us.component.ts @@ -0,0 +1,39 @@ +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import {FormGroup} from '@angular/forms'; +import {EnvProperties} from "../utils/properties/env-properties"; + +@Component({ + selector: 'contact-us', + templateUrl: './contact-us.component.html', +}) + +export class ContactUsComponent implements OnInit { + @Input() + public contactForm: FormGroup; + @Input() formTitle: string; + @Input() properties: EnvProperties; + @Output() sendEmitter: EventEmitter = new EventEmitter(); + @Output() resetEmitter: EventEmitter = new EventEmitter(); + @Input() errorMessage; + + constructor() { + } + + ngOnInit() { + } + + public send() { + this.sendEmitter.emit({ + valid: this.contactForm.valid + }); + } + + public reset() { + this.resetEmitter.emit(); + } + + + public handleRecaptcha(captchaResponse: string) { + this.contactForm.get('recaptcha').setValue(captchaResponse); + } +} diff --git a/contact-us/contact-us.module.ts b/contact-us/contact-us.module.ts new file mode 100644 index 00000000..1573b7f4 --- /dev/null +++ b/contact-us/contact-us.module.ts @@ -0,0 +1,23 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {RouterModule} from '@angular/router'; + +import {ContactUsComponent} from './contact-us.component'; +import {RecaptchaModule} from "ng-recaptcha"; +import {ReactiveFormsModule} from "@angular/forms"; + +@NgModule({ + imports: [ + CommonModule, RouterModule, + RecaptchaModule.forRoot(), ReactiveFormsModule], + declarations: [ + ContactUsComponent + ], + providers: [], + exports: [ + ContactUsComponent + ] +}) + +export class ContactUsModule { +} diff --git a/utils/email/composer.ts b/utils/email/composer.ts index 35ac3966..5b6bd840 100644 --- a/utils/email/composer.ts +++ b/utils/email/composer.ts @@ -1,6 +1,5 @@ import {Email} from "./email"; import {Body} from "./body"; -import {ContactForm} from "./contact-form"; export class Composer { private static noteBodySize = "14px"; @@ -49,7 +48,7 @@ export class Composer { return email; } - public static composeEmailForNewCommunity(contactForm: ContactForm, admins: any): Email { + public static composeEmailForNewCommunity(contactForm: any, admins: any): Email { let email: Email = new Email(); email.subject = "RCD: Request for new community"; diff --git a/utils/email/contact-form.ts b/utils/email/contact-form.ts deleted file mode 100644 index a3519029..00000000 --- a/utils/email/contact-form.ts +++ /dev/null @@ -1,9 +0,0 @@ -export class ContactForm { - name: string = ''; - surname: string = ''; - email: string = ''; - affiliation: string = ''; - community: string = ''; - message: string = ''; - recaptcha: string = null; -}