mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
111731: Also minimize the search facets while switching scopes
This commit is contained in:
@@ -17,15 +17,17 @@ import { BrowserOnlyMockPipe } from '../testing/browser-only-mock.pipe';
|
|||||||
import { SearchServiceStub } from '../testing/search-service.stub';
|
import { SearchServiceStub } from '../testing/search-service.stub';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { RouterStub } from '../testing/router.stub';
|
import { RouterStub } from '../testing/router.stub';
|
||||||
|
import { SearchFilterService } from '../../core/shared/search/search-filter.service';
|
||||||
|
import { SearchFilterServiceStub } from '../testing/search-filter-service.stub';
|
||||||
|
|
||||||
describe('SearchFormComponent', () => {
|
describe('SearchFormComponent', () => {
|
||||||
let comp: SearchFormComponent;
|
let comp: SearchFormComponent;
|
||||||
let fixture: ComponentFixture<SearchFormComponent>;
|
let fixture: ComponentFixture<SearchFormComponent>;
|
||||||
let de: DebugElement;
|
let de: DebugElement;
|
||||||
let el: HTMLElement;
|
|
||||||
|
|
||||||
const router = new RouterStub();
|
const router = new RouterStub();
|
||||||
const searchService = new SearchServiceStub();
|
const searchService = new SearchServiceStub();
|
||||||
|
let searchFilterService: SearchFilterServiceStub;
|
||||||
const paginationService = new PaginationServiceStub();
|
const paginationService = new PaginationServiceStub();
|
||||||
const searchConfigService = { paginationID: 'test-id' };
|
const searchConfigService = { paginationID: 'test-id' };
|
||||||
const dspaceObjectService = {
|
const dspaceObjectService = {
|
||||||
@@ -33,11 +35,14 @@ describe('SearchFormComponent', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(waitForAsync(() => {
|
beforeEach(waitForAsync(() => {
|
||||||
|
searchFilterService = new SearchFilterServiceStub();
|
||||||
|
|
||||||
return TestBed.configureTestingModule({
|
return TestBed.configureTestingModule({
|
||||||
imports: [FormsModule, RouterTestingModule, TranslateModule.forRoot()],
|
imports: [FormsModule, RouterTestingModule, TranslateModule.forRoot()],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: Router, useValue: router },
|
{ provide: Router, useValue: router },
|
||||||
{ provide: SearchService, useValue: searchService },
|
{ provide: SearchService, useValue: searchService },
|
||||||
|
{ provide: SearchFilterService, useValue: searchFilterService },
|
||||||
{ provide: PaginationService, useValue: paginationService },
|
{ provide: PaginationService, useValue: paginationService },
|
||||||
{ provide: SearchConfigurationService, useValue: searchConfigService },
|
{ provide: SearchConfigurationService, useValue: searchConfigService },
|
||||||
{ provide: DSpaceObjectDataService, useValue: dspaceObjectService },
|
{ provide: DSpaceObjectDataService, useValue: dspaceObjectService },
|
||||||
@@ -53,7 +58,6 @@ describe('SearchFormComponent', () => {
|
|||||||
fixture = TestBed.createComponent(SearchFormComponent);
|
fixture = TestBed.createComponent(SearchFormComponent);
|
||||||
comp = fixture.componentInstance; // SearchFormComponent test instance
|
comp = fixture.componentInstance; // SearchFormComponent test instance
|
||||||
de = fixture.debugElement.query(By.css('form'));
|
de = fixture.debugElement.query(By.css('form'));
|
||||||
el = de.nativeElement;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not display scopes when showScopeSelector is false', fakeAsync(() => {
|
it('should not display scopes when showScopeSelector is false', fakeAsync(() => {
|
||||||
|
@@ -13,6 +13,7 @@ import { BehaviorSubject } from 'rxjs';
|
|||||||
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
import { DSpaceObjectDataService } from '../../core/data/dspace-object-data.service';
|
||||||
import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
|
import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
|
||||||
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
|
||||||
|
import { SearchFilterService } from '../../core/shared/search/search-filter.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-search-form',
|
selector: 'ds-search-form',
|
||||||
@@ -71,6 +72,7 @@ export class SearchFormComponent implements OnChanges {
|
|||||||
constructor(
|
constructor(
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
protected searchService: SearchService,
|
protected searchService: SearchService,
|
||||||
|
protected searchFilterService: SearchFilterService,
|
||||||
protected paginationService: PaginationService,
|
protected paginationService: PaginationService,
|
||||||
protected searchConfig: SearchConfigurationService,
|
protected searchConfig: SearchConfigurationService,
|
||||||
protected modalService: NgbModal,
|
protected modalService: NgbModal,
|
||||||
@@ -107,6 +109,7 @@ export class SearchFormComponent implements OnChanges {
|
|||||||
*/
|
*/
|
||||||
onScopeChange(scope: DSpaceObject) {
|
onScopeChange(scope: DSpaceObject) {
|
||||||
this.updateSearch({ scope: scope ? scope.uuid : undefined });
|
this.updateSearch({ scope: scope ? scope.uuid : undefined });
|
||||||
|
this.searchFilterService.minimizeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -416,7 +416,6 @@ export class SearchComponent implements OnInit {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
private retrieveFilters(searchOptions: PaginatedSearchOptions) {
|
private retrieveFilters(searchOptions: PaginatedSearchOptions) {
|
||||||
this.filtersRD$.next(null);
|
|
||||||
this.searchConfigService.getConfig(searchOptions.scope, searchOptions.configuration).pipe(
|
this.searchConfigService.getConfig(searchOptions.scope, searchOptions.configuration).pipe(
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
).subscribe((filtersRD: RemoteData<SearchFilterConfig[]>) => {
|
).subscribe((filtersRD: RemoteData<SearchFilterConfig[]>) => {
|
||||||
|
Reference in New Issue
Block a user