Skip to content

Commit 92cc112

Browse files
111731: Also minimize the search facets while switching scopes
1 parent 25fd737 commit 92cc112

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/app/shared/search-form/search-form.component.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,32 @@ import { BrowserOnlyMockPipe } from '../testing/browser-only-mock.pipe';
1717
import { SearchServiceStub } from '../testing/search-service.stub';
1818
import { Router } from '@angular/router';
1919
import { RouterStub } from '../testing/router.stub';
20+
import { SearchFilterService } from '../../core/shared/search/search-filter.service';
21+
import { SearchFilterServiceStub } from '../testing/search-filter-service.stub';
2022

2123
describe('SearchFormComponent', () => {
2224
let comp: SearchFormComponent;
2325
let fixture: ComponentFixture<SearchFormComponent>;
2426
let de: DebugElement;
25-
let el: HTMLElement;
2627

2728
const router = new RouterStub();
2829
const searchService = new SearchServiceStub();
30+
let searchFilterService: SearchFilterServiceStub;
2931
const paginationService = new PaginationServiceStub();
3032
const searchConfigService = { paginationID: 'test-id' };
3133
const dspaceObjectService = {
3234
findById: () => createSuccessfulRemoteDataObject$(undefined),
3335
};
3436

3537
beforeEach(waitForAsync(() => {
38+
searchFilterService = new SearchFilterServiceStub();
39+
3640
return TestBed.configureTestingModule({
3741
imports: [FormsModule, RouterTestingModule, TranslateModule.forRoot()],
3842
providers: [
3943
{ provide: Router, useValue: router },
4044
{ provide: SearchService, useValue: searchService },
45+
{ provide: SearchFilterService, useValue: searchFilterService },
4146
{ provide: PaginationService, useValue: paginationService },
4247
{ provide: SearchConfigurationService, useValue: searchConfigService },
4348
{ provide: DSpaceObjectDataService, useValue: dspaceObjectService },
@@ -53,7 +58,6 @@ describe('SearchFormComponent', () => {
5358
fixture = TestBed.createComponent(SearchFormComponent);
5459
comp = fixture.componentInstance; // SearchFormComponent test instance
5560
de = fixture.debugElement.query(By.css('form'));
56-
el = de.nativeElement;
5761
});
5862

5963
it('should not display scopes when showScopeSelector is false', fakeAsync(() => {

src/app/shared/search-form/search-form.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { BehaviorSubject } from 'rxjs';
1313
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
1414
import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
1515
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
16+
import { SearchFilterService } from '../../core/shared/search/search-filter.service';
1617

1718
@Component({
1819
selector: 'ds-search-form',
@@ -71,6 +72,7 @@ export class SearchFormComponent implements OnChanges {
7172
constructor(
7273
protected router: Router,
7374
protected searchService: SearchService,
75+
protected searchFilterService: SearchFilterService,
7476
protected paginationService: PaginationService,
7577
protected searchConfig: SearchConfigurationService,
7678
protected modalService: NgbModal,
@@ -107,6 +109,7 @@ export class SearchFormComponent implements OnChanges {
107109
*/
108110
onScopeChange(scope: DSpaceObject) {
109111
this.updateSearch({ scope: scope ? scope.uuid : undefined });
112+
this.searchFilterService.minimizeAll();
110113
}
111114

112115
/**

src/app/shared/search/search.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ export class SearchComponent implements OnInit {
416416
* @private
417417
*/
418418
private retrieveFilters(searchOptions: PaginatedSearchOptions) {
419-
this.filtersRD$.next(null);
420419
this.searchConfigService.getConfig(searchOptions.scope, searchOptions.configuration).pipe(
421420
getFirstCompletedRemoteData(),
422421
).subscribe((filtersRD: RemoteData<SearchFilterConfig[]>) => {

0 commit comments

Comments
 (0)