From f71f0ed3ff9ec110caf123b51880b475da623249 Mon Sep 17 00:00:00 2001 From: apapachristou Date: Wed, 22 May 2019 12:52:53 +0300 Subject: [PATCH] Adds: Breadcrumb on dmp overview page, Fixes: bug on breadcrumbs at page refresh --- .../src/app/ui/dmp/editor/dmp-editor.component.ts | 14 +++++++++----- .../app/ui/dmp/listing/dmp-listing.component.ts | 7 ++++--- .../app/ui/dmp/overview/dmp-overview.component.ts | 11 ++++++++++- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index 05a33030d..d8f27bde5 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -154,14 +154,18 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC if (!this.editMode || this.dmp.status === Status.Inactive) { this.formGroup.disable(); } if (this.isAuthenticated) { // if (!this.isAuthenticated) { - this.breadCrumbs = Observable.of([ + const breadCrumbs = []; + breadCrumbs.push({ parentComponentName: null, label: 'DMPs', url: "/plans" }); + const breadcrumb = await this.projectService.getSingle(this.dmp.project.id).map(x => ({ label: x.label, url: '/projects/edit/' + x.id }) as BreadcrumbItem).toPromise(); + breadCrumbs.push( { parentComponentName: 'DmpListingComponent', - label: 'DMPs', - url: 'plans', - notFoundResolver: [await this.projectService.getSingle(this.dmp.project.id).map(x => ({ label: x.label, url: '/projects/edit/' + x.id }) as BreadcrumbItem).toPromise()] - }] + label: breadcrumb.label, + url: breadcrumb.url, + // notFoundResolver: [await this.projectService.getSingle(this.dmp.project.id).map(x => ({ label: x.label, url: '/projects/edit/' + x.id }) as BreadcrumbItem).toPromise()] + } ); + this.breadCrumbs = Observable.of(breadCrumbs); } this.associatedUsers = data.associatedUsers; }); diff --git a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts index aaa67d48b..0609e5663 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts +++ b/dmp-frontend/src/app/ui/dmp/listing/dmp-listing.component.ts @@ -26,7 +26,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread @ViewChild(MatSort) sort: MatSort; @ViewChild(DmpCriteriaComponent) criteria: DmpCriteriaComponent; - breadCrumbs: Observable = Observable.of([]); + breadCrumbs: Observable = Observable.of([{ parentComponentName: null, label: 'DMPs', url: "/plans" }]); itemId: string; projectId: string; showProject: boolean; @@ -58,7 +58,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread this.criteria.setCriteria({ like: null, projects: [project], groupIds: null, allVersions: false }); this.refresh(); projectLabel = this.route.snapshot.queryParams.projectLabel; - this.breadCrumbs = Observable.of([{ parentComponentName: 'ProjectEditorComponent', label: projectLabel, url: '/projects/edit/' + this.projectId }]); + // this.breadCrumbs = Observable.of([{ parentComponentName: 'ProjectEditorComponent', label: projectLabel, url: '/projects/edit/' + this.projectId }]); this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages)); } else { this.itemId = params['groupId']; @@ -84,6 +84,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread this.titlePrefix = 'for ' + projectLabel; } } + }); } @@ -131,7 +132,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread } rowClicked(dmp: DmpListingModel) { - this.router.navigate(['/plans/overview/' + dmp.id]); + this.router.navigate(['/plans/overview/' + dmp.id, { dmpLabel: dmp.label }]); // this.router.navigate(['/plans/edit/' + dmp.id]); } diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index 7dd5f7acb..c17e89db2 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -14,6 +14,8 @@ import { ConfirmationDialogComponent } from '../../../library/confirmation-dialo import { UiNotificationService, SnackBarNotificationLevel } from '../../../core/services/notification/ui-notification-service'; import * as FileSaver from 'file-saver'; import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component'; +import { Observable } from 'rxjs'; +import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item'; @Component({ selector: 'app-dmp-overview', @@ -24,6 +26,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { dmp: DmpOverviewModel; isNew = true; + breadCrumbs: Observable = Observable.of(); constructor( private route: ActivatedRoute, @@ -51,6 +54,12 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { .subscribe(data => { this.dmp = data; }) + if (params['dmpLabel'] !== undefined) { + const breadCrumbs = []; + breadCrumbs.push({ parentComponentName: null, label: 'DMPs', url: "/plans" }); + breadCrumbs.push({ parentComponentName: 'DmpListingComponent', label: params['dmpLabel'], url: '/overview/' + itemId }); + this.breadCrumbs = Observable.of(breadCrumbs); + } } }); } @@ -75,7 +84,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { this.router.navigate(['/datasets'], { queryParams: { dmpId: dmpId } }); } - goToUri(uri: string){ + goToUri(uri: string) { window.open(uri, "_blank"); }