mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Update DSO menu to also work for subpaths of the DSO and add missing messages
This commit is contained in:
@@ -83,7 +83,7 @@ describe('DSpaceObjectPageMenuProvider', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('return undefined when no DSO is present on the current route', (done) => {
|
||||
it('return the first parent DSO when no DSO is present on the current route', (done) => {
|
||||
const route = {
|
||||
data: {},
|
||||
parent: {
|
||||
@@ -96,7 +96,7 @@ describe('DSpaceObjectPageMenuProvider', () => {
|
||||
} as any;
|
||||
|
||||
provider.getRouteContext(route, undefined).subscribe((dso) => {
|
||||
expect(dso).toBeUndefined();
|
||||
expect(dso).toEqual(item);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@@ -8,9 +8,9 @@
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot, } from '@angular/router';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
|
||||
import { hasNoValue, hasValue } from '../../../empty.util';
|
||||
import { AbstractRouteContextMenuProvider } from './route-context.menu';
|
||||
import { RemoteData } from '../../../../core/data/remote-data';
|
||||
import { hasValue } from '../../../empty.util';
|
||||
|
||||
/**
|
||||
* Helper provider for DSpace object page based menus
|
||||
@@ -21,7 +21,13 @@ export abstract class DSpaceObjectPageMenuProvider extends AbstractRouteContextM
|
||||
* Retrieve the dso from the current route data
|
||||
*/
|
||||
public getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<DSpaceObject | undefined> {
|
||||
const dsoRD: RemoteData<DSpaceObject> = route.data.dso;
|
||||
let dsoRD: RemoteData<DSpaceObject> = route.data.dso;
|
||||
// Check if one of the parent routes has a DSO
|
||||
while (hasValue(route.parent) && hasNoValue(dsoRD)) {
|
||||
route = route.parent;
|
||||
dsoRD = route.data.dso;
|
||||
}
|
||||
|
||||
if (hasValue(dsoRD) && dsoRD.hasSucceeded && hasValue(dsoRD.payload)) {
|
||||
return of(dsoRD.payload);
|
||||
} else {
|
||||
|
@@ -7,16 +7,13 @@
|
||||
*/
|
||||
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, RouterStateSnapshot, } from '@angular/router';
|
||||
import { Observable, of, } from 'rxjs';
|
||||
import { hasNoValue, hasValue } from '../../empty.util';
|
||||
import { hasValue } from '../../empty.util';
|
||||
import { MenuItemType } from '../menu-item-type.model';
|
||||
import { PartialMenuSection } from '../menu-provider.model';
|
||||
import { AbstractRouteContextMenuProvider } from './helper-providers/route-context.menu';
|
||||
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
|
||||
import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { getDSORoute } from '../../../app-routing-paths';
|
||||
|
||||
import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu';
|
||||
|
||||
/**
|
||||
* Menu provider to create the statistics menu section depending on the page it is on
|
||||
@@ -24,22 +21,7 @@ import { getDSORoute } from '../../../app-routing-paths';
|
||||
* In all other cases the menu section will contain a link to the repository wide statistics
|
||||
*/
|
||||
@Injectable()
|
||||
export class StatisticsMenuProvider extends AbstractRouteContextMenuProvider<DSpaceObject> {
|
||||
|
||||
public getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<DSpaceObject> {
|
||||
let dsoRD: RemoteData<DSpaceObject> = route.data.dso;
|
||||
// Check if one of the parent routes has a DSO
|
||||
while (hasValue(route.parent) && hasNoValue(dsoRD)) {
|
||||
route = route.parent;
|
||||
dsoRD = route.data.dso;
|
||||
}
|
||||
|
||||
if (hasValue(dsoRD) && dsoRD.hasSucceeded && hasValue(dsoRD.payload)) {
|
||||
return of(dsoRD.payload);
|
||||
} else {
|
||||
return of(undefined);
|
||||
}
|
||||
}
|
||||
export class StatisticsMenuProvider extends DSpaceObjectPageMenuProvider {
|
||||
|
||||
public getSectionsForContext(dso: DSpaceObject): Observable<PartialMenuSection[]> {
|
||||
|
||||
@@ -66,4 +48,8 @@ export class StatisticsMenuProvider extends AbstractRouteContextMenuProvider<DSp
|
||||
] as PartialMenuSection[]);
|
||||
}
|
||||
|
||||
protected isApplicable(dso: DSpaceObject): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1084,6 +1084,8 @@
|
||||
|
||||
"collection.page.news": "News",
|
||||
|
||||
"collection.page.options": "Options",
|
||||
|
||||
"collection.select.confirm": "Confirm selected",
|
||||
|
||||
"collection.select.empty": "No collections to show",
|
||||
@@ -1296,6 +1298,8 @@
|
||||
|
||||
"community.page.news": "News",
|
||||
|
||||
"community.page.options": "Options",
|
||||
|
||||
"community.all-lists.head": "Subcommunities and Collections",
|
||||
|
||||
"community.sub-collection-list.head": "Collections in this Community",
|
||||
@@ -2406,6 +2410,8 @@
|
||||
|
||||
"item.page.link.simple": "Simple item page",
|
||||
|
||||
"item.page.options": "Options",
|
||||
|
||||
"item.page.orcid.title": "ORCID",
|
||||
|
||||
"item.page.orcid.tooltip": "Open ORCID setting page",
|
||||
@@ -2664,6 +2670,8 @@
|
||||
|
||||
"journal.page.publisher": "Publisher",
|
||||
|
||||
"journal.page.options": "Options",
|
||||
|
||||
"journal.page.titleprefix": "Journal: ",
|
||||
|
||||
"journal.search.results.head": "Journal Search Results",
|
||||
@@ -2688,6 +2696,8 @@
|
||||
|
||||
"journalissue.page.number": "Number",
|
||||
|
||||
"journalissue.page.options": "Options",
|
||||
|
||||
"journalissue.page.titleprefix": "Journal Issue: ",
|
||||
|
||||
"journalvolume.listelement.badge": "Journal Volume",
|
||||
@@ -2698,6 +2708,8 @@
|
||||
|
||||
"journalvolume.page.issuedate": "Issue Date",
|
||||
|
||||
"journalvolume.page.options": "Options",
|
||||
|
||||
"journalvolume.page.titleprefix": "Journal Volume: ",
|
||||
|
||||
"journalvolume.page.volume": "Volume",
|
||||
@@ -3058,6 +3070,8 @@
|
||||
|
||||
"orgunit.page.id": "ID",
|
||||
|
||||
"orgunit.page.options": "Options",
|
||||
|
||||
"orgunit.page.titleprefix": "Organizational Unit: ",
|
||||
|
||||
"pagination.options.description": "Pagination options",
|
||||
@@ -3090,6 +3104,8 @@
|
||||
|
||||
"person.page.link.full": "Show all metadata",
|
||||
|
||||
"person.page.options": "Options",
|
||||
|
||||
"person.page.orcid": "ORCID",
|
||||
|
||||
"person.page.staffid": "Staff ID",
|
||||
@@ -3302,6 +3318,8 @@
|
||||
|
||||
"project.page.keyword": "Keywords",
|
||||
|
||||
"project.page.options": "Options",
|
||||
|
||||
"project.page.status": "Status",
|
||||
|
||||
"project.page.titleprefix": "Research Project: ",
|
||||
@@ -3322,6 +3340,8 @@
|
||||
|
||||
"publication.page.publisher": "Publisher",
|
||||
|
||||
"publication.page.options": "Options",
|
||||
|
||||
"publication.page.titleprefix": "Publication: ",
|
||||
|
||||
"publication.page.volume-title": "Volume Title",
|
||||
|
Reference in New Issue
Block a user