Skip to content
Snippets Groups Projects
Commit 4af12c21 authored by Kristof De Langhe's avatar Kristof De Langhe
Browse files

55647: Related publications on person pages

parent 8e3e826a
No related branches found
No related tags found
No related merge requests found
......@@ -28,12 +28,14 @@ import { RelatedEntitiesComponent } from './simple/related-entities/related-enti
import { JournalPageFieldsComponent } from './simple/entity-types/journal/journal-page-fields.component';
import { JournalIssuePageFieldsComponent } from './simple/entity-types/journal-issue/journal-issue-page-fields.component';
import { JournalVolumePageFieldsComponent } from './simple/entity-types/journal-volume/journal-volume-page-fields.component';
import { SearchPageModule } from '../+search-page/search-page.module';
@NgModule({
imports: [
CommonModule,
SharedModule,
ItemPageRoutingModule
ItemPageRoutingModule,
SearchPageModule
],
declarations: [
ItemPageComponent,
......
......@@ -24,10 +24,6 @@
</ds-generic-item-page-field>
</div>
<div class="col-xs-12 col-md-6">
<ds-related-entities
[entities]="publications$ | async"
[label]="'relationships.isPublicationOf' | translate">
</ds-related-entities>
<ds-related-entities
[entities]="projects$ | async"
[label]="'relationships.isProjectOf' | translate">
......@@ -49,4 +45,11 @@
[label]="'person.page.firstname'">
</ds-generic-item-page-field>
</div>
<div class="col-12 border-top pt-2">
<ds-filtered-search-page
[fixedFilterQuery]="fixedFilterQuery"
[fixedFilter$]="fixedFilter$"
[searchEnabled]="false">
</ds-filtered-search-page>
</div>
</div>
......@@ -9,6 +9,7 @@ import {
EntityPageFieldsComponent, filterRelationsByTypeLabel,
relationsToItems
} from '../shared/entity-page-fields.component';
import { SearchFixedFilterService } from '../../../../+search-page/search-filters/search-filter/search-fixed-filter.service';
@rendersEntityType('Person', ElementViewMode.Full)
@Component({
......@@ -20,10 +21,13 @@ export class PersonPageFieldsComponent extends EntityPageFieldsComponent {
publications$: Observable<Item[]>;
projects$: Observable<Item[]>;
orgUnits$: Observable<Item[]>;
fixedFilter$: Observable<string>;
fixedFilterQuery: string;
constructor(
@Inject(ITEM) public item: Item,
private ids: ItemDataService
private ids: ItemDataService,
private fixedFilterService: SearchFixedFilterService
) {
super(item);
}
......@@ -44,5 +48,8 @@ export class PersonPageFieldsComponent extends EntityPageFieldsComponent {
filterRelationsByTypeLabel('isOrgUnitOfPerson'),
relationsToItems(this.item.id, this.ids)
);
this.fixedFilterQuery = this.fixedFilterService.getQueryByRelations('isAuthorOfPublication', this.item.id);
this.fixedFilter$ = Observable.of('publication');
}
}
......@@ -4,10 +4,15 @@ import { SearchFilterService } from './search-filters/search-filter/search-filte
import { SearchService } from './search-service/search.service';
import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
import { SearchPageComponent } from './search-page.component';
import { ChangeDetectionStrategy, Component, Injectable } from '@angular/core';
import { ChangeDetectionStrategy, Component, Injectable, Input } from '@angular/core';
import { pushInOut } from '../shared/animations/push';
import { RouteService } from '../shared/services/route.service';
import { SearchConfigurationService } from './search-service/search-configuration.service';
import { switchMap, tap } from 'rxjs/operators';
import { getSucceededRemoteData } from '../core/shared/operators';
import { Observable } from 'rxjs/Observable';
import { PaginatedSearchOptions } from './paginated-search-options.model';
import { isNotEmpty } from '../shared/empty.util';
/**
* This component renders a simple item page.
......@@ -23,6 +28,12 @@ import { SearchConfigurationService } from './search-service/search-configuratio
export class FilteredSearchPageComponent extends SearchPageComponent {
/**
* The actual query for the fixed filter.
* If empty, the query will be determined by the route parameter called 'filter'
*/
@Input() fixedFilterQuery: string;
constructor(protected service: SearchService,
protected sidebarService: SearchSidebarService,
protected windowService: HostWindowService,
......@@ -32,4 +43,9 @@ export class FilteredSearchPageComponent extends SearchPageComponent {
super(service, sidebarService, windowService, filterService, searchConfigService, routeService);
}
protected getSearchOptions(): Observable<PaginatedSearchOptions> {
this.searchConfigService.updateFixedFilter(this.fixedFilterQuery);
return this.searchConfigService.paginatedSearchOptions;
}
}
......@@ -56,4 +56,8 @@ export class SearchFixedFilterService {
return Observable.of(undefined);
}
getQueryByRelations(relationType: string, itemUUID: string): string {
return `query=relation.${relationType}:${itemUUID}`;
}
}
......@@ -4,13 +4,13 @@
id="search-sidebar"
[resultCount]="(resultsRD$ | async)?.payload.totalElements"></ds-search-sidebar>
<div class="col-12 col-md-9">
<ds-search-form id="search-form"
<ds-search-form *ngIf="searchEnabled" id="search-form"
[query]="(searchOptions$ | async)?.query"
[scope]="(searchOptions$ | async)?.scope"
[currentUrl]="getSearchLink()"
[scopes]="(scopeListRD$ | async)">
</ds-search-form>
<ds-search-labels></ds-search-labels>
<ds-search-labels *ngIf="searchEnabled"></ds-search-labels>
<div class="row">
<div id="search-body"
class="row-offcanvas row-offcanvas-left"
......@@ -32,7 +32,7 @@
</div>
<ds-search-results [searchResults]="resultsRD$ | async"
[searchConfig]="searchOptions$ | async"
[fixedFilter]="fixedFilter | async"></ds-search-results>
[fixedFilter]="fixedFilter$ | async"></ds-search-results>
</div>
</div>
</div>
......
import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, Input, OnInit } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { flatMap, switchMap, } from 'rxjs/operators';
import { PaginatedList } from '../core/data/paginated-list';
......@@ -12,7 +12,7 @@ import { SearchResult } from './search-result.model';
import { SearchService } from './search-service/search.service';
import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
import { Subscription } from 'rxjs/Subscription';
import { hasValue } from '../shared/empty.util';
import { hasValue, isNotEmpty } from '../shared/empty.util';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { SearchConfigurationService } from './search-service/search-configuration.service';
import { getSucceededRemoteData } from '../core/shared/operators';
......@@ -62,7 +62,17 @@ export class SearchPageComponent implements OnInit {
*/
sub: Subscription;
fixedFilter;
/**
* Whether or not the search bar should be visible
*/
@Input()
searchEnabled = true;
/**
* The currently applied filter (determines title of search)
*/
@Input()
fixedFilter$: Observable<string>;
constructor(protected service: SearchService,
protected sidebarService: SearchSidebarService,
......@@ -81,7 +91,7 @@ export class SearchPageComponent implements OnInit {
* If something changes, update the list of scopes for the dropdown
*/
ngOnInit(): void {
this.searchOptions$ = this.searchConfigService.paginatedSearchOptions;
this.searchOptions$ = this.getSearchOptions();
this.sub = this.searchOptions$
.switchMap((options) => this.service.search(options).pipe(getSucceededRemoteData()))
.subscribe((results) => {
......@@ -90,7 +100,13 @@ export class SearchPageComponent implements OnInit {
this.scopeListRD$ = this.searchConfigService.getCurrentScope('').pipe(
switchMap((scopeId) => this.service.getScopes(scopeId))
);
this.fixedFilter = this.routeService.getRouteParameterValue('filter');
if (!isNotEmpty(this.fixedFilter$)) {
this.fixedFilter$ = this.routeService.getRouteParameterValue('filter');
}
}
protected getSearchOptions(): Observable<PaginatedSearchOptions> {
return this.searchConfigService.paginatedSearchOptions;
}
/**
......
......@@ -89,6 +89,9 @@ const effects = [
SearchTextFilterComponent,
SearchHierarchyFilterComponent,
SearchBooleanFilterComponent,
],
exports: [
FilteredSearchPageComponent
]
})
......
......@@ -6,7 +6,7 @@ import { ActivatedRoute, Params } from '@angular/router';
import { PaginatedSearchOptions } from '../paginated-search-options.model';
import { Injectable, OnDestroy } from '@angular/core';
import { RouteService } from '../../shared/services/route.service';
import { hasNoValue, hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
import { hasNoValue, hasValue, isEmpty, isNotEmpty, isNotEmptyOperator } from '../../shared/empty.util';
import { RemoteData } from '../../core/data/remote-data';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Subscription } from 'rxjs/Subscription';
......@@ -14,6 +14,7 @@ import { getSucceededRemoteData } from '../../core/shared/operators';
import { SearchFilter } from '../search-filter.model';
import { DSpaceObjectType } from '../../core/shared/dspace-object-type.model';
import { SearchFixedFilterService } from '../search-filters/search-filter/search-fixed-filter.service';
import { map } from 'rxjs/operators';
/**
* Service that performs all actions that have to do with the current search configuration
......@@ -306,8 +307,21 @@ export class SearchConfigurationService implements OnDestroy {
* @returns {Observable<string>} Emits the current fixed filter as a partial SearchOptions object
*/
private getFixedFilterPart(): Observable<any> {
return this.getCurrentFixedFilter().map((fixedFilter) => {
return { fixedFilter }
});
return this.getCurrentFixedFilter().pipe(
isNotEmptyOperator(),
map((fixedFilter) => {
return { fixedFilter }
})
);
}
public updateFixedFilter(fixedFilter: string) {
const currentPaginatedValue: PaginatedSearchOptions = this.paginatedSearchOptions.getValue();
const updatedPaginatedValue: PaginatedSearchOptions = Object.assign(currentPaginatedValue, { fixedFilter: fixedFilter });
this.paginatedSearchOptions.next(updatedPaginatedValue);
const currentValue: SearchOptions = this.searchOptions.getValue();
const updatedValue: SearchOptions = Object.assign(currentValue, { fixedFilter: fixedFilter });
this.searchOptions.next(updatedValue);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment