Skip to content

Commit 276452e

Browse files
committed
Update DSO menu to also work for subpaths of the DSO and add missing messages
1 parent f6263f8 commit 276452e

4 files changed

Lines changed: 37 additions & 25 deletions

File tree

src/app/shared/menu/providers/helper-providers/dso.menu.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('DSpaceObjectPageMenuProvider', () => {
8383
});
8484
});
8585

86-
it('return undefined when no DSO is present on the current route', (done) => {
86+
it('return the first parent DSO when no DSO is present on the current route', (done) => {
8787
const route = {
8888
data: {},
8989
parent: {
@@ -96,7 +96,7 @@ describe('DSpaceObjectPageMenuProvider', () => {
9696
} as any;
9797

9898
provider.getRouteContext(route, undefined).subscribe((dso) => {
99-
expect(dso).toBeUndefined();
99+
expect(dso).toEqual(item);
100100
done();
101101
});
102102
});

src/app/shared/menu/providers/helper-providers/dso.menu.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import { ActivatedRouteSnapshot, RouterStateSnapshot, } from '@angular/router';
99
import { Observable, of } from 'rxjs';
1010
import { DSpaceObject } from '../../../../core/shared/dspace-object.model';
11+
import { hasNoValue, hasValue } from '../../../empty.util';
1112
import { AbstractRouteContextMenuProvider } from './route-context.menu';
1213
import { RemoteData } from '../../../../core/data/remote-data';
13-
import { hasValue } from '../../../empty.util';
1414

1515
/**
1616
* Helper provider for DSpace object page based menus
@@ -21,7 +21,13 @@ export abstract class DSpaceObjectPageMenuProvider extends AbstractRouteContextM
2121
* Retrieve the dso from the current route data
2222
*/
2323
public getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<DSpaceObject | undefined> {
24-
const dsoRD: RemoteData<DSpaceObject> = route.data.dso;
24+
let dsoRD: RemoteData<DSpaceObject> = route.data.dso;
25+
// Check if one of the parent routes has a DSO
26+
while (hasValue(route.parent) && hasNoValue(dsoRD)) {
27+
route = route.parent;
28+
dsoRD = route.data.dso;
29+
}
30+
2531
if (hasValue(dsoRD) && dsoRD.hasSucceeded && hasValue(dsoRD.payload)) {
2632
return of(dsoRD.payload);
2733
} else {

src/app/shared/menu/providers/statistics.menu.ts

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,21 @@
77
*/
88

99
import { Injectable } from '@angular/core';
10-
import { ActivatedRouteSnapshot, RouterStateSnapshot, } from '@angular/router';
1110
import { Observable, of, } from 'rxjs';
12-
import { hasNoValue, hasValue } from '../../empty.util';
11+
import { hasValue } from '../../empty.util';
1312
import { MenuItemType } from '../menu-item-type.model';
1413
import { PartialMenuSection } from '../menu-provider.model';
15-
import { AbstractRouteContextMenuProvider } from './helper-providers/route-context.menu';
1614
import { DSpaceObject } from '../../../core/shared/dspace-object.model';
17-
import { RemoteData } from '../../../core/data/remote-data';
1815
import { getDSORoute } from '../../../app-routing-paths';
19-
16+
import { DSpaceObjectPageMenuProvider } from './helper-providers/dso.menu';
2017

2118
/**
2219
* Menu provider to create the statistics menu section depending on the page it is on
2320
* When the user is on a DSO page or a derivative, this menu section will contain a link to the statistics of that DSO
2421
* In all other cases the menu section will contain a link to the repository wide statistics
2522
*/
2623
@Injectable()
27-
export class StatisticsMenuProvider extends AbstractRouteContextMenuProvider<DSpaceObject> {
28-
29-
public getRouteContext(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<DSpaceObject> {
30-
let dsoRD: RemoteData<DSpaceObject> = route.data.dso;
31-
// Check if one of the parent routes has a DSO
32-
while (hasValue(route.parent) && hasNoValue(dsoRD)) {
33-
route = route.parent;
34-
dsoRD = route.data.dso;
35-
}
36-
37-
if (hasValue(dsoRD) && dsoRD.hasSucceeded && hasValue(dsoRD.payload)) {
38-
return of(dsoRD.payload);
39-
} else {
40-
return of(undefined);
41-
}
42-
}
24+
export class StatisticsMenuProvider extends DSpaceObjectPageMenuProvider {
4325

4426
public getSectionsForContext(dso: DSpaceObject): Observable<PartialMenuSection[]> {
4527

@@ -66,4 +48,8 @@ export class StatisticsMenuProvider extends AbstractRouteContextMenuProvider<DSp
6648
] as PartialMenuSection[]);
6749
}
6850

51+
protected isApplicable(dso: DSpaceObject): boolean {
52+
return true;
53+
}
54+
6955
}

src/assets/i18n/en.json5

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,8 @@
10841084

10851085
"collection.page.news": "News",
10861086

1087+
"collection.page.options": "Options",
1088+
10871089
"collection.select.confirm": "Confirm selected",
10881090

10891091
"collection.select.empty": "No collections to show",
@@ -1296,6 +1298,8 @@
12961298

12971299
"community.page.news": "News",
12981300

1301+
"community.page.options": "Options",
1302+
12991303
"community.all-lists.head": "Subcommunities and Collections",
13001304

13011305
"community.sub-collection-list.head": "Collections in this Community",
@@ -2406,6 +2410,8 @@
24062410

24072411
"item.page.link.simple": "Simple item page",
24082412

2413+
"item.page.options": "Options",
2414+
24092415
"item.page.orcid.title": "ORCID",
24102416

24112417
"item.page.orcid.tooltip": "Open ORCID setting page",
@@ -2664,6 +2670,8 @@
26642670

26652671
"journal.page.publisher": "Publisher",
26662672

2673+
"journal.page.options": "Options",
2674+
26672675
"journal.page.titleprefix": "Journal: ",
26682676

26692677
"journal.search.results.head": "Journal Search Results",
@@ -2688,6 +2696,8 @@
26882696

26892697
"journalissue.page.number": "Number",
26902698

2699+
"journalissue.page.options": "Options",
2700+
26912701
"journalissue.page.titleprefix": "Journal Issue: ",
26922702

26932703
"journalvolume.listelement.badge": "Journal Volume",
@@ -2698,6 +2708,8 @@
26982708

26992709
"journalvolume.page.issuedate": "Issue Date",
27002710

2711+
"journalvolume.page.options": "Options",
2712+
27012713
"journalvolume.page.titleprefix": "Journal Volume: ",
27022714

27032715
"journalvolume.page.volume": "Volume",
@@ -3058,6 +3070,8 @@
30583070

30593071
"orgunit.page.id": "ID",
30603072

3073+
"orgunit.page.options": "Options",
3074+
30613075
"orgunit.page.titleprefix": "Organizational Unit: ",
30623076

30633077
"pagination.options.description": "Pagination options",
@@ -3090,6 +3104,8 @@
30903104

30913105
"person.page.link.full": "Show all metadata",
30923106

3107+
"person.page.options": "Options",
3108+
30933109
"person.page.orcid": "ORCID",
30943110

30953111
"person.page.staffid": "Staff ID",
@@ -3302,6 +3318,8 @@
33023318

33033319
"project.page.keyword": "Keywords",
33043320

3321+
"project.page.options": "Options",
3322+
33053323
"project.page.status": "Status",
33063324

33073325
"project.page.titleprefix": "Research Project: ",
@@ -3322,6 +3340,8 @@
33223340

33233341
"publication.page.publisher": "Publisher",
33243342

3343+
"publication.page.options": "Options",
3344+
33253345
"publication.page.titleprefix": "Publication: ",
33263346

33273347
"publication.page.volume-title": "Volume Title",

0 commit comments

Comments
 (0)