From 30d338bbbd60287d1b1695a0418626424f6d6cf5 Mon Sep 17 00:00:00 2001 From: Sofia Papacharalampous Date: Mon, 29 Apr 2024 16:40:11 +0300 Subject: [PATCH] used label as the title on dmp and description editor --- dmp-frontend/src/app/app.component.ts | 28 ++++++++++++------- .../editor/description-editor.component.ts | 12 ++++++-- .../editor/description-editor.routing.ts | 4 ++- .../dmp-editor.component.ts | 11 ++++++-- .../dmp-editor.routing.ts | 4 ++- 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/dmp-frontend/src/app/app.component.ts b/dmp-frontend/src/app/app.component.ts index c30f5a99d..24b6aa882 100644 --- a/dmp-frontend/src/app/app.component.ts +++ b/dmp-frontend/src/app/app.component.ts @@ -147,15 +147,19 @@ export class AppComponent implements OnInit, AfterViewInit { while (child.firstChild) { child = child.firstChild; } - if (child.snapshot.data['title']) { - return child.snapshot.data['title']; + const usePrefix = child.snapshot.data['usePrefix'] ?? true; + if (child.snapshot.data['getFromTitleService']) { + return { title: this.titleService.getTitle(), usePrefix: usePrefix }; + } + else if (child.snapshot.data['title']) { + return { title: child.snapshot.data['title'], usePrefix: usePrefix }; } } - return appTitle; + return { title: appTitle, usePrefix: true}; }) - ).subscribe((ttl: string) => { - this.translateTitle(ttl); - this.translate.onLangChange.subscribe(() => this.translateTitle(ttl)); + ).subscribe((titleOptions: { title: string, usePrefix: boolean}) => { + this.translateTitle(titleOptions.title, titleOptions.usePrefix); + this.translate.onLangChange.subscribe(() => this.translateTitle(titleOptions.title, titleOptions.usePrefix)); }); this.statusChangeSubscription = this.ccService.statusChange$.subscribe((event: NgcStatusChangeEvent) => { @@ -186,12 +190,16 @@ export class AppComponent implements OnInit, AfterViewInit { }); } - translateTitle(ttl: string) { + translateTitle(ttl: string, usePrefix: boolean) { if (ttl.length > 0) { this.translate.get(ttl).subscribe((translated: string) => { - this.translate.get('GENERAL.TITLES.PREFIX').subscribe((titlePrefix: string) => { - this.titleService.setTitle(titlePrefix + translated); - }); + if (usePrefix) { + this.translate.get('GENERAL.TITLES.PREFIX').subscribe((titlePrefix: string) => { + this.titleService.setTitle(titlePrefix + translated); + }); + } else { + this.titleService.setTitle(translated); + } }); } else { this.translate.get('GENERAL.TITLES.GENERAL').subscribe((translated: string) => { diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts index 3bd5956a1..555cf9fd3 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.component.ts @@ -50,6 +50,7 @@ import { FileTransformerEntityType } from '@app/core/common/enum/file-transforme import { nameof } from 'ts-simple-nameof'; import { AbstractControl, UntypedFormArray, UntypedFormGroup } from '@angular/forms'; import { TableOfContentsValidationService } from './table-of-contents/services/table-of-contents-validation-service'; +import { Title } from '@angular/platform-browser'; @Component({ selector: 'app-description-editor-component', @@ -101,9 +102,15 @@ export class DescriptionEditorComponent extends BaseEditor { if (result) { + this.titleService.setTitle(result.label); result.dmp = this.item.dmp; result.dmpDescriptionTemplate = this.item.dmpDescriptionTemplate; diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts index 2d1ea28a0..5641b3c86 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.routing.ts @@ -22,7 +22,9 @@ const routes: Routes = [ ...BreadcrumbService.generateRouteDataConfiguration({ title: 'BREADCRUMBS.EDIT-DESCRIPTION' }), - title: 'DESCRIPTION-EDITOR.TITLE-EDIT-DESCRIPTION' + getFromTitleService: true, + usePrefix: false + //title: 'DESCRIPTION-EDITOR.TITLE-EDIT-DESCRIPTION' // , // authContext: { // permissions: [AppPermission.EditDescription] diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts index 0ef5db80c..bead0e5fc 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.component.ts @@ -51,6 +51,7 @@ import { map, takeUntil } from 'rxjs/operators'; import { DmpEditorModel, DmpFieldIndicator } from './dmp-editor.model'; import { DmpEditorResolver } from './dmp-editor.resolver'; import { DmpEditorService } from './dmp-editor.service'; +import { Title } from '@angular/platform-browser'; @Component({ selector: 'app-dmp-editor', @@ -164,9 +165,15 @@ export class DmpEditorComponent extends BaseEditor implemen public enumUtils: EnumUtils, public descriptionTemplateService: DescriptionTemplateService, public userService: UserService, - public descriptionService: DescriptionService - + public descriptionService: DescriptionService, + public titleService: Title ) { + const descriptionLabel:string = route.snapshot.data['entity']?.label; + if (descriptionLabel) { + titleService.setTitle(descriptionLabel); + } else { + titleService.setTitle('DMP-EDITOR.TITLE-EDIT'); + } super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService, lockService, authService, configurationService); } diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.routing.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.routing.ts index 3cb253358..655682bc7 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.routing.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor.routing.ts @@ -35,7 +35,9 @@ const routes: Routes = [ data: { ...BreadcrumbService.generateRouteDataConfiguration({ title: 'BREADCRUMBS.EDIT-DMP' - }) + }), + getFromTitleService: true, + usePrefix: false } }