diff --git a/src/app/app-routing-paths.ts b/src/app/app-routing-paths.ts index db6b22a023..df3ada9ff4 100644 --- a/src/app/app-routing-paths.ts +++ b/src/app/app-routing-paths.ts @@ -32,6 +32,12 @@ export function getBitstreamRequestACopyRoute(item, bitstream): { routerLink: st }; } +export const HOME_PAGE_PATH = 'admin'; + +export function getHomePageRoute() { + return `/${HOME_PAGE_PATH}`; +} + export const ADMIN_MODULE_PATH = 'admin'; export function getAdminModuleRoute() { diff --git a/src/app/info/feedback/feedback-form/feedback-form.component.html b/src/app/info/feedback/feedback-form/feedback-form.component.html index 44a7044e52..02745f2580 100644 --- a/src/app/info/feedback/feedback-form/feedback-form.component.html +++ b/src/app/info/feedback/feedback-form/feedback-form.component.html @@ -8,7 +8,7 @@
-

{{ 'info.feedback.email_help' | translate }}

+ {{ 'info.feedback.email_help' | translate }}
@@ -27,12 +27,11 @@ class="alert"> -
-

{{ 'info.feedback.page_help' | translate }}

+ {{ 'info.feedback.page_help' | translate }}
@@ -43,4 +42,4 @@
- \ No newline at end of file + diff --git a/src/app/info/feedback/feedback-form/feedback-form.component.spec.ts b/src/app/info/feedback/feedback-form/feedback-form.component.spec.ts index 581c51add3..d6bedc46cf 100644 --- a/src/app/info/feedback/feedback-form/feedback-form.component.spec.ts +++ b/src/app/info/feedback/feedback-form/feedback-form.component.spec.ts @@ -16,6 +16,8 @@ import { of } from 'rxjs'; import { Feedback } from '../../../core/feedback/models/feedback.model'; import { Router } from '@angular/router'; import { RouterMock } from '../../../shared/mocks/router.mock'; +import { NativeWindowService } from '../../../core/services/window.service'; +import { NativeWindowMockFactory } from '../../../shared/mocks/mock-native-window-ref'; describe('FeedbackFormComponent', () => { @@ -43,6 +45,7 @@ describe('FeedbackFormComponent', () => { { provide: NotificationsService, useValue: notificationService }, { provide: FeedbackDataService, useValue: feedbackDataServiceStub }, { provide: AuthService, useValue: authService }, + { provide: NativeWindowService, useFactory: NativeWindowMockFactory }, { provide: Router, useValue: routerStub }, ], schemas: [NO_ERRORS_SCHEMA] @@ -61,7 +64,7 @@ describe('FeedbackFormComponent', () => { }); it('should have page value', () => { - expect(component.feedbackForm.controls.page.value).toEqual('/home'); + expect(component.feedbackForm.controls.page.value).toEqual('http://localhost/home'); }); it('should have email if ePerson', () => { diff --git a/src/app/info/feedback/feedback-form/feedback-form.component.ts b/src/app/info/feedback/feedback-form/feedback-form.component.ts index 98bf9a3fd7..e0b8238a50 100644 --- a/src/app/info/feedback/feedback-form/feedback-form.component.ts +++ b/src/app/info/feedback/feedback-form/feedback-form.component.ts @@ -1,7 +1,7 @@ import { RemoteData } from '../../../core/data/remote-data'; import { NoContent } from '../../../core/shared/NoContent.model'; import { FeedbackDataService } from '../../../core/feedback/feedback-data.service'; -import { Component, OnInit } from '@angular/core'; +import { Component, Inject, OnInit } from '@angular/core'; import { RouteService } from '../../../core/services/route.service'; import { FormBuilder, Validators } from '@angular/forms'; import { NotificationsService } from '../../../shared/notifications/notifications.service'; @@ -10,6 +10,10 @@ import { AuthService } from '../../../core/auth/auth.service'; import { EPerson } from '../../../core/eperson/models/eperson.model'; import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; import { Router } from '@angular/router'; +import { getHomePageRoute } from '../../../app-routing-paths'; +import { take } from 'rxjs/operators'; +import { NativeWindowRef, NativeWindowService } from '../../../core/services/window.service'; +import { URLCombiner } from '../../../core/url-combiner/url-combiner'; @Component({ selector: 'ds-feedback-form', @@ -31,6 +35,7 @@ export class FeedbackFormComponent implements OnInit { }); constructor( + @Inject(NativeWindowService) protected _window: NativeWindowRef, public routeService: RouteService, private fb: FormBuilder, protected notificationsService: NotificationsService, @@ -45,17 +50,18 @@ export class FeedbackFormComponent implements OnInit { */ ngOnInit() { - this.authService.getAuthenticatedUserFromStore().subscribe((user: EPerson) => { + this.authService.getAuthenticatedUserFromStore().pipe(take(1)).subscribe((user: EPerson) => { if (!!user) { this.feedbackForm.patchValue({ email: user.email }); } }); - this.routeService.getPreviousUrl().subscribe((url: string) => { + this.routeService.getPreviousUrl().pipe(take(1)).subscribe((url: string) => { if (!url) { - url = '/home'; + url = getHomePageRoute(); } - this.feedbackForm.patchValue({ page: url }); + const relatedUrl = new URLCombiner(this._window.nativeWindow.origin, url).toString(); + this.feedbackForm.patchValue({ page: relatedUrl }); }); } diff --git a/src/app/shared/mocks/mock-native-window-ref.ts b/src/app/shared/mocks/mock-native-window-ref.ts index 5546bd5ccc..5a6d6c5f30 100644 --- a/src/app/shared/mocks/mock-native-window-ref.ts +++ b/src/app/shared/mocks/mock-native-window-ref.ts @@ -7,7 +7,8 @@ export const MockWindow = { get href() { return this._href; } - } + }, + origin: 'http://localhost' }; export class NativeWindowRefMock { diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 5c8845ca6f..47275a1057 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -1594,6 +1594,11 @@ "info.feedback.error.message.required" : "A comment is required", + "info.feedback.page-label" : "Page", + + "info.feedback.page_help" : "Tha page related to your feedback", + + "item.alerts.private": "This item is private",