diff --git a/src/app/utils/subscribe/invite/invite.component.ts b/src/app/utils/subscribe/invite/invite.component.ts index 4c96198..117b0e0 100644 --- a/src/app/utils/subscribe/invite/invite.component.ts +++ b/src/app/utils/subscribe/invite/invite.component.ts @@ -7,6 +7,7 @@ import {ConnectHelper} from '../../../openaire import {Email} from '../../../openaireLibrary/utils/email/email'; import {Body} from '../../../openaireLibrary/utils/email/body'; +import {Validator} from '../../../openaireLibrary/utils/email/validator'; import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties'; import {EmailService} from '../../../openaireLibrary/utils/email/email.service'; @@ -88,7 +89,7 @@ export class InviteComponent implements OnInit { + '
The purpose of this dashboard is to gather, link & monitor the research results related to your community.

The community dashboard is part of the OpenAIRE-Connect project and currently is in BETA version.

'; // TODO move the initialisation - this.body = {/*salutation: "Dear Sir/Madame,",*/ fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, /*closing: "Kind regards,",*/ signature: "OpenAIRE team", note: ""}; + this.body = {fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, signature: "OpenAIRE team", note: ""}; this.email = {body: "", subject: "[OpenAIRE-Connect] " + community.title, recipients: []}; this.recipients = ""; @@ -132,7 +133,7 @@ export class InviteComponent implements OnInit { this.successfulSentMessage = res + " email sent successfully!"; } - this.body = {/*salutation: "Dear Sir/Madame,",*/ fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, /*closing: "Kind regards,",*/ signature: "OpenAIRE team", note: ""}; + this.body = {fromMessage: ", on behalf of ", fromName: this.fullname, paragraphs: this.defaultBody, signature: "OpenAIRE team", note: ""}; this.email = {body: "", subject: "[OpenAIRE-Connect] " + this.community.title, recipients: []}; this.recipients = ""; }, @@ -161,7 +162,7 @@ export class InviteComponent implements OnInit { public validateEmails(): boolean { if (this.parseEmails()) { - if (this.hasValidEmails()) { + if (Validator.hasValidEmails(this.email.recipients)) { return this.areValid; } } @@ -188,28 +189,6 @@ export class InviteComponent implements OnInit { return true; } - private hasValidEmails(): boolean { - let length = this.email.recipients.length; - - for(let i = 0; i < length; i++) { - if (!this.emailValidator(this.email.recipients[i])){ - // TODO remove console message after final testing - console.log("INVALID EMAIL"); - return false; - } - } - // TODO remove console message after final testing - console.log("ALL EMAILS ARE VALID"); - return true; - } - - private emailValidator(email : any): boolean { - if (email.match("^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$")) - return true; - else - return false; - } - public composeEmail() { // this.email.subject = "[OpenAIRE-Connect] Community_name"; this.email.body = this.formatEmailBody(); @@ -222,11 +201,12 @@ export class InviteComponent implements OnInit { fromMessageAndName = "" + this.body.fromMessage + this.body.fromName + ""; } - let formattedEmail = "
" + /*+ this.body.salutation + "

" +*/ - this.body.paragraphs + - "

" /*+ this.body.closing + "
"*/ + this.body.signature + fromMessageAndName + "
" + - "www.openaire.eu" + "

"; - + let formattedEmail = "
" + + this.body.paragraphs + + "

" + this.body.signature + fromMessageAndName + "
" + + "www.openaire.eu" + + "

" + + "
"; return formattedEmail; }