diff --git a/config/config.example.yml b/config/config.example.yml index 63f0c512f07..8c7f07a7a2a 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -437,6 +437,8 @@ item: iconPosition: IdentifierSubtypesIconPositionEnum.LEFT link: https://ror.org + # Enable authority based relations in item page + showAuthorityRelations: false # Community Page Config community: # Default tab to be shown when browsing a Community. Valid values are: comcols, search, or browse_ diff --git a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html index 24eb09a33a4..cd990c064c4 100644 --- a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html @@ -62,8 +62,19 @@
- + } @else { + - + + }
diff --git a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts index d7297b90b73..67b88aedf51 100644 --- a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.ts @@ -8,6 +8,7 @@ import { GenericItemPageFieldComponent } from '../../../../item-page/simple/fiel import { ItemPageImgFieldComponent } from '../../../../item-page/simple/field-components/specific-field/img/item-page-img-field.component'; import { ThemedItemPageTitleFieldComponent } from '../../../../item-page/simple/field-components/specific-field/title/themed-item-page-field.component'; import { ItemComponent } from '../../../../item-page/simple/item-types/shared/item.component'; +import { AuthorityRelatedEntitiesSearchComponent } from '../../../../item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component'; import { TabbedRelatedEntitiesSearchComponent } from '../../../../item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component'; import { RelatedItemsComponent } from '../../../../item-page/simple/related-items/related-items-component'; import { DsoEditMenuComponent } from '../../../../shared/dso-page/dso-edit-menu/dso-edit-menu.component'; @@ -23,6 +24,7 @@ import { ThemedThumbnailComponent } from '../../../../thumbnail/themed-thumbnail templateUrl: './org-unit.component.html', imports: [ AsyncPipe, + AuthorityRelatedEntitiesSearchComponent, DsoEditMenuComponent, GenericItemPageFieldComponent, ItemPageImgFieldComponent, diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.html b/src/app/entity-groups/research-entities/item-pages/person/person.component.html index e64cffd7bb8..efb92a35621 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.html +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.html @@ -58,12 +58,19 @@
- + } @else { + - + + }
diff --git a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts index 450350a6dab..bb8d79ca138 100644 --- a/src/app/entity-groups/research-entities/item-pages/person/person.component.ts +++ b/src/app/entity-groups/research-entities/item-pages/person/person.component.ts @@ -7,6 +7,7 @@ import { TranslateModule } from '@ngx-translate/core'; import { GenericItemPageFieldComponent } from '../../../../item-page/simple/field-components/specific-field/generic/generic-item-page-field.component'; import { ThemedItemPageTitleFieldComponent } from '../../../../item-page/simple/field-components/specific-field/title/themed-item-page-field.component'; import { ItemComponent } from '../../../../item-page/simple/item-types/shared/item.component'; +import { AuthorityRelatedEntitiesSearchComponent } from '../../../../item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component'; import { TabbedRelatedEntitiesSearchComponent } from '../../../../item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component'; import { RelatedItemsComponent } from '../../../../item-page/simple/related-items/related-items-component'; import { DsoEditMenuComponent } from '../../../../shared/dso-page/dso-edit-menu/dso-edit-menu.component'; @@ -22,6 +23,7 @@ import { ThemedThumbnailComponent } from '../../../../thumbnail/themed-thumbnail templateUrl: './person.component.html', imports: [ AsyncPipe, + AuthorityRelatedEntitiesSearchComponent, DsoEditMenuComponent, GenericItemPageFieldComponent, MetadataFieldWrapperComponent, diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.html b/src/app/entity-groups/research-entities/item-pages/project/project.component.html index 263dbdb96fb..3fb2796059e 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.html +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.html @@ -19,54 +19,54 @@ + + + + + + + + + + - - - - - - - - - - - -
- - - - - - - - - - -
- - {{"item.page.link.full" | translate}} -
-
+
+ + + + + + + + + + +
+ + {{"item.page.link.full" | translate}} + +
+
diff --git a/src/app/item-page/simple/item-types/shared/item.component.ts b/src/app/item-page/simple/item-types/shared/item.component.ts index 99bc027a8d0..8328b3b1975 100644 --- a/src/app/item-page/simple/item-types/shared/item.component.ts +++ b/src/app/item-page/simple/item-types/shared/item.component.ts @@ -79,12 +79,18 @@ export class ItemComponent implements OnInit { */ geospatialItemPageFieldsEnabled = false; + /** + * Flag to check whether to use the default relations or the authority based ones + */ + areAuthorityRelationsEnabled: boolean; + showDownloadLinkAsAttachment: boolean; constructor(protected routeService: RouteService, protected router: Router) { this.mediaViewer = environment.mediaViewer; this.geospatialItemPageFieldsEnabled = environment.geospatialMapViewer.enableItemPageFields; + this.areAuthorityRelationsEnabled = environment.item.showAuthorityRelations; this.showDownloadLinkAsAttachment = environment.layout.showDownloadLinkAsAttachment; } diff --git a/src/app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component.html b/src/app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component.html new file mode 100644 index 00000000000..85e15cb6fbc --- /dev/null +++ b/src/app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component.html @@ -0,0 +1,41 @@ +@if (configurations.length > 1) { + + +
+} + + +@if (configurations.length === 1) { + + +} diff --git a/src/app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component.spec.ts b/src/app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component.spec.ts new file mode 100644 index 00000000000..acb3ecde6e9 --- /dev/null +++ b/src/app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component.spec.ts @@ -0,0 +1,99 @@ +import { NO_ERRORS_SCHEMA } from '@angular/core'; +import { + ComponentFixture, + TestBed, + waitForAsync, +} from '@angular/core/testing'; +import { + ActivatedRoute, + Router, +} from '@angular/router'; +import { Item } from '@dspace/core/shared/item.model'; +import { RouterMock } from '@dspace/core/testing/router.mock'; +import { TranslateModule } from '@ngx-translate/core'; +import { of } from 'rxjs'; + +import { ThemedConfigurationSearchPageComponent } from '../../../../search-page/themed-configuration-search-page.component'; +import { AuthorityRelatedEntitiesSearchComponent } from './authority-related-entities-search.component'; + + +describe('AuthorityRelatedEntitiesSearchComponent', () => { + let component: AuthorityRelatedEntitiesSearchComponent; + let fixture: ComponentFixture; + + const mockItem = { + id: 'test-id-123', + } as Item; + const router = new RouterMock(); + + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + imports: [TranslateModule.forRoot(), AuthorityRelatedEntitiesSearchComponent], + providers: [ + { + provide: ActivatedRoute, + useValue: { + queryParams: of({ tab: 'relations-configuration' }), + snapshot: { + queryParams: { + scope: 'collection-uuid', + query: 'test', + }, + }, + }, + }, + { provide: Router, useValue: router }, + ], + schemas: [NO_ERRORS_SCHEMA], + }) + .overrideComponent(AuthorityRelatedEntitiesSearchComponent, { + remove: { + imports: [ + ThemedConfigurationSearchPageComponent, + ], + }, + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(AuthorityRelatedEntitiesSearchComponent); + component = fixture.componentInstance; + component.item = mockItem; + component.configurations = ['relations-configuration']; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); + + it('should set searchFilter on init', () => { + component.item = mockItem; + component.ngOnInit(); + + expect(component.searchFilter).toBe('scope=test-id-123'); + }); + + it('should render configuration search page when configuration is provided', () => { + component.item = mockItem; + component.configurations = ['test-config']; + + fixture.detectChanges(); + + const searchPage = fixture.nativeElement.querySelector('ds-configuration-search-page'); + expect(searchPage).toBeTruthy(); + }); + + it('should NOT render configuration search page when configuration is missing', () => { + component.item = mockItem; + component.configurations = []; + + fixture.detectChanges(); + + const searchPage = fixture.nativeElement.querySelector('ds-configuration-search-page'); + expect(searchPage).toBeFalsy(); + }); + +}); diff --git a/src/app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component.ts b/src/app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component.ts new file mode 100644 index 00000000000..9450edb9ba3 --- /dev/null +++ b/src/app/item-page/simple/related-entities/authority-related-entities-search/authority-related-entities-search.component.ts @@ -0,0 +1,52 @@ +import { AsyncPipe } from '@angular/common'; +import { + Component, + Input, + OnInit, +} from '@angular/core'; +import { + NgbNav, + NgbNavContent, + NgbNavItem, + NgbNavLink, + NgbNavOutlet, +} from '@ng-bootstrap/ng-bootstrap'; +import { TranslateModule } from '@ngx-translate/core'; + +import { ThemedConfigurationSearchPageComponent } from '../../../../search-page/themed-configuration-search-page.component'; +import { TabbedRelatedEntitiesSearchComponent } from '../tabbed-related-entities-search/tabbed-related-entities-search.component'; + +@Component({ + selector: 'ds-authority-related-entities-search', + templateUrl: './authority-related-entities-search.component.html', + imports: [ + AsyncPipe, + NgbNav, + NgbNavContent, + NgbNavItem, + NgbNavLink, + NgbNavOutlet, + ThemedConfigurationSearchPageComponent, + TranslateModule, + ], +}) +/** + * A component to show related items as search results, based on authority value + */ +export class AuthorityRelatedEntitiesSearchComponent extends TabbedRelatedEntitiesSearchComponent implements OnInit { + /** + * Filter used for set scope in discovery invocation + */ + searchFilter: string; + /** + * Discovery configurations for search page + */ + @Input() configurations: string[] = []; + + + + ngOnInit() { + super.ngOnInit(); + this.searchFilter = `scope=${this.item.id}`; + } +} diff --git a/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html b/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html index 147650b11aa..901077dbfb1 100644 --- a/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html +++ b/src/app/item-page/simple/related-entities/tabbed-related-entities-search/tabbed-related-entities-search.component.html @@ -1,6 +1,6 @@ @if (relationTypes.length > 1) {