55946: Fixed search query not working

This commit is contained in:
Kristof De Langhe
2018-10-11 11:16:47 +02:00
parent 8f0d7b6a4e
commit fc96700475
4 changed files with 19 additions and 14 deletions

View File

@@ -9,7 +9,6 @@
<div class="col-12 col-lg-6"> <div class="col-12 col-lg-6">
<ds-search-form id="search-form" <ds-search-form id="search-form"
[query]="(searchOptions$ | async)?.query" [query]="(searchOptions$ | async)?.query"
[scope]="(searchOptions$ | async)?.scope"
[currentUrl]="getCurrentUrl()"> [currentUrl]="getCurrentUrl()">
</ds-search-form> </ds-search-form>
</div> </div>

View File

@@ -33,16 +33,16 @@ import { CollectionDataService } from '../../../core/data/collection-data.servic
import { ObjectSelectService } from '../../../shared/object-select/object-select.service'; import { ObjectSelectService } from '../../../shared/object-select/object-select.service';
import { ObjectSelectServiceStub } from '../../../shared/testing/object-select-service-stub'; import { ObjectSelectServiceStub } from '../../../shared/testing/object-select-service-stub';
fdescribe('ItemCollectionMapperComponent', () => { describe('ItemCollectionMapperComponent', () => {
let comp: ItemCollectionMapperComponent; let comp: ItemCollectionMapperComponent;
let fixture: ComponentFixture<ItemCollectionMapperComponent>; let fixture: ComponentFixture<ItemCollectionMapperComponent>;
let route: ActivatedRoute; let route: ActivatedRoute;
let router: Router; let router: Router;
let searchConfigService: SearchConfigurationService; let searchConfigService: SearchConfigurationService;
let searchService: SearchService;
let notificationsService: NotificationsService; let notificationsService: NotificationsService;
let itemDataService: ItemDataService; let itemDataService: ItemDataService;
let collectionDataService: CollectionDataService;
const mockItem: Item = Object.assign(new Item(), { const mockItem: Item = Object.assign(new Item(), {
id: '932c7d50-d85a-44cb-b9dc-b427b12877bd', id: '932c7d50-d85a-44cb-b9dc-b427b12877bd',
@@ -69,9 +69,9 @@ fdescribe('ItemCollectionMapperComponent', () => {
removeMappingFromCollection: () => Observable.of(new RestResponse(true, '200')), removeMappingFromCollection: () => Observable.of(new RestResponse(true, '200')),
getMappedCollections: () => Observable.of(mockCollectionsRD) getMappedCollections: () => Observable.of(mockCollectionsRD)
}; };
const collectionDataServiceStub = { const searchServiceStub = Object.assign(new SearchServiceStub(), {
findAll: () => Observable.of(mockCollectionsRD) search: () => Observable.of(mockCollectionsRD)
}; });
const activatedRouteStub = new ActivatedRouteStub({}, { item: mockItemRD }); const activatedRouteStub = new ActivatedRouteStub({}, { item: mockItemRD });
const translateServiceStub = { const translateServiceStub = {
get: () => Observable.of('test-message of item ' + mockItem.name), get: () => Observable.of('test-message of item ' + mockItem.name),
@@ -90,7 +90,7 @@ fdescribe('ItemCollectionMapperComponent', () => {
{ provide: SearchConfigurationService, useValue: searchConfigServiceStub }, { provide: SearchConfigurationService, useValue: searchConfigServiceStub },
{ provide: NotificationsService, useValue: new NotificationsServiceStub() }, { provide: NotificationsService, useValue: new NotificationsServiceStub() },
{ provide: ItemDataService, useValue: itemDataServiceStub }, { provide: ItemDataService, useValue: itemDataServiceStub },
{ provide: CollectionDataService, useValue: collectionDataServiceStub }, { provide: SearchService, useValue: searchServiceStub },
{ provide: ObjectSelectService, useValue: new ObjectSelectServiceStub() }, { provide: ObjectSelectService, useValue: new ObjectSelectServiceStub() },
{ provide: TranslateService, useValue: translateServiceStub }, { provide: TranslateService, useValue: translateServiceStub },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) } { provide: HostWindowService, useValue: new HostWindowServiceStub(0) }
@@ -107,7 +107,7 @@ fdescribe('ItemCollectionMapperComponent', () => {
searchConfigService = (comp as any).searchConfigService; searchConfigService = (comp as any).searchConfigService;
notificationsService = (comp as any).notificationsService; notificationsService = (comp as any).notificationsService;
itemDataService = (comp as any).itemDataService; itemDataService = (comp as any).itemDataService;
collectionDataService = (comp as any).collectionDataService; searchService = (comp as any).searchService;
}); });
it('should display the correct collection name', () => { it('should display the correct collection name', () => {

View File

@@ -8,7 +8,7 @@ import { RemoteData } from '../../../core/data/remote-data';
import { PaginatedList } from '../../../core/data/paginated-list'; import { PaginatedList } from '../../../core/data/paginated-list';
import { Collection } from '../../../core/shared/collection.model'; import { Collection } from '../../../core/shared/collection.model';
import { Item } from '../../../core/shared/item.model'; import { Item } from '../../../core/shared/item.model';
import { getSucceededRemoteData } from '../../../core/shared/operators'; import { getSucceededRemoteData, toDSpaceObjectListRD } from '../../../core/shared/operators';
import { ActivatedRoute, Router } from '@angular/router'; import { ActivatedRoute, Router } from '@angular/router';
import { SearchService } from '../../../+search-page/search-service/search.service'; import { SearchService } from '../../../+search-page/search-service/search.service';
import { SearchConfigurationService } from '../../../+search-page/search-service/search-configuration.service'; import { SearchConfigurationService } from '../../../+search-page/search-service/search-configuration.service';
@@ -19,6 +19,7 @@ import { RestResponse } from '../../../core/cache/response-cache.models';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { NotificationsService } from '../../../shared/notifications/notifications.service'; import { NotificationsService } from '../../../shared/notifications/notifications.service';
import { C } from '@angular/core/src/render3'; import { C } from '@angular/core/src/render3';
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
@Component({ @Component({
selector: 'ds-item-collection-mapper', selector: 'ds-item-collection-mapper',
@@ -59,7 +60,7 @@ export class ItemCollectionMapperComponent implements OnInit {
constructor(private route: ActivatedRoute, constructor(private route: ActivatedRoute,
private router: Router, private router: Router,
private searchConfigService: SearchConfigurationService, private searchConfigService: SearchConfigurationService,
private collectionDataService: CollectionDataService, private searchService: SearchService,
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private itemDataService: ItemDataService, private itemDataService: ItemDataService,
private translateService: TranslateService) { private translateService: TranslateService) {
@@ -82,8 +83,13 @@ export class ItemCollectionMapperComponent implements OnInit {
switchMap((item: Item) => this.itemDataService.getMappedCollections(item.id)) switchMap((item: Item) => this.itemDataService.getMappedCollections(item.id))
); );
this.mappingCollectionsRD$ = this.searchOptions$.pipe( this.mappingCollectionsRD$ = this.searchOptions$.pipe(
switchMap((searchOptions: PaginatedSearchOptions) => this.collectionDataService.findAll(searchOptions)) switchMap((searchOptions: PaginatedSearchOptions) => {
); return this.searchService.search(Object.assign(searchOptions, {
dsoType: DSpaceObjectType.COLLECTION
}));
}),
toDSpaceObjectListRD()
) as Observable<RemoteData<PaginatedList<Collection>>>;
} }
/** /**

View File

@@ -1,4 +1,4 @@
import { filter, take } from 'rxjs/operators'; import { filter, take, tap } from 'rxjs/operators';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { Observable } from 'rxjs/Observable'; import { Observable } from 'rxjs/Observable';
import { hasValue, isNotEmpty } from '../../shared/empty.util'; import { hasValue, isNotEmpty } from '../../shared/empty.util';
@@ -58,7 +58,7 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
hrefObs.pipe( hrefObs.pipe(
filter((href: string) => hasValue(href)), filter((href: string) => hasValue(href)),
take(1)) take(1), tap((value) => console.log(value)))
.subscribe((href: string) => { .subscribe((href: string) => {
const request = new FindAllRequest(this.requestService.generateRequestId(), href, options); const request = new FindAllRequest(this.requestService.generateRequestId(), href, options);
this.requestService.configure(request); this.requestService.configure(request);