Commits
Alexandre Vryghem authored e94b094c201 Merge
49 49 | import { RouteService } from '../../services/route.service'; |
50 50 | import { URLCombiner } from '../../url-combiner/url-combiner'; |
51 51 | import { DSpaceObjectType } from '../dspace-object-type.model'; |
52 52 | import { GenericConstructor } from '../generic-constructor'; |
53 53 | import { HALEndpointService } from '../hal-endpoint.service'; |
54 54 | import { |
55 55 | getAllSucceededRemoteDataPayload, |
56 56 | getFirstSucceededRemoteData, |
57 57 | } from '../operators'; |
58 58 | import { ViewMode } from '../view-mode.model'; |
59 + | import { SearchFilterConfig } from '../../../shared/search/models/search-filter-config.model'; |
60 + | import { FacetConfigResponse } from '../../../shared/search/models/facet-config-response.model'; |
61 + | import { addOperatorToFilterValue } from '../../../shared/search/search.utils'; |
62 + | import { FilterConfig } from './search-filters/search-config.model'; |
63 + | import { FilterType } from '../../../shared/search/models/filter-type.model'; |
59 64 | import { |
60 65 | SearchConfig, |
61 66 | SortConfig, |
62 67 | } from './search-filters/search-config.model'; |
63 68 | |
64 69 | /** |
65 70 | * Service that performs all actions that have to do with the current search configuration |
66 71 | */ |
67 72 | @Injectable({ providedIn: 'root' }) |
68 73 | export class SearchConfigurationService implements OnDestroy { |
275 280 | * Return the SortOptions list available for the given SearchConfig |
276 281 | * @param searchConfig The SearchConfig object |
277 282 | */ |
278 283 | getConfigurationSortOptions(searchConfig: SearchConfig): SortOptions[] { |
279 284 | return searchConfig.sortOptions.map((entry: SortConfig) => ({ |
280 285 | field: entry.name, |
281 286 | direction: entry.sortOrder.toLowerCase() === SortDirection.ASC.toLowerCase() ? SortDirection.ASC : SortDirection.DESC, |
282 287 | })); |
283 288 | } |
284 289 | |
290 + | /** |
291 + | * Return the {@link FilterConfig}s of the filters that should be displayed for the current configuration/scope |
292 + | * |
293 + | * @param configuration The search configuration |
294 + | * @param scope The scope if exists |
295 + | */ |
296 + | public getConfigurationAdvancedSearchFilters(configuration: string, scope?: string): Observable<FilterConfig[]> { |
297 + | return this.getConfigurationSearchConfig(configuration, scope).pipe( |
298 + | map((searchConfiguration: SearchConfig) => { |
299 + | return searchConfiguration.filters |
300 + | .filter((filterConfig: FilterConfig) => filterConfig.type !== FilterType.range); |
301 + | }), |
302 + | ); |
303 + | } |
304 + | |
285 305 | setPaginationId(paginationId): void { |
286 306 | if (isNotEmpty(paginationId)) { |
287 307 | const currentValue: PaginatedSearchOptions = this.paginatedSearchOptions.getValue(); |
288 308 | const updatedValue: PaginatedSearchOptions = Object.assign(new PaginatedSearchOptions({}), currentValue, { |
289 309 | pagination: Object.assign({}, currentValue.pagination, { |
290 310 | id: paginationId, |
291 311 | }), |
292 312 | }); |
293 313 | // unsubscribe from subscription related to old pagination id |
294 314 | this.unsubscribeFromSearchOptions(this.paginationID); |