mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
facet fix
This commit is contained in:
@@ -62,6 +62,7 @@ export class SearchFacetSelectedOptionComponent implements OnInit, OnDestroy {
|
||||
ngOnInit(): void {
|
||||
this.sub = observableCombineLatest(this.selectedValues$, this.searchConfigService.searchOptions)
|
||||
.subscribe(([selectedValues, searchOptions]) => {
|
||||
console.log(selectedValues);
|
||||
this.updateRemoveParams(selectedValues)
|
||||
});
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import {
|
||||
Subject,
|
||||
Subscription
|
||||
} from 'rxjs';
|
||||
import { switchMap, distinctUntilChanged, map, take, flatMap } from 'rxjs/operators';
|
||||
import { switchMap, distinctUntilChanged, map, take, flatMap, tap } from 'rxjs/operators';
|
||||
import { animate, state, style, transition, trigger } from '@angular/animations';
|
||||
import { Component, Inject, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
@@ -117,14 +117,6 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
||||
})
|
||||
);
|
||||
|
||||
this.selectedValues$ = observableCombineLatest(
|
||||
this.filterService.getSelectedValuesForFilter(this.filterConfig),
|
||||
facetValues$.pipe(flatMap((facetValues) => facetValues.values))).pipe(
|
||||
map(([selectedValues, facetValues]) => {
|
||||
return facetValues.payload.page.filter((facetValue) => selectedValues.includes(this.getFacetValue(facetValue)))
|
||||
})
|
||||
);
|
||||
|
||||
let filterValues = [];
|
||||
this.subs.push(facetValues$.subscribe((facetOutcome) => {
|
||||
const newValues$ = facetOutcome.values;
|
||||
@@ -140,9 +132,24 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
||||
|
||||
filterValues = [...filterValues, newValues$];
|
||||
|
||||
this.subs.push(this.rdbs.aggregate(filterValues).subscribe((rd: RemoteData<Array<PaginatedList<FacetValue>>>) => {
|
||||
this.subs.push(this.rdbs.aggregate(filterValues).pipe(
|
||||
tap((rd: RemoteData<Array<PaginatedList<FacetValue>>>) => {
|
||||
this.selectedValues$ = this.filterService.getSelectedValuesForFilter(this.filterConfig).pipe(
|
||||
map((selectedValues) => {
|
||||
return selectedValues.map((value: string) => {
|
||||
const fValue = [].concat(...rd.payload.map((page) => page.page)).find((facetValue: FacetValue) => facetValue.value === value)
|
||||
if (hasValue(fValue)) {
|
||||
return fValue;
|
||||
}
|
||||
return Object.assign(new FacetValue(), { label: value, value: value });
|
||||
});
|
||||
})
|
||||
);
|
||||
})
|
||||
).subscribe((rd: RemoteData<Array<PaginatedList<FacetValue>>>) => {
|
||||
this.animationState = 'ready';
|
||||
this.filterValues$.next(rd);
|
||||
|
||||
}));
|
||||
this.subs.push(newValues$.pipe(take(1)).subscribe((rd) => {
|
||||
this.isLastPage$.next(hasNoValue(rd.payload.next))
|
||||
@@ -224,10 +231,12 @@ export class SearchFacetFilterComponent implements OnInit, OnDestroy {
|
||||
if (isNotEmpty(data)) {
|
||||
this.router.navigate(this.getSearchLinkParts(), {
|
||||
queryParams:
|
||||
{ [this.filterConfig.paramName]: [
|
||||
{
|
||||
[this.filterConfig.paramName]: [
|
||||
...selectedValues.map((facet) => this.getFacetValue(facet)),
|
||||
data
|
||||
] },
|
||||
]
|
||||
},
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
this.filter = '';
|
||||
|
@@ -21,6 +21,8 @@ import { SearchOptions } from '../../search-options.model';
|
||||
import { PaginatedSearchOptions } from '../../paginated-search-options.model';
|
||||
import { SearchFixedFilterService } from './search-fixed-filter.service';
|
||||
import { Params } from '@angular/router';
|
||||
import * as postcss from 'postcss';
|
||||
import prefix = postcss.vendor.prefix;
|
||||
// const spy = create();
|
||||
const filterStateSelector = (state: SearchFiltersState) => state.searchFilter;
|
||||
|
||||
@@ -142,7 +144,6 @@ export class SearchFilterService {
|
||||
const prefixValues$ = this.routeService.getQueryParamsWithPrefix(filterConfig.paramName + '.').pipe(
|
||||
map((params: Params) => [].concat(...Object.values(params))),
|
||||
);
|
||||
|
||||
return observableCombineLatest(values$, prefixValues$).pipe(
|
||||
map(([values, prefixValues]) => {
|
||||
if (isNotEmpty(values)) {
|
||||
|
Reference in New Issue
Block a user