used label as the title on dmp and description editor

This commit is contained in:
Sofia Papacharalampous 2024-04-29 16:40:11 +03:00
parent 8a16098fc1
commit 30d338bbbd
5 changed files with 43 additions and 16 deletions

View File

@ -147,15 +147,19 @@ export class AppComponent implements OnInit, AfterViewInit {
while (child.firstChild) { while (child.firstChild) {
child = child.firstChild; child = child.firstChild;
} }
if (child.snapshot.data['title']) { const usePrefix = child.snapshot.data['usePrefix'] ?? true;
return child.snapshot.data['title']; 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) => { ).subscribe((titleOptions: { title: string, usePrefix: boolean}) => {
this.translateTitle(ttl); this.translateTitle(titleOptions.title, titleOptions.usePrefix);
this.translate.onLangChange.subscribe(() => this.translateTitle(ttl)); this.translate.onLangChange.subscribe(() => this.translateTitle(titleOptions.title, titleOptions.usePrefix));
}); });
this.statusChangeSubscription = this.ccService.statusChange$.subscribe((event: NgcStatusChangeEvent) => { 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) { if (ttl.length > 0) {
this.translate.get(ttl).subscribe((translated: string) => { this.translate.get(ttl).subscribe((translated: string) => {
this.translate.get('GENERAL.TITLES.PREFIX').subscribe((titlePrefix: string) => { if (usePrefix) {
this.titleService.setTitle(titlePrefix + translated); this.translate.get('GENERAL.TITLES.PREFIX').subscribe((titlePrefix: string) => {
}); this.titleService.setTitle(titlePrefix + translated);
});
} else {
this.titleService.setTitle(translated);
}
}); });
} else { } else {
this.translate.get('GENERAL.TITLES.GENERAL').subscribe((translated: string) => { this.translate.get('GENERAL.TITLES.GENERAL').subscribe((translated: string) => {

View File

@ -50,6 +50,7 @@ import { FileTransformerEntityType } from '@app/core/common/enum/file-transforme
import { nameof } from 'ts-simple-nameof'; import { nameof } from 'ts-simple-nameof';
import { AbstractControl, UntypedFormArray, UntypedFormGroup } from '@angular/forms'; import { AbstractControl, UntypedFormArray, UntypedFormGroup } from '@angular/forms';
import { TableOfContentsValidationService } from './table-of-contents/services/table-of-contents-validation-service'; import { TableOfContentsValidationService } from './table-of-contents/services/table-of-contents-validation-service';
import { Title } from '@angular/platform-browser';
@Component({ @Component({
selector: 'app-description-editor-component', selector: 'app-description-editor-component',
@ -101,9 +102,15 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
private dmpService: DmpService, private dmpService: DmpService,
public visibilityRulesService: VisibilityRulesService, public visibilityRulesService: VisibilityRulesService,
public fileTransformerService: FileTransformerService, public fileTransformerService: FileTransformerService,
public tocValidationService: TableOfContentsValidationService public tocValidationService: TableOfContentsValidationService,
public titleService: Title
) { ) {
const descriptionLabel:string = route.snapshot.data['entity']?.label;
if (descriptionLabel) {
titleService.setTitle(descriptionLabel);
} else {
titleService.setTitle('DESCRIPTION-EDITOR.TITLE-EDIT-DESCRIPTION');
}
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService, lockService, authService, configurationService); super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService, lockService, authService, configurationService);
} }
@ -210,6 +217,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
}); });
dialogRef.afterClosed().subscribe((result: Description) => { dialogRef.afterClosed().subscribe((result: Description) => {
if (result) { if (result) {
this.titleService.setTitle(result.label);
result.dmp = this.item.dmp; result.dmp = this.item.dmp;
result.dmpDescriptionTemplate = this.item.dmpDescriptionTemplate; result.dmpDescriptionTemplate = this.item.dmpDescriptionTemplate;

View File

@ -22,7 +22,9 @@ const routes: Routes = [
...BreadcrumbService.generateRouteDataConfiguration({ ...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.EDIT-DESCRIPTION' title: 'BREADCRUMBS.EDIT-DESCRIPTION'
}), }),
title: 'DESCRIPTION-EDITOR.TITLE-EDIT-DESCRIPTION' getFromTitleService: true,
usePrefix: false
//title: 'DESCRIPTION-EDITOR.TITLE-EDIT-DESCRIPTION'
// , // ,
// authContext: { // authContext: {
// permissions: [AppPermission.EditDescription] // permissions: [AppPermission.EditDescription]

View File

@ -51,6 +51,7 @@ import { map, takeUntil } from 'rxjs/operators';
import { DmpEditorModel, DmpFieldIndicator } from './dmp-editor.model'; import { DmpEditorModel, DmpFieldIndicator } from './dmp-editor.model';
import { DmpEditorResolver } from './dmp-editor.resolver'; import { DmpEditorResolver } from './dmp-editor.resolver';
import { DmpEditorService } from './dmp-editor.service'; import { DmpEditorService } from './dmp-editor.service';
import { Title } from '@angular/platform-browser';
@Component({ @Component({
selector: 'app-dmp-editor', selector: 'app-dmp-editor',
@ -164,9 +165,15 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
public enumUtils: EnumUtils, public enumUtils: EnumUtils,
public descriptionTemplateService: DescriptionTemplateService, public descriptionTemplateService: DescriptionTemplateService,
public userService: UserService, 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); super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService, lockService, authService, configurationService);
} }

View File

@ -35,7 +35,9 @@ const routes: Routes = [
data: { data: {
...BreadcrumbService.generateRouteDataConfiguration({ ...BreadcrumbService.generateRouteDataConfiguration({
title: 'BREADCRUMBS.EDIT-DMP' title: 'BREADCRUMBS.EDIT-DMP'
}) }),
getFromTitleService: true,
usePrefix: false
} }
} }