import { Component, Input } from '@angular/core'; import { I18nService } from '@yourcause/common/i18n'; import { LogService } from '@yourcause/common/logging'; import { YCModalComponent } from '@yourcause/common/modals'; import { NotifierService } from '@yourcause/common/notifier'; @Component({ selector: 'gc-attach-external-email-modal', templateUrl: './attach-external-email-modal.component.html', styleUrls: ['./attach-external-email-modal.component.scss'] }) export class AttachExternalEmailModalComponent extends YCModalComponent { @Input() emailAddress: string; modalHeader = this.i18n.translate( 'common:textAttachExternalEmailToApplication', {}, 'Attach External Email to Application' ); descriptionText = this.i18n.translate( 'common:textAttachExternalEmailDescription2', {}, 'To attach external emails to this application, Forward or CC them to the unique application email address below. External emails will show in the Communications tab.' ); constructor ( private logger: LogService, private i18n: I18nService, private notifierService: NotifierService ) { super(); } copyEmailAddress () { try { const textArea = document.createElement('textarea'); textArea.value = this.emailAddress; textArea.setAttribute('readonly', ''); textArea.style.position = 'absolute'; textArea.style.left = '-9999px'; document.body.appendChild(textArea); textArea.select(); document.execCommand('copy'); document.body.removeChild(textArea); this.notifierService.success(this.i18n.translate( 'common:textCopiedEmailAddress', {}, 'Copied email address' )); } catch (e) { this.logger.error(e); this.notifierService.error(this.i18n.translate( 'common:textErrorCopiedToClipboard', {}, 'Error in copying to clipboard.' )); } } }