Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ item:
pageSize: 5
# Show the bitstream access status label on the item page
showAccessStatuses: false

# Enable authority based relations in item page
showAuthorithyRelations: false
# Community Page Config
community:
# Default tab to be shown when browsing a Community. Valid values are: comcols, search, or browse_<field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,19 @@
</div>
</div>
<div class="mt-5 w-100 px-0">
<ds-tabbed-related-entities-search [item]="object"
[relationTypes]="[{
@if (areAuthorityRelationsEnabled) {
<ds-authority-related-entities-search
[item]="object"
[configurations]="['RELATION.Person.researchoutputs', 'RELATION.Person.projects']"
></ds-authority-related-entities-search>
} @else {
<ds-tabbed-related-entities-search [item]="object"
[relationTypes]="[{
label: 'isAuthorOfPublication',
filter: 'isAuthorOfPublication',
configuration: 'default-relationships'
}]">
</ds-tabbed-related-entities-search>
</ds-tabbed-related-entities-search>
}
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -22,6 +23,7 @@ import { ThemedThumbnailComponent } from '../../../../thumbnail/themed-thumbnail
templateUrl: './person.component.html',
imports: [
AsyncPipe,
AuthorityRelatedEntitiesSearchComponent,
DsoEditMenuComponent,
GenericItemPageFieldComponent,
MetadataFieldWrapperComponent,
Expand Down
6 changes: 6 additions & 0 deletions src/app/item-page/simple/item-types/shared/item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,16 @@ export class ItemComponent implements OnInit {
*/
geospatialItemPageFieldsEnabled = false;

/**
* Flag to check whether to use the default relations or the authority based ones
*/
areAuthorityRelationsEnabled: boolean;

constructor(protected routeService: RouteService,
protected router: Router) {
this.mediaViewer = environment.mediaViewer;
this.geospatialItemPageFieldsEnabled = environment.geospatialMapViewer.enableItemPageFields;
this.areAuthorityRelationsEnabled = environment.item.showAuthorithyRelations;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
@if (configurations.length > 1) {
<ul ngbNav #tabs="ngbNav"
[destroyOnHide]="true"
[activeId]="activeTab$ | async"
(navChange)="onTabChange($event)"
class="nav-tabs">

@for (config of configurations; track config) {
<li [ngbNavItem]="config">
<a ngbNavLink>
{{('item.page.relationships.' + config) | translate}}
</a>

<ng-template ngbNavContent>
<div class="mt-4">
<ds-configuration-search-page
class="w-100"
[fixedFilterQuery]="searchFilter"
[configuration]="config"
[searchEnabled]="searchEnabled"
[showScopeSelector]="false">
</ds-configuration-search-page>
</div>
</ng-template>
</li>
}
</ul>

<div [ngbNavOutlet]="tabs"></div>
}


@if (configurations.length === 1) {
<ds-configuration-search-page
class="w-100"
[fixedFilterQuery]="searchFilter"
[configuration]="configurations[0]"
[searchEnabled]="searchEnabled"
[showScopeSelector]="false">
</ds-configuration-search-page>
}
Original file line number Diff line number Diff line change
@@ -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<AuthorityRelatedEntitiesSearchComponent>;

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();
});

});
Original file line number Diff line number Diff line change
@@ -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}`;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@if (relationTypes.length > 1) {
<ul ngbNav #tabs="ngbNav" [destroyOnHide]="true" [activeId]="activeTab$ | async" (navChange)="onTabChange($event)" class="nav-tabs" role="tablist">
@for (relationType of relationTypes; track relationType) {
@for (relationType of relationTypes; track relationType.configuration) {
<li [ngbNavItem]="relationType.filter" role="presentation">
<a ngbNavLink role="tab">
{{'item.page.relationships.' + relationType.label | translate}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import {
Router,
} from '@angular/router';
import { Item } from '@dspace/core/shared/item.model';
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
import {
NgbNav,
NgbNavContent,
NgbNavItem,
NgbNavLink,
NgbNavOutlet,
} from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
Expand All @@ -22,7 +28,11 @@ import { RelatedEntitiesSearchComponent } from '../related-entities-search/relat
templateUrl: './tabbed-related-entities-search.component.html',
imports: [
AsyncPipe,
NgbNavModule,
NgbNav,
NgbNavContent,
NgbNavItem,
NgbNavLink,
NgbNavOutlet,
RelatedEntitiesSearchComponent,
TranslateModule,
VarDirective,
Expand Down Expand Up @@ -66,8 +76,8 @@ export class TabbedRelatedEntitiesSearchComponent implements OnInit {
*/
activeTab$: Observable<string>;

constructor(private route: ActivatedRoute,
private router: Router) {
constructor(protected route: ActivatedRoute,
protected router: Router) {
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/app/shared/listable.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import { ItemPageUriFieldComponent } from '../item-page/simple/field-components/
import { PublicationComponent } from '../item-page/simple/item-types/publication/publication.component';
import { UntypedItemComponent } from '../item-page/simple/item-types/untyped-item/untyped-item.component';
import { ThemedMetadataRepresentationListComponent } from '../item-page/simple/metadata-representation-list/themed-metadata-representation-list.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 { ThemedThumbnailComponent } from '../thumbnail/themed-thumbnail.component';
Expand Down Expand Up @@ -243,6 +244,7 @@ const ENTRY_COMPONENTS = [
ItemActionsComponent,
PersonInputSuggestionsComponent,
TabbedRelatedEntitiesSearchComponent,
AuthorityRelatedEntitiesSearchComponent,
WorkspaceItemAdminWorkflowActionsComponent,
WorkflowItemAdminWorkflowActionsComponent,
FormsModule,
Expand Down
8 changes: 8 additions & 0 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -3011,6 +3011,10 @@

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

"item.page.relationships.RELATION.Person.researchoutputs": "Publications",

"item.page.relationships.RELATION.Person.projects": "Projects",

"item.page.subject": "Keywords",

"item.page.uri": "URI",
Expand Down Expand Up @@ -4627,6 +4631,10 @@

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

"RELATION.Person.researchoutputs.search.results.head": "Research Output",

"RELATION.Person.projects.search.results.head": "Projects",

"root.skip-to-content": "Skip to main content",

"search.description": "",
Expand Down
3 changes: 3 additions & 0 deletions src/config/default-app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ export class DefaultAppConfig implements AppConfig {
// Show the bitstream access status label
showAccessStatuses: false,
},
// If true, the search result in item page will display relations based on authority.
// If false,the search result in item page will display default DSpace relations.
showAuthorithyRelations: true,
};

// Community Page Config
Expand Down
2 changes: 2 additions & 0 deletions src/config/item-config.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ export interface ItemConfig extends Config {
// Show the bitstream access status label
showAccessStatuses: boolean;
}

showAuthorithyRelations: boolean;
}
1 change: 1 addition & 0 deletions src/environments/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export const environment: BuildConfig = {
// Show the bitstream access status label
showAccessStatuses: false,
},
showAuthorithyRelations: false,
},
community: {
defaultBrowseTab: 'search',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ThemedResultsBackButtonComponent } from 'src/app/shared/results-back-bu
import { ThemedThumbnailComponent } from 'src/app/thumbnail/themed-thumbnail.component';

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

@listableObjectComponent('Person', ViewMode.StandalonePage, Context.Any, 'custom')
Expand All @@ -25,6 +26,7 @@ import { listableObjectComponent } from '../../../../../../../app/shared/object-
templateUrl: '../../../../../../../app/entity-groups/research-entities/item-pages/person/person.component.html',
imports: [
AsyncPipe,
AuthorityRelatedEntitiesSearchComponent,
DsoEditMenuComponent,
GenericItemPageFieldComponent,
MetadataFieldWrapperComponent,
Expand Down
Loading