mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Merge remote-tracking branch 'alex/fix-scope-issues-on-search-form_contribute-7.6' into added-recently-added-section-to-community-page_contribute-7.6
This commit is contained in:
@@ -27,6 +27,7 @@ const filterStateSelector = (state: SearchFiltersState) => state.searchFilter;
|
||||
export const FILTER_CONFIG: InjectionToken<SearchFilterConfig> = new InjectionToken<SearchFilterConfig>('filterConfig');
|
||||
export const IN_PLACE_SEARCH: InjectionToken<boolean> = new InjectionToken<boolean>('inPlaceSearch');
|
||||
export const REFRESH_FILTER: InjectionToken<BehaviorSubject<any>> = new InjectionToken<boolean>('refreshFilters');
|
||||
export const SCOPE: InjectionToken<string> = new InjectionToken<string>('scope');
|
||||
|
||||
/**
|
||||
* Service that performs all actions that have to do with search filters and facets
|
||||
|
@@ -4,6 +4,7 @@ import { FilterType } from '../../../models/filter-type.model';
|
||||
import { SearchFilterConfig } from '../../../models/search-filter-config.model';
|
||||
import {
|
||||
FILTER_CONFIG,
|
||||
SCOPE,
|
||||
IN_PLACE_SEARCH,
|
||||
REFRESH_FILTER
|
||||
} from '../../../../../core/shared/search/search-filter.service';
|
||||
@@ -35,6 +36,11 @@ export class SearchFacetFilterWrapperComponent implements OnInit {
|
||||
*/
|
||||
@Input() refreshFilters: BehaviorSubject<boolean>;
|
||||
|
||||
/**
|
||||
* The current scope
|
||||
*/
|
||||
@Input() scope: string;
|
||||
|
||||
/**
|
||||
* The constructor of the search facet filter that should be rendered, based on the filter config's type
|
||||
*/
|
||||
@@ -56,7 +62,8 @@ export class SearchFacetFilterWrapperComponent implements OnInit {
|
||||
providers: [
|
||||
{ provide: FILTER_CONFIG, useFactory: () => (this.filterConfig), deps: [] },
|
||||
{ provide: IN_PLACE_SEARCH, useFactory: () => (this.inPlaceSearch), deps: [] },
|
||||
{ provide: REFRESH_FILTER, useFactory: () => (this.refreshFilters), deps: [] }
|
||||
{ provide: REFRESH_FILTER, useFactory: () => (this.refreshFilters), deps: [] },
|
||||
{ provide: SCOPE, useFactory: () => (this.scope), deps: [] },
|
||||
],
|
||||
parent: this.injector
|
||||
});
|
||||
|
@@ -4,6 +4,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import {
|
||||
FILTER_CONFIG,
|
||||
SCOPE,
|
||||
IN_PLACE_SEARCH,
|
||||
REFRESH_FILTER,
|
||||
SearchFilterService
|
||||
@@ -99,6 +100,7 @@ describe('SearchFacetFilterComponent', () => {
|
||||
{ provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() },
|
||||
{ provide: IN_PLACE_SEARCH, useValue: false },
|
||||
{ provide: REFRESH_FILTER, useValue: new BehaviorSubject<boolean>(false) },
|
||||
{ provide: SCOPE, useValue: undefined },
|
||||
{
|
||||
provide: SearchFilterService, useValue: {
|
||||
getSelectedValuesForFilter: () => observableOf(selectedValues),
|
||||
|
@@ -22,6 +22,7 @@ import { SearchFilterConfig } from '../../../models/search-filter-config.model';
|
||||
import { SearchService } from '../../../../../core/shared/search/search.service';
|
||||
import {
|
||||
FILTER_CONFIG,
|
||||
SCOPE,
|
||||
IN_PLACE_SEARCH,
|
||||
REFRESH_FILTER,
|
||||
SearchFilterService
|
||||
@@ -104,7 +105,9 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
||||
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
|
||||
@Inject(IN_PLACE_SEARCH) public inPlaceSearch: boolean,
|
||||
@Inject(FILTER_CONFIG) public filterConfig: SearchFilterConfig,
|
||||
@Inject(REFRESH_FILTER) public refreshFilters: BehaviorSubject<boolean>) {
|
||||
@Inject(REFRESH_FILTER) public refreshFilters: BehaviorSubject<boolean>,
|
||||
@Inject(SCOPE) public scope: string,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,8 +117,11 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
||||
this.currentUrl = this.router.url;
|
||||
this.filterValues$ = new BehaviorSubject(createPendingRemoteDataObject());
|
||||
this.currentPage = this.getCurrentPage().pipe(distinctUntilChanged());
|
||||
|
||||
this.searchOptions$ = this.searchConfigService.searchOptions;
|
||||
this.searchOptions$ = this.searchConfigService.searchOptions.pipe(
|
||||
map((options: SearchOptions) => hasNoValue(this.scope) ? options : Object.assign({}, options, {
|
||||
scope: this.scope,
|
||||
})),
|
||||
);
|
||||
this.subs.push(
|
||||
this.searchOptions$.subscribe(() => this.updateFilterValueList()),
|
||||
this.refreshFilters.asObservable().pipe(
|
||||
|
@@ -18,6 +18,7 @@
|
||||
(@slide.start)="startSlide($event)" (@slide.done)="finishSlide($event)"
|
||||
class="search-filter-wrapper" [ngClass]="{ 'closed' : closed, 'notab': notab }">
|
||||
<ds-search-facet-filter-wrapper
|
||||
[scope]="scope"
|
||||
[filterConfig]="filter"
|
||||
[inPlaceSearch]="inPlaceSearch"
|
||||
[refreshFilters]="refreshFilters" >
|
||||
|
@@ -6,7 +6,7 @@ import { filter, map, startWith, switchMap, take } from 'rxjs/operators';
|
||||
import { SearchFilterConfig } from '../../models/search-filter-config.model';
|
||||
import { SearchFilterService } from '../../../../core/shared/search/search-filter.service';
|
||||
import { slide } from '../../../animations/slide';
|
||||
import { isNotEmpty } from '../../../empty.util';
|
||||
import { isNotEmpty, hasValue } from '../../../empty.util';
|
||||
import { SearchService } from '../../../../core/shared/search/search.service';
|
||||
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
||||
import { SEARCH_CONFIG_SERVICE } from '../../../../my-dspace-page/my-dspace-page.component';
|
||||
@@ -38,6 +38,11 @@ export class SearchFilterComponent implements OnInit {
|
||||
*/
|
||||
@Input() refreshFilters: BehaviorSubject<boolean>;
|
||||
|
||||
/**
|
||||
* The current scope
|
||||
*/
|
||||
@Input() scope: string;
|
||||
|
||||
/**
|
||||
* True when the filter is 100% collapsed in the UI
|
||||
*/
|
||||
@@ -171,6 +176,9 @@ export class SearchFilterComponent implements OnInit {
|
||||
} else {
|
||||
return this.searchConfigService.searchOptions.pipe(
|
||||
switchMap((options) => {
|
||||
if (hasValue(this.scope)) {
|
||||
options.scope = this.scope;
|
||||
}
|
||||
return this.searchService.getFacetValuesFor(this.filter, 1, options).pipe(
|
||||
filter((RD) => !RD.isLoading),
|
||||
map((valuesRD) => {
|
||||
|
@@ -14,6 +14,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { SearchService } from '../../../../../core/shared/search/search.service';
|
||||
import {
|
||||
FILTER_CONFIG,
|
||||
SCOPE,
|
||||
IN_PLACE_SEARCH,
|
||||
SearchFilterService,
|
||||
REFRESH_FILTER
|
||||
@@ -75,7 +76,8 @@ describe('SearchHierarchyFilterComponent', () => {
|
||||
{ provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() },
|
||||
{ provide: IN_PLACE_SEARCH, useValue: false },
|
||||
{ provide: FILTER_CONFIG, useValue: Object.assign(new SearchFilterConfig(), { name: testSearchFilter }) },
|
||||
{ provide: REFRESH_FILTER, useValue: new BehaviorSubject<boolean>(false)}
|
||||
{ provide: REFRESH_FILTER, useValue: new BehaviorSubject<boolean>(false)},
|
||||
{ provide: SCOPE, useValue: undefined },
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
}).compileComponents();
|
||||
|
@@ -9,6 +9,7 @@ import {
|
||||
import { SearchService } from '../../../../../core/shared/search/search.service';
|
||||
import {
|
||||
FILTER_CONFIG,
|
||||
SCOPE,
|
||||
IN_PLACE_SEARCH,
|
||||
SearchFilterService, REFRESH_FILTER
|
||||
} from '../../../../../core/shared/search/search-filter.service';
|
||||
@@ -49,9 +50,10 @@ export class SearchHierarchyFilterComponent extends SearchFacetFilterComponent i
|
||||
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
|
||||
@Inject(IN_PLACE_SEARCH) public inPlaceSearch: boolean,
|
||||
@Inject(FILTER_CONFIG) public filterConfig: SearchFilterConfig,
|
||||
@Inject(REFRESH_FILTER) public refreshFilters: BehaviorSubject<boolean>
|
||||
@Inject(REFRESH_FILTER) public refreshFilters: BehaviorSubject<boolean>,
|
||||
@Inject(SCOPE) public scope: string,
|
||||
) {
|
||||
super(searchService, filterService, rdbs, router, searchConfigService, inPlaceSearch, filterConfig, refreshFilters);
|
||||
super(searchService, filterService, rdbs, router, searchConfigService, inPlaceSearch, filterConfig, refreshFilters, scope);
|
||||
}
|
||||
|
||||
vocabularyExists$: Observable<boolean>;
|
||||
|
@@ -4,6 +4,7 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import {
|
||||
FILTER_CONFIG,
|
||||
SCOPE,
|
||||
IN_PLACE_SEARCH,
|
||||
REFRESH_FILTER,
|
||||
SearchFilterService
|
||||
@@ -105,6 +106,7 @@ describe('SearchRangeFilterComponent', () => {
|
||||
{ provide: SEARCH_CONFIG_SERVICE, useValue: new SearchConfigurationServiceStub() },
|
||||
{ provide: IN_PLACE_SEARCH, useValue: false },
|
||||
{ provide: REFRESH_FILTER, useValue: new BehaviorSubject<boolean>(false) },
|
||||
{ provide: SCOPE, useValue: undefined },
|
||||
{
|
||||
provide: SearchFilterService, useValue: {
|
||||
getSelectedValuesForFilter: () => selectedValues,
|
||||
|
@@ -9,6 +9,7 @@ import { facetLoad, SearchFacetFilterComponent } from '../search-facet-filter/se
|
||||
import { SearchFilterConfig } from '../../../models/search-filter-config.model';
|
||||
import {
|
||||
FILTER_CONFIG,
|
||||
SCOPE,
|
||||
IN_PLACE_SEARCH,
|
||||
REFRESH_FILTER,
|
||||
SearchFilterService
|
||||
@@ -83,8 +84,9 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple
|
||||
@Inject(FILTER_CONFIG) public filterConfig: SearchFilterConfig,
|
||||
@Inject(PLATFORM_ID) private platformId: any,
|
||||
@Inject(REFRESH_FILTER) public refreshFilters: BehaviorSubject<boolean>,
|
||||
@Inject(SCOPE) public scope: string,
|
||||
private route: RouteService) {
|
||||
super(searchService, filterService, rdbs, router, searchConfigService, inPlaceSearch, filterConfig, refreshFilters);
|
||||
super(searchService, filterService, rdbs, router, searchConfigService, inPlaceSearch, filterConfig, refreshFilters, scope);
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<h3>{{"search.filters.head" | translate}}</h3>
|
||||
<div *ngIf="(filters | async)?.hasSucceeded">
|
||||
<div *ngFor="let filter of (filters | async)?.payload; trackBy: trackUpdate">
|
||||
<ds-search-filter [filter]="filter" [inPlaceSearch]="inPlaceSearch" [refreshFilters]="refreshFilters"></ds-search-filter>
|
||||
<ds-search-filter [scope]="currentScope" [filter]="filter" [inPlaceSearch]="inPlaceSearch" [refreshFilters]="refreshFilters"></ds-search-filter>
|
||||
</div>
|
||||
</div>
|
||||
<a class="btn btn-primary" [routerLink]="[searchLink]" [queryParams]="clearParams | async" queryParamsHandling="merge" role="button"><i class="fas fa-undo"></i> {{"search.filters.reset" | translate}}</a>
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import { SearchService } from '../../../core/shared/search/search.service';
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { SearchSettingsComponent } from './search-settings.component';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
@@ -6,15 +5,11 @@ import { PaginationComponentOptions } from '../../pagination/pagination-componen
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { RouterTestingModule } from '@angular/router/testing';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { EnumKeysPipe } from '../../utils/enum-keys-pipe';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { SearchFilterService } from '../../../core/shared/search/search-filter.service';
|
||||
import { VarDirective } from '../../utils/var.directive';
|
||||
import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-page.component';
|
||||
import { SidebarService } from '../../sidebar/sidebar.service';
|
||||
import { SidebarServiceStub } from '../../testing/sidebar-service.stub';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../testing/pagination-service.stub';
|
||||
|
||||
@@ -22,32 +17,23 @@ describe('SearchSettingsComponent', () => {
|
||||
|
||||
let comp: SearchSettingsComponent;
|
||||
let fixture: ComponentFixture<SearchSettingsComponent>;
|
||||
let searchServiceObject: SearchService;
|
||||
|
||||
let pagination: PaginationComponentOptions;
|
||||
let sort: SortOptions;
|
||||
let mockResults;
|
||||
let searchServiceStub;
|
||||
|
||||
let queryParam;
|
||||
let scopeParam;
|
||||
let paginatedSearchOptions;
|
||||
|
||||
let paginationService;
|
||||
let paginationService: PaginationServiceStub;
|
||||
|
||||
let activatedRouteStub;
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
beforeEach(waitForAsync(async () => {
|
||||
pagination = new PaginationComponentOptions();
|
||||
pagination.id = 'search-results-pagination';
|
||||
pagination.currentPage = 1;
|
||||
pagination.pageSize = 10;
|
||||
sort = new SortOptions('score', SortDirection.DESC);
|
||||
mockResults = ['test', 'data'];
|
||||
searchServiceStub = {
|
||||
searchOptions: { pagination: pagination, sort: sort },
|
||||
search: () => mockResults,
|
||||
};
|
||||
|
||||
queryParam = 'test query';
|
||||
scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f';
|
||||
@@ -58,30 +44,12 @@ describe('SearchSettingsComponent', () => {
|
||||
sort,
|
||||
};
|
||||
|
||||
activatedRouteStub = {
|
||||
queryParams: observableOf({
|
||||
query: queryParam,
|
||||
scope: scopeParam,
|
||||
}),
|
||||
};
|
||||
|
||||
paginationService = new PaginationServiceStub(pagination, sort);
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])],
|
||||
declarations: [SearchSettingsComponent, EnumKeysPipe, VarDirective],
|
||||
providers: [
|
||||
{ provide: SearchService, useValue: searchServiceStub },
|
||||
|
||||
{ provide: ActivatedRoute, useValue: activatedRouteStub },
|
||||
{
|
||||
provide: SidebarService,
|
||||
useValue: SidebarServiceStub,
|
||||
},
|
||||
{
|
||||
provide: SearchFilterService,
|
||||
useValue: {},
|
||||
},
|
||||
{
|
||||
provide: PaginationService,
|
||||
useValue: paginationService,
|
||||
@@ -111,10 +79,7 @@ describe('SearchSettingsComponent', () => {
|
||||
|
||||
// SearchPageComponent test instance
|
||||
fixture.detectChanges();
|
||||
searchServiceObject = (comp as any).service;
|
||||
spyOn(comp, 'reloadOrder');
|
||||
spyOn(searchServiceObject, 'search').and.callThrough();
|
||||
|
||||
});
|
||||
|
||||
it('it should show the order settings with the respective selectable options', () => {
|
||||
|
@@ -1,7 +1,5 @@
|
||||
import { Component, Inject, Input } from '@angular/core';
|
||||
import { SearchService } from '../../../core/shared/search/search.service';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { SearchConfigurationService } from '../../../core/shared/search/search-configuration.service';
|
||||
import { SEARCH_CONFIG_SERVICE } from '../../../my-dspace-page/my-dspace-page.component';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
@@ -26,11 +24,10 @@ export class SearchSettingsComponent {
|
||||
*/
|
||||
@Input() sortOptionsList: SortOptions[];
|
||||
|
||||
constructor(private service: SearchService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private paginationService: PaginationService,
|
||||
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigurationService: SearchConfigurationService) {
|
||||
constructor(
|
||||
protected paginationService: PaginationService,
|
||||
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigurationService: SearchConfigurationService,
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -36,8 +36,6 @@ import { getCollectionPageRoute } from '../../collection-page/collection-page-ro
|
||||
|
||||
let comp: SearchComponent;
|
||||
let fixture: ComponentFixture<SearchComponent>;
|
||||
let searchServiceObject: SearchService;
|
||||
let searchConfigurationServiceObject: SearchConfigurationService;
|
||||
const store: Store<SearchComponent> = jasmine.createSpyObj('store', {
|
||||
/* eslint-disable no-empty,@typescript-eslint/no-empty-function */
|
||||
dispatch: {},
|
||||
@@ -93,7 +91,6 @@ const mockDso2 = Object.assign(new Item(), {
|
||||
}
|
||||
}
|
||||
});
|
||||
const sort: SortOptions = new SortOptions('score', SortDirection.DESC);
|
||||
const mockSearchResults: SearchObjects<DSpaceObject> = Object.assign(new SearchObjects(), {
|
||||
page: [mockDso, mockDso2]
|
||||
});
|
||||
@@ -106,23 +103,13 @@ const searchServiceStub = jasmine.createSpyObj('SearchService', {
|
||||
getSearchConfigurationFor: createSuccessfulRemoteDataObject$(searchConfig),
|
||||
trackSearch: {},
|
||||
}) as SearchService;
|
||||
const configurationParam = 'default';
|
||||
const queryParam = 'test query';
|
||||
const scopeParam = '7669c72a-3f2a-451f-a3b9-9210e7a4c02f';
|
||||
const fixedFilter = 'fixed filter';
|
||||
|
||||
const defaultSearchOptions = new PaginatedSearchOptions({ pagination });
|
||||
|
||||
const paginatedSearchOptions$ = new BehaviorSubject(defaultSearchOptions);
|
||||
|
||||
const paginatedSearchOptions = new PaginatedSearchOptions({
|
||||
configuration: configurationParam,
|
||||
query: queryParam,
|
||||
scope: scopeParam,
|
||||
fixedFilter: fixedFilter,
|
||||
pagination,
|
||||
sort
|
||||
});
|
||||
const activatedRouteStub = {
|
||||
snapshot: {
|
||||
queryParamMap: new Map([
|
||||
@@ -155,14 +142,11 @@ const filtersConfigRD = createSuccessfulRemoteDataObject([mockFilterConfig, mock
|
||||
const filtersConfigRD$ = observableOf(filtersConfigRD);
|
||||
|
||||
const routeServiceStub = {
|
||||
getRouteParameterValue: () => {
|
||||
return observableOf('');
|
||||
},
|
||||
getQueryParameterValue: () => {
|
||||
return observableOf('');
|
||||
return observableOf(null);
|
||||
},
|
||||
getQueryParamsWithPrefix: () => {
|
||||
return observableOf('');
|
||||
return observableOf(null);
|
||||
},
|
||||
setParameter: () => {
|
||||
return;
|
||||
@@ -252,16 +236,10 @@ describe('SearchComponent', () => {
|
||||
comp.paginationId = paginationId;
|
||||
|
||||
spyOn((comp as any), 'getSearchOptions').and.returnValue(paginatedSearchOptions$.asObservable());
|
||||
|
||||
searchServiceObject = TestBed.inject(SearchService);
|
||||
searchConfigurationServiceObject = TestBed.inject(SEARCH_CONFIG_SERVICE);
|
||||
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
comp = null;
|
||||
searchServiceObject = null;
|
||||
searchConfigurationServiceObject = null;
|
||||
});
|
||||
|
||||
it('should init search parameters properly and call retrieveSearchResults', fakeAsync(() => {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Inject, Input, OnInit, Output } from '@angular/core';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Inject, Input, OnInit, Output, OnDestroy } from '@angular/core';
|
||||
import { NavigationStart, Router } from '@angular/router';
|
||||
|
||||
import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs';
|
||||
@@ -11,7 +11,7 @@ import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
import { pushInOut } from '../animations/push';
|
||||
import { HostWindowService } from '../host-window.service';
|
||||
import { SidebarService } from '../sidebar/sidebar.service';
|
||||
import { hasValue, hasValueOperator, isNotEmpty } from '../empty.util';
|
||||
import { hasValue, hasValueOperator, isEmpty, isNotEmpty } from '../empty.util';
|
||||
import { RouteService } from '../../core/services/route.service';
|
||||
import { SEARCH_CONFIG_SERVICE } from '../../my-dspace-page/my-dspace-page.component';
|
||||
import { PaginatedSearchOptions } from './models/paginated-search-options.model';
|
||||
@@ -34,7 +34,7 @@ import { CollectionElementLinkType } from '../object-collection/collection-eleme
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { SubmissionObject } from '../../core/submission/models/submission-object.model';
|
||||
import { SearchFilterConfig } from './models/search-filter-config.model';
|
||||
import { WorkspaceItem } from '../..//core/submission/models/workspaceitem.model';
|
||||
import { WorkspaceItem } from '../../core/submission/models/workspaceitem.model';
|
||||
import { ITEM_MODULE_PATH } from '../../item-page/item-page-routing-paths';
|
||||
import { COLLECTION_MODULE_PATH } from '../../collection-page/collection-page-routing-paths';
|
||||
import { COMMUNITY_MODULE_PATH } from '../../community-page/community-page-routing-paths';
|
||||
@@ -50,7 +50,7 @@ import { COMMUNITY_MODULE_PATH } from '../../community-page/community-page-routi
|
||||
/**
|
||||
* This component renders a sidebar, a search input bar and the search results.
|
||||
*/
|
||||
export class SearchComponent implements OnInit {
|
||||
export class SearchComponent implements OnDestroy, OnInit {
|
||||
|
||||
/**
|
||||
* The list of available configuration options
|
||||
@@ -166,6 +166,11 @@ export class SearchComponent implements OnInit {
|
||||
*/
|
||||
@Input() query: string;
|
||||
|
||||
/**
|
||||
* The fallback scope when no scope is defined in the url, if this is also undefined no scope will be set
|
||||
*/
|
||||
@Input() scope: string;
|
||||
|
||||
/**
|
||||
* The current configuration used during the search
|
||||
*/
|
||||
@@ -179,7 +184,7 @@ export class SearchComponent implements OnInit {
|
||||
/**
|
||||
* The current sort options used
|
||||
*/
|
||||
currentScope$: BehaviorSubject<string> = new BehaviorSubject<string>('');
|
||||
currentScope$: Observable<string>;
|
||||
|
||||
/**
|
||||
* The current sort options used
|
||||
@@ -299,6 +304,10 @@ export class SearchComponent implements OnInit {
|
||||
this.routeService.setParameter('fixedFilterQuery', this.fixedFilterQuery);
|
||||
}
|
||||
|
||||
this.currentScope$ = this.routeService.getQueryParameterValue('scope').pipe(
|
||||
map((routeValue: string) => hasValue(routeValue) ? routeValue : this.scope),
|
||||
);
|
||||
|
||||
this.isSidebarCollapsed$ = this.isSidebarCollapsed();
|
||||
this.searchLink = this.getSearchLink();
|
||||
this.currentContext$.next(this.context);
|
||||
@@ -306,9 +315,8 @@ export class SearchComponent implements OnInit {
|
||||
// Determinate PaginatedSearchOptions and listen to any update on it
|
||||
const configuration$: Observable<string> = this.searchConfigService
|
||||
.getCurrentConfiguration(this.configuration).pipe(distinctUntilChanged());
|
||||
const searchSortOptions$: Observable<SortOptions[]> = configuration$.pipe(
|
||||
switchMap((configuration: string) => this.searchConfigService
|
||||
.getConfigurationSearchConfig(configuration)),
|
||||
const searchSortOptions$: Observable<SortOptions[]> = combineLatest([configuration$, this.currentScope$]).pipe(
|
||||
switchMap(([configuration, scope]: [string, string]) => this.searchConfigService.getConfigurationSearchConfig(configuration, scope)),
|
||||
map((searchConfig: SearchConfig) => this.searchConfigService.getConfigurationSortOptions(searchConfig)),
|
||||
distinctUntilChanged()
|
||||
);
|
||||
@@ -321,13 +329,13 @@ export class SearchComponent implements OnInit {
|
||||
);
|
||||
const searchOptions$: Observable<PaginatedSearchOptions> = this.getSearchOptions().pipe(distinctUntilChanged());
|
||||
|
||||
this.subs.push(combineLatest([configuration$, searchSortOptions$, searchOptions$, sortOption$]).pipe(
|
||||
filter(([configuration, searchSortOptions, searchOptions, sortOption]: [string, SortOptions[], PaginatedSearchOptions, SortOptions]) => {
|
||||
this.subs.push(combineLatest([configuration$, searchSortOptions$, searchOptions$, sortOption$, this.currentScope$]).pipe(
|
||||
filter(([configuration, searchSortOptions, searchOptions, sortOption, scope]: [string, SortOptions[], PaginatedSearchOptions, SortOptions, string]) => {
|
||||
// filter for search options related to instanced paginated id
|
||||
return searchOptions.pagination.id === this.paginationId;
|
||||
}),
|
||||
debounceTime(100)
|
||||
).subscribe(([configuration, searchSortOptions, searchOptions, sortOption]: [string, SortOptions[], PaginatedSearchOptions, SortOptions]) => {
|
||||
).subscribe(([configuration, searchSortOptions, searchOptions, sortOption, scope]: [string, SortOptions[], PaginatedSearchOptions, SortOptions, string]) => {
|
||||
// Build the PaginatedSearchOptions object
|
||||
const combinedOptions = Object.assign({}, searchOptions,
|
||||
{
|
||||
@@ -337,6 +345,9 @@ export class SearchComponent implements OnInit {
|
||||
if (combinedOptions.query === '') {
|
||||
combinedOptions.query = this.query;
|
||||
}
|
||||
if (isEmpty(combinedOptions.scope)) {
|
||||
combinedOptions.scope = scope;
|
||||
}
|
||||
const newSearchOptions = new PaginatedSearchOptions(combinedOptions);
|
||||
// check if search options are changed
|
||||
// if so retrieve new related results otherwise skip it
|
||||
@@ -344,13 +355,12 @@ export class SearchComponent implements OnInit {
|
||||
// Initialize variables
|
||||
this.currentConfiguration$.next(configuration);
|
||||
this.currentSortOptions$.next(newSearchOptions.sort);
|
||||
this.currentScope$.next(newSearchOptions.scope);
|
||||
this.sortOptionsList$.next(searchSortOptions);
|
||||
this.searchOptions$.next(newSearchOptions);
|
||||
this.initialized$.next(true);
|
||||
// retrieve results
|
||||
this.retrieveSearchResults(newSearchOptions);
|
||||
this.retrieveFilters(searchOptions);
|
||||
this.retrieveFilters(newSearchOptions);
|
||||
}
|
||||
}));
|
||||
|
||||
|
@@ -15,11 +15,37 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ds-themed-search',
|
||||
styleUrls: [],
|
||||
templateUrl: '../theme-support/themed.component.html',
|
||||
})
|
||||
export class ThemedSearchComponent extends ThemedComponent<SearchComponent> {
|
||||
protected inAndOutputNames: (keyof SearchComponent & keyof this)[] = ['configurationList', 'context', 'configuration', 'fixedFilterQuery', 'useCachedVersionIfAvailable', 'inPlaceSearch', 'linkType', 'paginationId', 'searchEnabled', 'sideBarWidth', 'searchFormPlaceholder', 'selectable', 'selectionConfig', 'showCsvExport', 'showSidebar', 'showThumbnails', 'showViewModes', 'useUniquePageId', 'viewModeList', 'showScopeSelector', 'resultFound', 'deselectObject', 'selectObject', 'trackStatistics', 'query'];
|
||||
protected inAndOutputNames: (keyof SearchComponent & keyof this)[] = [
|
||||
'configurationList',
|
||||
'context',
|
||||
'configuration',
|
||||
'fixedFilterQuery',
|
||||
'useCachedVersionIfAvailable',
|
||||
'inPlaceSearch',
|
||||
'linkType',
|
||||
'paginationId',
|
||||
'searchEnabled',
|
||||
'sideBarWidth',
|
||||
'searchFormPlaceholder',
|
||||
'selectable',
|
||||
'selectionConfig',
|
||||
'showCsvExport',
|
||||
'showSidebar',
|
||||
'showThumbnails',
|
||||
'showViewModes',
|
||||
'useUniquePageId',
|
||||
'viewModeList',
|
||||
'showScopeSelector',
|
||||
'trackStatistics',
|
||||
'query',
|
||||
'scope',
|
||||
'resultFound',
|
||||
'deselectObject',
|
||||
'selectObject',
|
||||
];
|
||||
|
||||
@Input() configurationList: SearchConfigurationOption[];
|
||||
|
||||
@@ -51,7 +77,7 @@ export class ThemedSearchComponent extends ThemedComponent<SearchComponent> {
|
||||
|
||||
@Input() showSidebar: boolean;
|
||||
|
||||
@Input() showThumbnails;
|
||||
@Input() showThumbnails: boolean;
|
||||
|
||||
@Input() showViewModes: boolean;
|
||||
|
||||
@@ -65,6 +91,8 @@ export class ThemedSearchComponent extends ThemedComponent<SearchComponent> {
|
||||
|
||||
@Input() query: string;
|
||||
|
||||
@Input() scope: string;
|
||||
|
||||
@Output() resultFound: EventEmitter<SearchObjects<DSpaceObject>> = new EventEmitter();
|
||||
|
||||
@Output() deselectObject: EventEmitter<ListableObject> = new EventEmitter();
|
||||
|
@@ -3890,6 +3890,18 @@
|
||||
|
||||
"sorting.lastModified.DESC": "Last modified Descending",
|
||||
|
||||
"sorting.person.familyName.ASC": "Surname Ascending",
|
||||
|
||||
"sorting.person.familyName.DESC": "Surname Descending",
|
||||
|
||||
"sorting.person.givenName.ASC": "Name Ascending",
|
||||
|
||||
"sorting.person.givenName.DESC": "Name Descending",
|
||||
|
||||
"sorting.person.birthDate.ASC": "Birth Date Ascending",
|
||||
|
||||
"sorting.person.birthDate.DESC": "Birth Date Descending",
|
||||
|
||||
"statistics.title": "Statistics",
|
||||
|
||||
"statistics.header": "Statistics for {{ scope }}",
|
||||
|
Reference in New Issue
Block a user