diff --git a/dmp-frontend/src/app/app-routing.module.ts b/dmp-frontend/src/app/app-routing.module.ts index c8eee17ab..9ba283c4d 100644 --- a/dmp-frontend/src/app/app-routing.module.ts +++ b/dmp-frontend/src/app/app-routing.module.ts @@ -93,14 +93,14 @@ const appRoutes: Routes = [ title: 'GENERAL.TITLES.DATASET-PROFILES' } }, - // { - // path: 'contact', - // loadChildren: () => import('./ui/contact/contact.module').then(m => m.ContactModule), - // data: { - // breadcrumb: true, - // title: 'CONTACT.SUPPORT.TITLE' - // } - // }, + { + path: 'contact-support', + loadChildren: () => import('./ui/contact/contact.module').then(m => m.ContactModule), + data: { + breadcrumb: true, + title: 'CONTACT.SUPPORT.TITLE' + } + }, { path: 'glossary', loadChildren: () => import('./ui/glossary/glossary.module').then(m => m.GlossaryModule), diff --git a/dmp-frontend/src/app/library/contact-dialog/contact-dialog.component.html b/dmp-frontend/src/app/library/contact-dialog/contact-dialog.component.html deleted file mode 100644 index 3f7bedeb1..000000000 --- a/dmp-frontend/src/app/library/contact-dialog/contact-dialog.component.html +++ /dev/null @@ -1,32 +0,0 @@ -
diff --git a/dmp-frontend/src/app/library/contact-dialog/contact-dialog.module.ts b/dmp-frontend/src/app/library/contact-dialog/contact-dialog.module.ts deleted file mode 100644 index a0fe4ea9f..000000000 --- a/dmp-frontend/src/app/library/contact-dialog/contact-dialog.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import { CommonUiModule } from '../../common/ui/common-ui.module'; -import { ContactDialogComponent } from './contact-dialog.component'; -import { FormsModule, ReactiveFormsModule } from '@angular/forms'; - -@NgModule({ - imports: [CommonUiModule, FormsModule, ReactiveFormsModule], - declarations: [ContactDialogComponent], - exports: [ContactDialogComponent], - entryComponents: [ContactDialogComponent] -}) -export class ContactDialogModule { - constructor() { } -} diff --git a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html new file mode 100644 index 000000000..a052f8455 --- /dev/null +++ b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.html @@ -0,0 +1,33 @@ + diff --git a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.scss b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.scss new file mode 100644 index 000000000..cdbae5052 --- /dev/null +++ b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.scss @@ -0,0 +1,23 @@ +h1 { + text-align: center; +} + +img { + height: 150px; + width: 100%; +} + +.contact-component { + margin-top: 80px; +} + +.contact-container { + margin: 1em; + padding: 2em; + box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14); + background-color: #ffffff; +} + +.contact-actions { + padding-right: 1em; +} diff --git a/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.ts b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.ts new file mode 100644 index 000000000..b7b4dcc70 --- /dev/null +++ b/dmp-frontend/src/app/ui/contact/contact-content/contact-content.component.ts @@ -0,0 +1,87 @@ +import { FormGroup, AbstractControl, FormControl, FormArray } from '@angular/forms'; +import { Component, OnInit, Input } from '@angular/core'; +import { Location } from '@angular/common'; +import { takeUntil } from 'rxjs/operators'; +import { TranslateService } from '@ngx-translate/core'; +import { ContactEmailFormModel } from '../../../core/model/contact/contact-email-form-model'; +import { ContactSupportService } from '../../../core/services/contact-support/contact-support.service'; +import { BaseComponent } from '../../../core/common/base/base.component'; +import { UiNotificationService, SnackBarNotificationLevel } from '../../../core/services/notification/ui-notification-service'; +import { ValidationErrorModel } from '../../../common/forms/validation/error-model/validation-error-model'; + +@Component({ + selector: 'app-contact-content', + templateUrl: './contact-content.component.html', + styleUrls: ['./contact-content.component.scss'] +}) +export class ContactContentComponent extends BaseComponent implements OnInit { + + @Input() isDialog: boolean; + @Input() form: FormGroup; + private contactEmailFormModel: ContactEmailFormModel; + public formGroup: FormGroup; + + constructor( + private contactSupportService: ContactSupportService, + private _location: Location, + private uiNotificationService: UiNotificationService, + private language: TranslateService, + ) { + super(); + } + + ngOnInit() { + if (this.isDialog) { + this.formGroup = this.form; + } else { + this.contactEmailFormModel = new ContactEmailFormModel(); + this.formGroup = this.contactEmailFormModel.buildForm(); + } + } + + cancel() { + this._location.back(); + } + + send() { + this.contactSupportService.postEmail(this.formGroup.value) + .pipe(takeUntil(this._destroyed)) + .subscribe( + complete => this.onCallbackSuccess(), + error => this.onCallbackError(error) + ); + this.formGroup.reset(); + } + + onCallbackSuccess(): void { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-EMAIL-SEND'), SnackBarNotificationLevel.Success); + } + + onCallbackError(errorResponse: any) { + this.setErrorModel(errorResponse.error); + this.validateAllFormFields(this.formGroup); + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-EMAIL-SEND'), SnackBarNotificationLevel.Error); + } + + public setErrorModel(validationErrorModel: ValidationErrorModel) { + Object.keys(validationErrorModel).forEach(item => { + (- +
{{'FOOTER.CONTACT-SUPPORT' | translate}}