Skip to content

Commit 5ac23e6

Browse files
[DURACOM-445] add authority based search relations component
1 parent 7657918 commit 5ac23e6

9 files changed

Lines changed: 152 additions & 4 deletions

File tree

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,19 @@
5858
</div>
5959
</div>
6060
<div class="mt-5 w-100 px-0">
61-
<ds-tabbed-related-entities-search [item]="object"
62-
[relationTypes]="[{
61+
@if (areAuthorityRelationsEnabled) {
62+
<ds-authority-related-entities-search
63+
[item]="object"
64+
[configuration]="'RELATION.Person.publication'"
65+
></ds-authority-related-entities-search>
66+
} @else {
67+
<ds-tabbed-related-entities-search [item]="object"
68+
[relationTypes]="[{
6369
label: 'isAuthorOfPublication',
6470
filter: 'isAuthorOfPublication',
6571
configuration: 'default-relationships'
6672
}]">
67-
</ds-tabbed-related-entities-search>
73+
</ds-tabbed-related-entities-search>
74+
}
6875
</div>
6976
</div>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { TranslateModule } from '@ngx-translate/core';
77
import { GenericItemPageFieldComponent } from '../../../../item-page/simple/field-components/specific-field/generic/generic-item-page-field.component';
88
import { ThemedItemPageTitleFieldComponent } from '../../../../item-page/simple/field-components/specific-field/title/themed-item-page-field.component';
99
import { ItemComponent } from '../../../../item-page/simple/item-types/shared/item.component';
10+
import { AuthorityRelatedEntitiesSearchComponent } from '../../../../item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component';
1011
import { TabbedRelatedEntitiesSearchComponent } from '../../../../item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component';
1112
import { RelatedItemsComponent } from '../../../../item-page/simple/related-items/related-items-component';
1213
import { DsoEditMenuComponent } from '../../../../shared/dso-page/dso-edit-menu/dso-edit-menu.component';
@@ -22,6 +23,7 @@ import { ThemedThumbnailComponent } from '../../../../thumbnail/themed-thumbnail
2223
templateUrl: './person.component.html',
2324
imports: [
2425
AsyncPipe,
26+
AuthorityRelatedEntitiesSearchComponent,
2527
DsoEditMenuComponent,
2628
GenericItemPageFieldComponent,
2729
MetadataFieldWrapperComponent,

src/app/item-page/simple/item-types/shared/item.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,16 @@ export class ItemComponent implements OnInit {
7979
*/
8080
geospatialItemPageFieldsEnabled = false;
8181

82+
/**
83+
* Flag to check whether to use the default relations or the authority based ones
84+
*/
85+
areAuthorityRelationsEnabled: boolean;
86+
8287
constructor(protected routeService: RouteService,
8388
protected router: Router) {
8489
this.mediaViewer = environment.mediaViewer;
8590
this.geospatialItemPageFieldsEnabled = environment.geospatialMapViewer.enableItemPageFields;
91+
this.areAuthorityRelationsEnabled = environment.item.showAuthorithyRelations;
8692
}
8793

8894
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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>
8+
}
9+
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { NO_ERRORS_SCHEMA } from '@angular/core';
2+
import {
3+
ComponentFixture,
4+
TestBed,
5+
waitForAsync,
6+
} from '@angular/core/testing';
7+
import { Item } from '@dspace/core/shared/item.model';
8+
import { TranslateModule } from '@ngx-translate/core';
9+
10+
import { ThemedConfigurationSearchPageComponent } from '../../../../search-page/themed-configuration-search-page.component';
11+
import { AuthorityRelatedEntitiesSearchComponent } from './authority-related-entities-search.component';
12+
13+
14+
describe('AuthorityRelatedEntitiesSearchComponent', () => {
15+
let component: AuthorityRelatedEntitiesSearchComponent;
16+
let fixture: ComponentFixture<AuthorityRelatedEntitiesSearchComponent>;
17+
18+
const mockItem = {
19+
id: 'test-id-123',
20+
} as Item;
21+
22+
beforeEach(waitForAsync(() => {
23+
TestBed.configureTestingModule({
24+
imports: [TranslateModule.forRoot(), AuthorityRelatedEntitiesSearchComponent],
25+
providers: [],
26+
schemas: [NO_ERRORS_SCHEMA],
27+
})
28+
.overrideComponent(AuthorityRelatedEntitiesSearchComponent, {
29+
remove: {
30+
imports: [
31+
ThemedConfigurationSearchPageComponent,
32+
],
33+
},
34+
})
35+
.compileComponents();
36+
}));
37+
38+
beforeEach(() => {
39+
fixture = TestBed.createComponent(AuthorityRelatedEntitiesSearchComponent);
40+
component = fixture.componentInstance;
41+
component.item = mockItem;
42+
component.configuration = 'relations-configuration';
43+
fixture.detectChanges();
44+
});
45+
46+
it('should create', () => {
47+
expect(component).toBeTruthy();
48+
});
49+
50+
it('should set searchFilter on init', () => {
51+
component.item = mockItem;
52+
component.ngOnInit();
53+
54+
expect(component.searchFilter).toBe('scope=test-id-123');
55+
});
56+
57+
it('should render configuration search page when configuration is provided', () => {
58+
component.item = mockItem;
59+
component.configuration = 'test-config';
60+
61+
fixture.detectChanges();
62+
63+
const searchPage = fixture.nativeElement.querySelector('ds-configuration-search-page');
64+
expect(searchPage).toBeTruthy();
65+
});
66+
67+
it('should NOT render configuration search page when configuration is missing', () => {
68+
component.item = mockItem;
69+
component.configuration = undefined;
70+
71+
fixture.detectChanges();
72+
73+
const searchPage = fixture.nativeElement.querySelector('ds-configuration-search-page');
74+
expect(searchPage).toBeFalsy();
75+
});
76+
77+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import {
2+
Component,
3+
Input,
4+
OnInit,
5+
} from '@angular/core';
6+
import { Item } from '@dspace/core/shared/item.model';
7+
8+
import { ThemedConfigurationSearchPageComponent } from '../../../../search-page/themed-configuration-search-page.component';
9+
10+
@Component({
11+
selector: 'ds-authority-related-entities-search',
12+
templateUrl: './authority-related-entities-search.component.html',
13+
imports: [
14+
ThemedConfigurationSearchPageComponent,
15+
],
16+
})
17+
/**
18+
* A component to show related items as search results, based on authority value
19+
*/
20+
export class AuthorityRelatedEntitiesSearchComponent implements OnInit {
21+
/**
22+
* Filter used for set scope in discovery invocation
23+
*/
24+
searchFilter: string;
25+
/**
26+
* Name of configuration for this box
27+
*/
28+
@Input() configuration: string;
29+
/**
30+
* flag for enable/disable search bar
31+
*/
32+
@Input() searchEnabled = true;
33+
34+
35+
@Input() item: Item;
36+
37+
38+
ngOnInit() {
39+
this.searchFilter = `scope=${this.item.id}`;
40+
}
41+
42+
}

src/app/shared/listable.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import { ItemPageUriFieldComponent } from '../item-page/simple/field-components/
7171
import { PublicationComponent } from '../item-page/simple/item-types/publication/publication.component';
7272
import { UntypedItemComponent } from '../item-page/simple/item-types/untyped-item/untyped-item.component';
7373
import { ThemedMetadataRepresentationListComponent } from '../item-page/simple/metadata-representation-list/themed-metadata-representation-list.component';
74+
import { AuthorityRelatedEntitiesSearchComponent } from '../item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component';
7475
import { TabbedRelatedEntitiesSearchComponent } from '../item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component';
7576
import { RelatedItemsComponent } from '../item-page/simple/related-items/related-items-component';
7677
import { ThemedThumbnailComponent } from '../thumbnail/themed-thumbnail.component';
@@ -243,6 +244,7 @@ const ENTRY_COMPONENTS = [
243244
ItemActionsComponent,
244245
PersonInputSuggestionsComponent,
245246
TabbedRelatedEntitiesSearchComponent,
247+
AuthorityRelatedEntitiesSearchComponent,
246248
WorkspaceItemAdminWorkflowActionsComponent,
247249
WorkflowItemAdminWorkflowActionsComponent,
248250
FormsModule,

src/config/default-app-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ export class DefaultAppConfig implements AppConfig {
348348
},
349349
// If true, the search result in item page will display relations based on authority.
350350
// If false,the search result in item page will display default DSpace relations.
351-
showAuthorithyRelations: false,
351+
showAuthorithyRelations: true,
352352
};
353353

354354
// Community Page Config

src/themes/custom/app/entity-groups/research-entities/item-pages/person/person.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ThemedResultsBackButtonComponent } from 'src/app/shared/results-back-bu
1414
import { ThemedThumbnailComponent } from 'src/app/thumbnail/themed-thumbnail.component';
1515

1616
import { PersonComponent as BaseComponent } from '../../../../../../../app/entity-groups/research-entities/item-pages/person/person.component';
17+
import { AuthorityRelatedEntitiesSearchComponent } from '../../../../../../../app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component';
1718
import { listableObjectComponent } from '../../../../../../../app/shared/object-collection/shared/listable-object/listable-object.decorator';
1819

1920
@listableObjectComponent('Person', ViewMode.StandalonePage, Context.Any, 'custom')
@@ -25,6 +26,7 @@ import { listableObjectComponent } from '../../../../../../../app/shared/object-
2526
templateUrl: '../../../../../../../app/entity-groups/research-entities/item-pages/person/person.component.html',
2627
imports: [
2728
AsyncPipe,
29+
AuthorityRelatedEntitiesSearchComponent,
2830
DsoEditMenuComponent,
2931
GenericItemPageFieldComponent,
3032
MetadataFieldWrapperComponent,

0 commit comments

Comments
 (0)