mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
55946: Fixed search query not working
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
<div class="col-12 col-lg-6">
|
||||
<ds-search-form id="search-form"
|
||||
[query]="(searchOptions$ | async)?.query"
|
||||
[scope]="(searchOptions$ | async)?.scope"
|
||||
[currentUrl]="getCurrentUrl()">
|
||||
</ds-search-form>
|
||||
</div>
|
||||
|
@@ -33,16 +33,16 @@ import { CollectionDataService } from '../../../core/data/collection-data.servic
|
||||
import { ObjectSelectService } from '../../../shared/object-select/object-select.service';
|
||||
import { ObjectSelectServiceStub } from '../../../shared/testing/object-select-service-stub';
|
||||
|
||||
fdescribe('ItemCollectionMapperComponent', () => {
|
||||
describe('ItemCollectionMapperComponent', () => {
|
||||
let comp: ItemCollectionMapperComponent;
|
||||
let fixture: ComponentFixture<ItemCollectionMapperComponent>;
|
||||
|
||||
let route: ActivatedRoute;
|
||||
let router: Router;
|
||||
let searchConfigService: SearchConfigurationService;
|
||||
let searchService: SearchService;
|
||||
let notificationsService: NotificationsService;
|
||||
let itemDataService: ItemDataService;
|
||||
let collectionDataService: CollectionDataService;
|
||||
|
||||
const mockItem: Item = Object.assign(new Item(), {
|
||||
id: '932c7d50-d85a-44cb-b9dc-b427b12877bd',
|
||||
@@ -69,9 +69,9 @@ fdescribe('ItemCollectionMapperComponent', () => {
|
||||
removeMappingFromCollection: () => Observable.of(new RestResponse(true, '200')),
|
||||
getMappedCollections: () => Observable.of(mockCollectionsRD)
|
||||
};
|
||||
const collectionDataServiceStub = {
|
||||
findAll: () => Observable.of(mockCollectionsRD)
|
||||
};
|
||||
const searchServiceStub = Object.assign(new SearchServiceStub(), {
|
||||
search: () => Observable.of(mockCollectionsRD)
|
||||
});
|
||||
const activatedRouteStub = new ActivatedRouteStub({}, { item: mockItemRD });
|
||||
const translateServiceStub = {
|
||||
get: () => Observable.of('test-message of item ' + mockItem.name),
|
||||
@@ -90,7 +90,7 @@ fdescribe('ItemCollectionMapperComponent', () => {
|
||||
{ provide: SearchConfigurationService, useValue: searchConfigServiceStub },
|
||||
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
|
||||
{ provide: ItemDataService, useValue: itemDataServiceStub },
|
||||
{ provide: CollectionDataService, useValue: collectionDataServiceStub },
|
||||
{ provide: SearchService, useValue: searchServiceStub },
|
||||
{ provide: ObjectSelectService, useValue: new ObjectSelectServiceStub() },
|
||||
{ provide: TranslateService, useValue: translateServiceStub },
|
||||
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) }
|
||||
@@ -107,7 +107,7 @@ fdescribe('ItemCollectionMapperComponent', () => {
|
||||
searchConfigService = (comp as any).searchConfigService;
|
||||
notificationsService = (comp as any).notificationsService;
|
||||
itemDataService = (comp as any).itemDataService;
|
||||
collectionDataService = (comp as any).collectionDataService;
|
||||
searchService = (comp as any).searchService;
|
||||
});
|
||||
|
||||
it('should display the correct collection name', () => {
|
||||
|
@@ -8,7 +8,7 @@ import { RemoteData } from '../../../core/data/remote-data';
|
||||
import { PaginatedList } from '../../../core/data/paginated-list';
|
||||
import { Collection } from '../../../core/shared/collection.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 { SearchService } from '../../../+search-page/search-service/search.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 { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { C } from '@angular/core/src/render3';
|
||||
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-item-collection-mapper',
|
||||
@@ -59,7 +60,7 @@ export class ItemCollectionMapperComponent implements OnInit {
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private searchConfigService: SearchConfigurationService,
|
||||
private collectionDataService: CollectionDataService,
|
||||
private searchService: SearchService,
|
||||
private notificationsService: NotificationsService,
|
||||
private itemDataService: ItemDataService,
|
||||
private translateService: TranslateService) {
|
||||
@@ -82,8 +83,13 @@ export class ItemCollectionMapperComponent implements OnInit {
|
||||
switchMap((item: Item) => this.itemDataService.getMappedCollections(item.id))
|
||||
);
|
||||
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>>>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { filter, take } from 'rxjs/operators';
|
||||
import { filter, take, tap } from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
||||
@@ -58,7 +58,7 @@ export abstract class DataService<TNormalized extends NormalizedObject, TDomain>
|
||||
|
||||
hrefObs.pipe(
|
||||
filter((href: string) => hasValue(href)),
|
||||
take(1))
|
||||
take(1), tap((value) => console.log(value)))
|
||||
.subscribe((href: string) => {
|
||||
const request = new FindAllRequest(this.requestService.generateRequestId(), href, options);
|
||||
this.requestService.configure(request);
|
||||
|
Reference in New Issue
Block a user