Adds: Breadcrumb on dmp overview page, Fixes: bug on breadcrumbs at page refresh

This commit is contained in:
apapachristou 2019-05-22 12:52:53 +03:00
parent 7844c33b7c
commit f71f0ed3ff
3 changed files with 23 additions and 9 deletions

View File

@ -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.editMode || this.dmp.status === Status.Inactive) { this.formGroup.disable(); }
if (this.isAuthenticated) { if (this.isAuthenticated) {
// 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', parentComponentName: 'DmpListingComponent',
label: 'DMPs', label: breadcrumb.label,
url: 'plans', 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()] // 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; this.associatedUsers = data.associatedUsers;
}); });

View File

@ -26,7 +26,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
@ViewChild(MatSort) sort: MatSort; @ViewChild(MatSort) sort: MatSort;
@ViewChild(DmpCriteriaComponent) criteria: DmpCriteriaComponent; @ViewChild(DmpCriteriaComponent) criteria: DmpCriteriaComponent;
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([]); breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of([{ parentComponentName: null, label: 'DMPs', url: "/plans" }]);
itemId: string; itemId: string;
projectId: string; projectId: string;
showProject: boolean; 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.criteria.setCriteria({ like: null, projects: [project], groupIds: null, allVersions: false });
this.refresh(); this.refresh();
projectLabel = this.route.snapshot.queryParams.projectLabel; 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)); this.criteria.setRefreshCallback((resetPages) => this.refresh(resetPages));
} else { } else {
this.itemId = params['groupId']; this.itemId = params['groupId'];
@ -84,6 +84,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
this.titlePrefix = 'for ' + projectLabel; this.titlePrefix = 'for ' + projectLabel;
} }
} }
}); });
} }
@ -131,7 +132,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit, IBread
} }
rowClicked(dmp: DmpListingModel) { 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]); // this.router.navigate(['/plans/edit/' + dmp.id]);
} }

View File

@ -14,6 +14,8 @@ import { ConfirmationDialogComponent } from '../../../library/confirmation-dialo
import { UiNotificationService, SnackBarNotificationLevel } from '../../../core/services/notification/ui-notification-service'; import { UiNotificationService, SnackBarNotificationLevel } from '../../../core/services/notification/ui-notification-service';
import * as FileSaver from 'file-saver'; import * as FileSaver from 'file-saver';
import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component'; import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component';
import { Observable } from 'rxjs';
import { BreadcrumbItem } from '../../misc/breadcrumb/definition/breadcrumb-item';
@Component({ @Component({
selector: 'app-dmp-overview', selector: 'app-dmp-overview',
@ -24,6 +26,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
dmp: DmpOverviewModel; dmp: DmpOverviewModel;
isNew = true; isNew = true;
breadCrumbs: Observable<BreadcrumbItem[]> = Observable.of();
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
@ -51,6 +54,12 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
.subscribe(data => { .subscribe(data => {
this.dmp = 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 } }); this.router.navigate(['/datasets'], { queryParams: { dmpId: dmpId } });
} }
goToUri(uri: string){ goToUri(uri: string) {
window.open(uri, "_blank"); window.open(uri, "_blank");
} }