Skip to content

Commit 23ecd1e

Browse files
[DURACOM-445] add nav tabs to authority-related-entities-search, fix old module import
1 parent 5ac23e6 commit 23ecd1e

7 files changed

Lines changed: 109 additions & 28 deletions

File tree

src/app/entity-groups/research-entities/item-pages/person/person.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
@if (areAuthorityRelationsEnabled) {
6262
<ds-authority-related-entities-search
6363
[item]="object"
64-
[configuration]="'RELATION.Person.publication'"
64+
[configurations]="['RELATION.Person.researchoutputs', 'RELATION.Person.projects']"
6565
></ds-authority-related-entities-search>
6666
} @else {
6767
<ds-tabbed-related-entities-search [item]="object"
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,41 @@
1-
@if (configuration) {
2-
<ds-configuration-search-page class="w-100"
3-
[fixedFilterQuery]="searchFilter"
4-
[configuration]="configuration"
5-
[searchEnabled]="searchEnabled"
6-
[showScopeSelector]="false"
7-
></ds-configuration-search-page>
1+
@if (configurations.length > 1) {
2+
<ul ngbNav #tabs="ngbNav"
3+
[destroyOnHide]="true"
4+
[activeId]="activeTab$ | async"
5+
(navChange)="onTabChange($event)"
6+
class="nav-tabs">
7+
8+
@for (config of configurations; track config) {
9+
<li [ngbNavItem]="config">
10+
<a ngbNavLink>
11+
{{('item.page.relationships.' + config) | translate}}
12+
</a>
13+
14+
<ng-template ngbNavContent>
15+
<div class="mt-4">
16+
<ds-configuration-search-page
17+
class="w-100"
18+
[fixedFilterQuery]="searchFilter"
19+
[configuration]="config"
20+
[searchEnabled]="searchEnabled"
21+
[showScopeSelector]="false">
22+
</ds-configuration-search-page>
23+
</div>
24+
</ng-template>
25+
</li>
26+
}
27+
</ul>
28+
29+
<div [ngbNavOutlet]="tabs"></div>
830
}
931

1032

33+
@if (configurations.length === 1) {
34+
<ds-configuration-search-page
35+
class="w-100"
36+
[fixedFilterQuery]="searchFilter"
37+
[configuration]="configurations[0]"
38+
[searchEnabled]="searchEnabled"
39+
[showScopeSelector]="false">
40+
</ds-configuration-search-page>
41+
}

src/app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component.spec.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ import {
44
TestBed,
55
waitForAsync,
66
} from '@angular/core/testing';
7+
import {
8+
ActivatedRoute,
9+
Router,
10+
} from '@angular/router';
711
import { Item } from '@dspace/core/shared/item.model';
12+
import { RouterMock } from '@dspace/core/testing/router.mock';
813
import { TranslateModule } from '@ngx-translate/core';
14+
import { of } from 'rxjs';
915

1016
import { ThemedConfigurationSearchPageComponent } from '../../../../search-page/themed-configuration-search-page.component';
1117
import { AuthorityRelatedEntitiesSearchComponent } from './authority-related-entities-search.component';
@@ -18,11 +24,27 @@ describe('AuthorityRelatedEntitiesSearchComponent', () => {
1824
const mockItem = {
1925
id: 'test-id-123',
2026
} as Item;
27+
const router = new RouterMock();
28+
2129

2230
beforeEach(waitForAsync(() => {
2331
TestBed.configureTestingModule({
2432
imports: [TranslateModule.forRoot(), AuthorityRelatedEntitiesSearchComponent],
25-
providers: [],
33+
providers: [
34+
{
35+
provide: ActivatedRoute,
36+
useValue: {
37+
queryParams: of({ tab: 'relations-configuration' }),
38+
snapshot: {
39+
queryParams: {
40+
scope: 'collection-uuid',
41+
query: 'test',
42+
},
43+
},
44+
},
45+
},
46+
{ provide: Router, useValue: router },
47+
],
2648
schemas: [NO_ERRORS_SCHEMA],
2749
})
2850
.overrideComponent(AuthorityRelatedEntitiesSearchComponent, {
@@ -39,7 +61,7 @@ describe('AuthorityRelatedEntitiesSearchComponent', () => {
3961
fixture = TestBed.createComponent(AuthorityRelatedEntitiesSearchComponent);
4062
component = fixture.componentInstance;
4163
component.item = mockItem;
42-
component.configuration = 'relations-configuration';
64+
component.configurations = ['relations-configuration'];
4365
fixture.detectChanges();
4466
});
4567

@@ -56,7 +78,7 @@ describe('AuthorityRelatedEntitiesSearchComponent', () => {
5678

5779
it('should render configuration search page when configuration is provided', () => {
5880
component.item = mockItem;
59-
component.configuration = 'test-config';
81+
component.configurations = ['test-config'];
6082

6183
fixture.detectChanges();
6284

@@ -66,7 +88,7 @@ describe('AuthorityRelatedEntitiesSearchComponent', () => {
6688

6789
it('should NOT render configuration search page when configuration is missing', () => {
6890
component.item = mockItem;
69-
component.configuration = undefined;
91+
component.configurations = [];
7092

7193
fixture.detectChanges();
7294

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,52 @@
1+
import { AsyncPipe } from '@angular/common';
12
import {
23
Component,
34
Input,
45
OnInit,
56
} from '@angular/core';
6-
import { Item } from '@dspace/core/shared/item.model';
7+
import {
8+
NgbNav,
9+
NgbNavContent,
10+
NgbNavItem,
11+
NgbNavLink,
12+
NgbNavOutlet,
13+
} from '@ng-bootstrap/ng-bootstrap';
14+
import { TranslateModule } from '@ngx-translate/core';
715

816
import { ThemedConfigurationSearchPageComponent } from '../../../../search-page/themed-configuration-search-page.component';
17+
import { TabbedRelatedEntitiesSearchComponent } from '../tabbed-related-entities-search/tabbed-related-entities-search.component';
918

1019
@Component({
1120
selector: 'ds-authority-related-entities-search',
1221
templateUrl: './authority-related-entities-search.component.html',
1322
imports: [
23+
AsyncPipe,
24+
NgbNav,
25+
NgbNavContent,
26+
NgbNavItem,
27+
NgbNavLink,
28+
NgbNavOutlet,
1429
ThemedConfigurationSearchPageComponent,
30+
TranslateModule,
1531
],
1632
})
1733
/**
1834
* A component to show related items as search results, based on authority value
1935
*/
20-
export class AuthorityRelatedEntitiesSearchComponent implements OnInit {
36+
export class AuthorityRelatedEntitiesSearchComponent extends TabbedRelatedEntitiesSearchComponent implements OnInit {
2137
/**
2238
* Filter used for set scope in discovery invocation
2339
*/
2440
searchFilter: string;
2541
/**
26-
* Name of configuration for this box
27-
*/
28-
@Input() configuration: string;
29-
/**
30-
* flag for enable/disable search bar
42+
* Discovery configurations for search page
3143
*/
32-
@Input() searchEnabled = true;
44+
@Input() configurations: string[] = [];
3345

3446

35-
@Input() item: Item;
36-
3747

3848
ngOnInit() {
49+
super.ngOnInit();
3950
this.searchFilter = `scope=${this.item.id}`;
4051
}
41-
4252
}

src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@if (relationTypes.length > 1) {
22
<ul ngbNav #tabs="ngbNav" [destroyOnHide]="true" [activeId]="activeTab$ | async" (navChange)="onTabChange($event)" class="nav-tabs" role="tablist">
3-
@for (relationType of relationTypes; track relationType) {
3+
@for (relationType of relationTypes; track relationType.configuration) {
44
<li [ngbNavItem]="relationType.filter" role="presentation">
55
<a ngbNavLink role="tab">
66
{{'item.page.relationships.' + relationType.label | translate}}

src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ import {
99
Router,
1010
} from '@angular/router';
1111
import { Item } from '@dspace/core/shared/item.model';
12-
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
12+
import {
13+
NgbNav,
14+
NgbNavContent,
15+
NgbNavItem,
16+
NgbNavLink,
17+
NgbNavOutlet,
18+
} from '@ng-bootstrap/ng-bootstrap';
1319
import { TranslateModule } from '@ngx-translate/core';
1420
import { Observable } from 'rxjs';
1521
import { map } from 'rxjs/operators';
@@ -22,7 +28,11 @@ import { RelatedEntitiesSearchComponent } from '../related-entities-search/relat
2228
templateUrl: './tabbed-related-entities-search.component.html',
2329
imports: [
2430
AsyncPipe,
25-
NgbNavModule,
31+
NgbNav,
32+
NgbNavContent,
33+
NgbNavItem,
34+
NgbNavLink,
35+
NgbNavOutlet,
2636
RelatedEntitiesSearchComponent,
2737
TranslateModule,
2838
VarDirective,
@@ -66,8 +76,8 @@ export class TabbedRelatedEntitiesSearchComponent implements OnInit {
6676
*/
6777
activeTab$: Observable<string>;
6878

69-
constructor(private route: ActivatedRoute,
70-
private router: Router) {
79+
constructor(protected route: ActivatedRoute,
80+
protected router: Router) {
7181
}
7282

7383
/**

src/assets/i18n/en.json5

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,6 +3005,10 @@
30053005

30063006
"item.page.relationships.isOrgUnitOfProject": "Research Projects",
30073007

3008+
"item.page.relationships.RELATION.Person.researchoutputs": "Publications",
3009+
3010+
"item.page.relationships.RELATION.Person.projects": "Projects",
3011+
30083012
"item.page.subject": "Keywords",
30093013

30103014
"item.page.uri": "URI",
@@ -4621,6 +4625,10 @@
46214625

46224626
"resource-policies.table.headers.title.for.collection": "Policies for Collection",
46234627

4628+
"RELATION.Person.researchoutputs.search.results.head": "Research Output",
4629+
4630+
"RELATION.Person.projects.search.results.head": "Projects",
4631+
46244632
"root.skip-to-content": "Skip to main content",
46254633

46264634
"search.description": "",

0 commit comments

Comments
 (0)