-
+
-
{{"search.filters.reset" | translate}}
\ No newline at end of file
+
{{"search.filters.reset" | translate}}
diff --git a/src/app/+search-page/search-filters/search-filters.component.ts b/src/app/+search-page/search-filters/search-filters.component.ts
index f16faff1f3..d6116843be 100644
--- a/src/app/+search-page/search-filters/search-filters.component.ts
+++ b/src/app/+search-page/search-filters/search-filters.component.ts
@@ -1,14 +1,17 @@
-import { Observable, of as observableOf } from 'rxjs';
+import { ChangeDetectorRef, Component, Inject, OnDestroy, OnInit } from '@angular/core';
+
+import { BehaviorSubject, Observable, of as observableOf, Subscription } from 'rxjs';
+import { filter, first, map, mergeMap, startWith, switchMap, tap } from 'rxjs/operators';
-import { filter, map, mergeMap, startWith, switchMap } from 'rxjs/operators';
-import { Component } from '@angular/core';
import { SearchService } from '../search-service/search.service';
import { RemoteData } from '../../core/data/remote-data';
import { SearchFilterConfig } from '../search-service/search-filter-config.model';
import { SearchConfigurationService } from '../search-service/search-configuration.service';
-import { isNotEmpty } from '../../shared/empty.util';
+import { hasValue, isNotEmpty } from '../../shared/empty.util';
import { SearchFilterService } from './search-filter/search-filter.service';
import { getSucceededRemoteData } from '../../core/shared/operators';
+import { PaginatedSearchOptions } from '../paginated-search-options.model';
+import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component';
@Component({
selector: 'ds-search-filters',
@@ -19,11 +22,12 @@ import { getSucceededRemoteData } from '../../core/shared/operators';
/**
* This component represents the part of the search sidebar that contains filters.
*/
-export class SearchFiltersComponent {
+export class SearchFiltersComponent implements OnDestroy, OnInit {
+
/**
- * An observable containing configuration about which filters are shown and how they are shown
+ * An Array containing configuration about which filters are shown and how they are shown
*/
- filters: Observable
>;
+ filters: SearchFilterConfig[] = [];
/**
* List of all filters that are currently active with their value set to null.
@@ -31,15 +35,44 @@ export class SearchFiltersComponent {
*/
clearParams;
+ /**
+ * A boolean representing load state of filters configuration
+ */
+ isLoadingFilters$: BehaviorSubject = new BehaviorSubject(true);
+
+ /**
+ * The current paginated search options
+ */
+ searchOptions$: Observable;
+
+ private sub: Subscription;
+
/**
* Initialize instance variables
+ * @param {ChangeDetectorRef} cdr
* @param {SearchService} searchService
* @param {SearchConfigurationService} searchConfigService
* @param {SearchFilterService} filterService
*/
- constructor(private searchService: SearchService, private searchConfigService: SearchConfigurationService, private filterService: SearchFilterService) {
- this.filters = searchService.getConfig().pipe(getSucceededRemoteData());
- this.clearParams = searchConfigService.getCurrentFrontendFilters().pipe(map((filters) => {
+ constructor(
+ private cdr: ChangeDetectorRef,
+ private searchService: SearchService,
+ @Inject(SEARCH_CONFIG_SERVICE) private searchConfigService: SearchConfigurationService,
+ private filterService: SearchFilterService) {
+ }
+
+ ngOnInit(): void {
+ this.searchOptions$ = this.searchConfigService.searchOptions;
+
+ this.sub = this.searchOptions$.pipe(
+ tap(() => this.setLoading()),
+ switchMap((options) => this.searchService.getConfig(options.scope, options.configuration).pipe(getSucceededRemoteData())))
+ .subscribe((filtersRD: RemoteData) => {
+ this.filters = filtersRD.payload;
+ this.isLoadingFilters$.next(false);
+ });
+
+ this.clearParams = this.searchConfigService.getCurrentFrontendFilters().pipe(map((filters) => {
Object.keys(filters).forEach((f) => filters[f] = null);
return filters;
}));
@@ -58,12 +91,13 @@ export class SearchFiltersComponent {
* @returns {Observable} Emits true whenever a given filter config should be shown
*/
isActive(filterConfig: SearchFilterConfig): Observable {
+ console.log('isActive', filterConfig);
return this.filterService.getSelectedValuesForFilter(filterConfig).pipe(
mergeMap((isActive) => {
if (isNotEmpty(isActive)) {
return observableOf(true);
} else {
- return this.searchConfigService.searchOptions.pipe(
+ return this.searchOptions$.pipe(
switchMap((options) => {
return this.searchService.getFacetValuesFor(filterConfig, 1, options).pipe(
filter((RD) => !RD.isLoading),
@@ -73,6 +107,20 @@ export class SearchFiltersComponent {
}
))
}
- }),startWith(true),);
+ }),
+ first(),
+ startWith(true),);
}
+
+ private setLoading() {
+ this.isLoadingFilters$.next(true);
+ this.cdr.detectChanges();
+ }
+
+ ngOnDestroy(): void {
+ if (hasValue(this.sub)) {
+ this.sub.unsubscribe();
+ }
+ }
+
}
diff --git a/src/app/+search-page/search-labels/search-labels.component.ts b/src/app/+search-page/search-labels/search-labels.component.ts
index 08e07cce3d..fd82de326c 100644
--- a/src/app/+search-page/search-labels/search-labels.component.ts
+++ b/src/app/+search-page/search-labels/search-labels.component.ts
@@ -1,10 +1,11 @@
-import { Component } from '@angular/core';
+import { Component, Inject } from '@angular/core';
import { SearchService } from '../search-service/search.service';
import { Observable } from 'rxjs';
import { Params } from '@angular/router';
import { map } from 'rxjs/operators';
import { hasValue, isNotEmpty } from '../../shared/empty.util';
import { SearchConfigurationService } from '../search-service/search-configuration.service';
+import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component';
@Component({
selector: 'ds-search-labels',
@@ -24,7 +25,9 @@ export class SearchLabelsComponent {
/**
* Initialize the instance variable
*/
- constructor(private searchService: SearchService, private searchConfigService: SearchConfigurationService) {
+ constructor(
+ private searchService: SearchService,
+ @Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService) {
this.appliedFilters = this.searchConfigService.getCurrentFrontendFilters();
}
diff --git a/src/app/+search-page/search-options.model.ts b/src/app/+search-page/search-options.model.ts
index 123cf950f8..e56cec1724 100644
--- a/src/app/+search-page/search-options.model.ts
+++ b/src/app/+search-page/search-options.model.ts
@@ -8,12 +8,14 @@ import { DSpaceObjectType } from '../core/shared/dspace-object-type.model';
* This model class represents all parameters needed to request information about a certain search request
*/
export class SearchOptions {
+ configuration?: string;
scope?: string;
query?: string;
dsoType?: DSpaceObjectType;
filters?: SearchFilter[];
- constructor(options: {scope?: string, query?: string, dsoType?: DSpaceObjectType, filters?: SearchFilter[]}) {
+ constructor(options: {configuration?: string, scope?: string, query?: string, dsoType?: DSpaceObjectType, filters?: SearchFilter[]}) {
+ this.configuration = options.configuration;
this.scope = options.scope;
this.query = options.query;
this.dsoType = options.dsoType;
@@ -28,6 +30,9 @@ export class SearchOptions {
*/
toRestUrl(url: string, args: string[] = []): string {
+ if (isNotEmpty(this.configuration)) {
+ args.push(`configuration=${this.configuration}`);
+ }
if (isNotEmpty(this.query)) {
args.push(`query=${this.query}`);
}
diff --git a/src/app/+search-page/search-page.component.ts b/src/app/+search-page/search-page.component.ts
index 816e3d67bf..333faacc47 100644
--- a/src/app/+search-page/search-page.component.ts
+++ b/src/app/+search-page/search-page.component.ts
@@ -1,4 +1,4 @@
-import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
+import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core';
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
import { switchMap, } from 'rxjs/operators';
import { PaginatedList } from '../core/data/paginated-list';
@@ -7,13 +7,13 @@ import { DSpaceObject } from '../core/shared/dspace-object.model';
import { pushInOut } from '../shared/animations/push';
import { HostWindowService } from '../shared/host-window.service';
import { PaginatedSearchOptions } from './paginated-search-options.model';
-import { SearchFilterService } from './search-filters/search-filter/search-filter.service';
import { SearchResult } from './search-result.model';
import { SearchService } from './search-service/search.service';
import { SearchSidebarService } from './search-sidebar/search-sidebar.service';
import { hasValue } from '../shared/empty.util';
import { SearchConfigurationService } from './search-service/search-configuration.service';
import { getSucceededRemoteData } from '../core/shared/operators';
+import { SEARCH_CONFIG_SERVICE } from '../+my-dspace-page/my-dspace-page.component';
/**
* This component renders a simple item page.
@@ -26,7 +26,13 @@ import { getSucceededRemoteData } from '../core/shared/operators';
styleUrls: ['./search-page.component.scss'],
templateUrl: './search-page.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
- animations: [pushInOut]
+ animations: [pushInOut],
+ providers: [
+ {
+ provide: SEARCH_CONFIG_SERVICE,
+ useClass: SearchConfigurationService
+ }
+ ]
})
/**
@@ -62,8 +68,7 @@ export class SearchPageComponent implements OnInit {
constructor(private service: SearchService,
private sidebarService: SearchSidebarService,
private windowService: HostWindowService,
- private filterService: SearchFilterService,
- private searchConfigService: SearchConfigurationService) {
+ @Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService) {
this.isXsOrSm$ = this.windowService.isXsOrSm();
}
diff --git a/src/app/+search-page/search-page.module.ts b/src/app/+search-page/search-page.module.ts
index 0c8a4ee306..ff23f92b2c 100644
--- a/src/app/+search-page/search-page.module.ts
+++ b/src/app/+search-page/search-page.module.ts
@@ -28,11 +28,37 @@ import { SearchFacetFilterWrapperComponent } from './search-filters/search-filte
import { SearchBooleanFilterComponent } from './search-filters/search-filter/search-boolean-filter/search-boolean-filter.component';
import { SearchHierarchyFilterComponent } from './search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component';
import { SearchConfigurationService } from './search-service/search-configuration.service';
+import { SearchSwitchConfigurationComponent } from './search-switch-configuration/search-switch-configuration.component';
const effects = [
SearchSidebarEffects
];
+const components = [
+ SearchPageComponent,
+ SearchResultsComponent,
+ SearchSidebarComponent,
+ SearchSettingsComponent,
+ ItemSearchResultListElementComponent,
+ CollectionSearchResultListElementComponent,
+ CommunitySearchResultListElementComponent,
+ ItemSearchResultGridElementComponent,
+ CollectionSearchResultGridElementComponent,
+ CommunitySearchResultGridElementComponent,
+ CommunitySearchResultListElementComponent,
+ SearchFiltersComponent,
+ SearchFilterComponent,
+ SearchFacetFilterComponent,
+ SearchLabelsComponent,
+ SearchFacetFilterComponent,
+ SearchFacetFilterWrapperComponent,
+ SearchRangeFilterComponent,
+ SearchTextFilterComponent,
+ SearchHierarchyFilterComponent,
+ SearchBooleanFilterComponent,
+ SearchSwitchConfigurationComponent
+];
+
@NgModule({
imports: [
SearchPageRoutingModule,
@@ -41,29 +67,7 @@ const effects = [
EffectsModule.forFeature(effects),
CoreModule.forRoot()
],
- declarations: [
- SearchPageComponent,
- SearchResultsComponent,
- SearchSidebarComponent,
- SearchSettingsComponent,
- ItemSearchResultListElementComponent,
- CollectionSearchResultListElementComponent,
- CommunitySearchResultListElementComponent,
- ItemSearchResultGridElementComponent,
- CollectionSearchResultGridElementComponent,
- CommunitySearchResultGridElementComponent,
- CommunitySearchResultListElementComponent,
- SearchFiltersComponent,
- SearchFilterComponent,
- SearchFacetFilterComponent,
- SearchLabelsComponent,
- SearchFacetFilterComponent,
- SearchFacetFilterWrapperComponent,
- SearchRangeFilterComponent,
- SearchTextFilterComponent,
- SearchHierarchyFilterComponent,
- SearchBooleanFilterComponent,
- ],
+ declarations: components,
providers: [
SearchService,
SearchSidebarService,
@@ -82,7 +86,8 @@ const effects = [
SearchTextFilterComponent,
SearchHierarchyFilterComponent,
SearchBooleanFilterComponent,
- ]
+ ],
+ exports: components
})
/**
diff --git a/src/app/+search-page/search-service/facet-value.model.ts b/src/app/+search-page/search-service/facet-value.model.ts
index a597528d50..d5102ec68d 100644
--- a/src/app/+search-page/search-service/facet-value.model.ts
+++ b/src/app/+search-page/search-service/facet-value.model.ts
@@ -6,7 +6,13 @@ import { autoserialize, autoserializeAs } from 'cerialize';
*/
export class FacetValue {
/**
- * The display value of the facet value
+ * The display label of the facet value
+ */
+ @autoserialize
+ label: string;
+
+ /**
+ * The value of the facet value
*/
@autoserializeAs(String, 'label')
value: string;
diff --git a/src/app/+search-page/search-service/search-configuration.service.ts b/src/app/+search-page/search-service/search-configuration.service.ts
index 292f26724d..31ba839eb5 100644
--- a/src/app/+search-page/search-service/search-configuration.service.ts
+++ b/src/app/+search-page/search-service/search-configuration.service.ts
@@ -1,3 +1,6 @@
+import { Injectable, OnDestroy } from '@angular/core';
+import { ActivatedRoute, Params } from '@angular/router';
+
import {
BehaviorSubject,
combineLatest as observableCombineLatest,
@@ -7,12 +10,11 @@ import {
Subscription
} from 'rxjs';
import { filter, map } from 'rxjs/operators';
+
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
import { SearchOptions } from '../search-options.model';
-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, isNotEmpty } from '../../shared/empty.util';
import { RemoteData } from '../../core/data/remote-data';
@@ -28,7 +30,7 @@ export class SearchConfigurationService implements OnDestroy {
/**
* Default pagination settings
*/
- private defaultPagination = Object.assign(new PaginationComponentOptions(), {
+ protected defaultPagination = Object.assign(new PaginationComponentOptions(), {
id: 'search-page-configuration',
pageSize: 10,
currentPage: 1
@@ -37,17 +39,22 @@ export class SearchConfigurationService implements OnDestroy {
/**
* Default sort settings
*/
- private defaultSort = new SortOptions('score', SortDirection.DESC);
+ protected defaultSort = new SortOptions('score', SortDirection.DESC);
+
+ /**
+ * Default configuration parameter setting
+ */
+ protected defaultConfiguration = 'default';
/**
* Default scope setting
*/
- private defaultScope = '';
+ protected defaultScope = '';
/**
* Default query setting
*/
- private defaultQuery = '';
+ protected defaultQuery = '';
/**
* Emits the current default values
@@ -74,8 +81,8 @@ export class SearchConfigurationService implements OnDestroy {
* @param {RouteService} routeService
* @param {ActivatedRoute} route
*/
- constructor(private routeService: RouteService,
- private route: ActivatedRoute) {
+ constructor(protected routeService: RouteService,
+ protected route: ActivatedRoute) {
this.defaults
.pipe(getSucceededRemoteData())
.subscribe((defRD) => {
@@ -85,10 +92,20 @@ export class SearchConfigurationService implements OnDestroy {
this.subs.push(this.subscribeToSearchOptions(defs));
this.subs.push(this.subscribeToPaginatedSearchOptions(defs));
+
}
)
}
+ /**
+ * @returns {Observable} Emits the current configuration string
+ */
+ getCurrentConfiguration(defaultConfiguration: string) {
+ return this.routeService.getQueryParameterValue('configuration').pipe(map((configuration) => {
+ return configuration || defaultConfiguration;
+ }));
+ }
+
/**
* @returns {Observable} Emits the current scope's identifier
*/
@@ -188,6 +205,7 @@ export class SearchConfigurationService implements OnDestroy {
*/
subscribeToSearchOptions(defaults: SearchOptions): Subscription {
return observableMerge(
+ this.getConfigurationPart(defaults.configuration),
this.getScopePart(defaults.scope),
this.getQueryPart(defaults.query),
this.getDSOTypePart(),
@@ -208,6 +226,7 @@ export class SearchConfigurationService implements OnDestroy {
return observableMerge(
this.getPaginationPart(defaults.pagination),
this.getSortPart(defaults.sort),
+ this.getConfigurationPart(defaults.configuration),
this.getScopePart(defaults.scope),
this.getQueryPart(defaults.query),
this.getDSOTypePart(),
@@ -226,6 +245,7 @@ export class SearchConfigurationService implements OnDestroy {
if (hasNoValue(this._defaults)) {
const options = new PaginatedSearchOptions({
pagination: this.defaultPagination,
+ configuration: this.defaultConfiguration,
sort: this.defaultSort,
scope: this.defaultScope,
query: this.defaultQuery
@@ -242,6 +262,16 @@ export class SearchConfigurationService implements OnDestroy {
this.subs.forEach((sub) => {
sub.unsubscribe();
});
+ this.subs = [];
+ }
+
+ /**
+ * @returns {Observable} Emits the current configuration settings as a partial SearchOptions object
+ */
+ private getConfigurationPart(defaultConfiguration: string): Observable {
+ return this.getCurrentConfiguration(defaultConfiguration).pipe(map((configuration) => {
+ return { configuration }
+ }));
}
/**
diff --git a/src/app/+search-page/search-service/search-query-response.model.ts b/src/app/+search-page/search-service/search-query-response.model.ts
index ac1d8b7df3..bca6e644fc 100644
--- a/src/app/+search-page/search-service/search-query-response.model.ts
+++ b/src/app/+search-page/search-service/search-query-response.model.ts
@@ -34,7 +34,7 @@ export class SearchQueryResponse {
* The sort parameters used in the search request
*/
@autoserialize
- configurationName: string;
+ configuration: string;
/**
* The sort parameters used in the search request
diff --git a/src/app/+search-page/search-service/search-result-element-decorator.ts b/src/app/+search-page/search-service/search-result-element-decorator.ts
index 348cf7f592..59446480a3 100644
--- a/src/app/+search-page/search-service/search-result-element-decorator.ts
+++ b/src/app/+search-page/search-service/search-result-element-decorator.ts
@@ -1,5 +1,6 @@
import { GenericConstructor } from '../../core/shared/generic-constructor';
import { ListableObject } from '../../shared/object-collection/shared/listable-object.model';
+import { isNull } from '../../shared/empty.util';
/**
* Contains the mapping between a search result component and a DSpaceObject
@@ -11,12 +12,19 @@ const searchResultMap = new Map();
* @param {GenericConstructor} domainConstructor The constructor of the DSpaceObject
* @returns Decorator function that performs the actual mapping on initialization of the component
*/
-export function searchResultFor(domainConstructor: GenericConstructor) {
+export function searchResultFor(domainConstructor: GenericConstructor, configuration: string = null) {
return function decorator(searchResult: any) {
if (!searchResult) {
return;
}
- searchResultMap.set(domainConstructor, searchResult);
+ if (isNull(configuration)) {
+ searchResultMap.set(domainConstructor, searchResult);
+ } else {
+ if (!searchResultMap.get(configuration)) {
+ searchResultMap.set(configuration, new Map());
+ }
+ searchResultMap.get(configuration).set(domainConstructor, searchResult);
+ }
};
}
@@ -25,6 +33,10 @@ export function searchResultFor(domainConstructor: GenericConstructor} domainConstructor The DSpaceObject's constructor for which the search result component is requested
* @returns The component's constructor that matches the given DSpaceObject
*/
-export function getSearchResultFor(domainConstructor: GenericConstructor) {
- return searchResultMap.get(domainConstructor);
+export function getSearchResultFor(domainConstructor: GenericConstructor, configuration: string = null) {
+ if (isNull(configuration) || configuration === 'default') {
+ return searchResultMap.get(domainConstructor);
+ } else {
+ return searchResultMap.get(configuration).get(domainConstructor);
+ }
}
diff --git a/src/app/+search-page/search-service/search.service.ts b/src/app/+search-page/search-service/search.service.ts
index 275b0b3340..1d5ff06193 100644
--- a/src/app/+search-page/search-service/search.service.ts
+++ b/src/app/+search-page/search-service/search.service.ts
@@ -7,7 +7,7 @@ import {
Router,
UrlSegmentGroup
} from '@angular/router';
-import { map, switchMap, tap } from 'rxjs/operators';
+import { distinctUntilChanged, filter, first, map, switchMap, take, tap } from 'rxjs/operators';
import { RemoteDataBuildService } from '../../core/cache/builders/remote-data-build.service';
import {
FacetConfigSuccessResponse,
@@ -23,12 +23,12 @@ import { DSpaceObject } from '../../core/shared/dspace-object.model';
import { GenericConstructor } from '../../core/shared/generic-constructor';
import { HALEndpointService } from '../../core/shared/hal-endpoint.service';
import {
- configureRequest,
+ configureRequest, filterSuccessfulResponses,
getResponseFromEntry,
getSucceededRemoteData
} from '../../core/shared/operators';
import { URLCombiner } from '../../core/url-combiner/url-combiner';
-import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
+import { hasValue, isEmpty, isNotEmpty, isNotUndefined } from '../../shared/empty.util';
import { NormalizedSearchResult } from '../normalized-search-result.model';
import { SearchOptions } from '../search-options.model';
import { SearchResult } from '../search-result.model';
@@ -63,6 +63,16 @@ export class SearchService implements OnDestroy {
*/
private facetLinkPathPrefix = 'discover/facets/';
+ /**
+ * When true, a new search request is always dispatched
+ */
+ private forceBypassCache = false;
+
+ /**
+ * The ResponseParsingService constructor name
+ */
+ private parser: GenericConstructor = SearchResponseParsingService;
+
/**
* Subscription to unsubscribe from
*/
@@ -78,6 +88,19 @@ export class SearchService implements OnDestroy {
) {
}
+ /**
+ * Method to set service options
+ * @param {GenericConstructor} parser The configuration necessary to perform this search
+ * @param {boolean} forceBypassCache When true, a new search request is always dispatched
+ * @returns {Observable>>>} Emits a paginated list with all search results found
+ */
+ setServiceOptions(parser: GenericConstructor, forceBypassCache: boolean) {
+ if (parser) {
+ this.parser = parser;
+ }
+ this.forceBypassCache = forceBypassCache;
+ }
+
/**
* Method to retrieve a paginated list of search results from the server
* @param {PaginatedSearchOptions} searchOptions The configuration necessary to perform this search
@@ -90,13 +113,15 @@ export class SearchService implements OnDestroy {
url = (searchOptions as PaginatedSearchOptions).toRestUrl(url);
}
const request = new GetRequest(this.requestService.generateRequestId(), url);
+ const getResponseParserFn: () => GenericConstructor = () => {
+ return this.parser;
+ };
+
return Object.assign(request, {
- getResponseParser(): GenericConstructor {
- return SearchResponseParsingService;
- }
+ getResponseParser: getResponseParserFn
});
}),
- configureRequest(this.requestService)
+ configureRequest(this.requestService, this.forceBypassCache),
);
const requestEntryObs = requestObs.pipe(
switchMap((request: RestRequest) => this.requestService.getByHref(request.href))
@@ -111,8 +136,11 @@ export class SearchService implements OnDestroy {
// turn dspace href from search results to effective list of DSpaceObjects
// Turn list of observable remote data DSO's into observable remote data object with list of DSO
const dsoObs: Observable> = sqrObs.pipe(
+ // filter((sqr: SearchQueryResponse) => isNotUndefined(sqr)),
map((sqr: SearchQueryResponse) => {
- return sqr.objects.map((nsr: NormalizedSearchResult) => {
+ return sqr.objects
+ .filter((nsr: NormalizedSearchResult) => isNotUndefined(nsr.dspaceObject))
+ .map((nsr: NormalizedSearchResult) => {
return this.rdb.buildSingle(nsr.dspaceObject);
})
}),
@@ -126,7 +154,7 @@ export class SearchService implements OnDestroy {
let co = DSpaceObject;
if (dsos.payload[index]) {
const constructor: GenericConstructor = dsos.payload[index].constructor as GenericConstructor;
- co = getSearchResultFor(constructor);
+ co = getSearchResultFor(constructor, searchOptions.configuration);
return Object.assign(new co(), object, {
dspaceObject: dsos.payload[index]
});
@@ -134,6 +162,7 @@ export class SearchService implements OnDestroy {
return undefined;
}
});
+ // .filter((object) => isNotUndefined(object));
})
);
@@ -156,7 +185,7 @@ export class SearchService implements OnDestroy {
* @param {string} scope UUID of the object for which config the filter config is requested, when no scope is provided the configuration for the whole repository is loaded
* @returns {Observable>} The found filter configuration
*/
- getConfig(scope?: string): Observable> {
+ getConfig(scope?: string, configuration?: string): Observable> {
const requestObs = this.halService.getEndpoint(this.facetLinkPathPrefix).pipe(
map((url: string) => {
const args: string[] = [];
@@ -165,6 +194,10 @@ export class SearchService implements OnDestroy {
args.push(`scope=${scope}`);
}
+ if (isNotEmpty(configuration)) {
+ args.push(`configuration=${configuration}`);
+ }
+
if (isNotEmpty(args)) {
url = new URLCombiner(url, `?${args.join('&')}`).toString();
}
@@ -176,7 +209,7 @@ export class SearchService implements OnDestroy {
}
});
}),
- configureRequest(this.requestService)
+ configureRequest(this.requestService, this.forceBypassCache)
);
const requestEntryObs = requestObs.pipe(
@@ -202,6 +235,7 @@ export class SearchService implements OnDestroy {
* @returns {Observable>>} Emits the given page of facet values
*/
getFacetValuesFor(filterConfig: SearchFilterConfig, valuePage: number, searchOptions?: SearchOptions, filterQuery?: string): Observable>> {
+ console.log('getFacetValuesFor');
const requestObs = this.halService.getEndpoint(this.facetLinkPathPrefix + filterConfig.name).pipe(
map((url: string) => {
const args: string[] = [`page=${valuePage - 1}`, `size=${filterConfig.pageSize}`];
@@ -219,7 +253,8 @@ export class SearchService implements OnDestroy {
}
});
}),
- configureRequest(this.requestService)
+ configureRequest(this.requestService, this.forceBypassCache),
+ first()
);
const requestEntryObs = requestObs.pipe(
diff --git a/src/app/+search-page/search-settings/search-settings.component.ts b/src/app/+search-page/search-settings/search-settings.component.ts
index 7fc5645fcc..24b2ee4778 100644
--- a/src/app/+search-page/search-settings/search-settings.component.ts
+++ b/src/app/+search-page/search-settings/search-settings.component.ts
@@ -1,10 +1,11 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, Inject, OnInit } from '@angular/core';
import { SearchService } from '../search-service/search.service';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
import { PaginatedSearchOptions } from '../paginated-search-options.model';
import { Observable } from 'rxjs';
import { SearchConfigurationService } from '../search-service/search-configuration.service';
+import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component';
@Component({
selector: 'ds-search-settings',
@@ -30,7 +31,7 @@ export class SearchSettingsComponent implements OnInit {
constructor(private service: SearchService,
private route: ActivatedRoute,
private router: Router,
- private searchConfigurationService: SearchConfigurationService) {
+ @Inject(SEARCH_CONFIG_SERVICE) public searchConfigurationService: SearchConfigurationService) {
}
/**
diff --git a/src/app/+search-page/search-sidebar/search-sidebar.component.html b/src/app/+search-page/search-sidebar/search-sidebar.component.html
index 5ff1e3c8fa..ac9c834443 100644
--- a/src/app/+search-page/search-sidebar/search-sidebar.component.html
+++ b/src/app/+search-page/search-sidebar/search-sidebar.component.html
@@ -10,6 +10,7 @@