Skip to content

Commit 749e1a7

Browse files
authored
Merge pull request DSpace#1934 from TexasDigitalLibrary/DS-1905
DS-1905: fixes route function to match default value of websvc.opensearch.svccontext
2 parents b092d0b + 63011bc commit 749e1a7

2 files changed

Lines changed: 10 additions & 20 deletions

File tree

src/app/shared/rss-feed/rss.component.spec.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2-
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
32
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
43
import { RemoteData } from '../../core/data/remote-data';
54
import { GroupDataService } from '../../core/eperson/group-data.service';
@@ -23,7 +22,6 @@ import { RouterMock } from '../mocks/router.mock';
2322

2423
describe('RssComponent', () => {
2524
let comp: RSSComponent;
26-
let options: SortOptions;
2725
let fixture: ComponentFixture<RSSComponent>;
2826
let uuid: string;
2927
let query: string;
@@ -63,7 +61,6 @@ describe('RssComponent', () => {
6361
pageSize: 10,
6462
currentPage: 1
6563
}),
66-
sort: new SortOptions('dc.title', SortDirection.ASC),
6764
}));
6865
groupDataService = jasmine.createSpyObj('groupsDataService', {
6966
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
@@ -88,26 +85,25 @@ describe('RssComponent', () => {
8885
}));
8986

9087
beforeEach(() => {
91-
options = new SortOptions('dc.title', SortDirection.DESC);
9288
uuid = '2cfcf65e-0a51-4bcb-8592-b8db7b064790';
9389
query = 'test';
9490
fixture = TestBed.createComponent(RSSComponent);
9591
comp = fixture.componentInstance;
9692
});
9793

9894
it('should formulate the correct url given params in url', () => {
99-
const route = comp.formulateRoute(uuid, 'opensearch', options, query);
100-
expect(route).toBe('/opensearch/search?format=atom&scope=2cfcf65e-0a51-4bcb-8592-b8db7b064790&sort=dc.title&sort_direction=DESC&query=test');
95+
const route = comp.formulateRoute(uuid, 'opensearch/search', query);
96+
expect(route).toBe('/opensearch/search?format=atom&scope=2cfcf65e-0a51-4bcb-8592-b8db7b064790&query=test');
10197
});
10298

10399
it('should skip uuid if its null', () => {
104-
const route = comp.formulateRoute(null, 'opensearch', options, query);
105-
expect(route).toBe('/opensearch/search?format=atom&sort=dc.title&sort_direction=DESC&query=test');
100+
const route = comp.formulateRoute(null, 'opensearch/search', query);
101+
expect(route).toBe('/opensearch/search?format=atom&query=test');
106102
});
107103

108104
it('should default to query * if none provided', () => {
109-
const route = comp.formulateRoute(null, 'opensearch', options, null);
110-
expect(route).toBe('/opensearch/search?format=atom&sort=dc.title&sort_direction=DESC&query=*');
105+
const route = comp.formulateRoute(null, 'opensearch/search', null);
106+
expect(route).toBe('/opensearch/search?format=atom&query=*');
111107
});
112108
});
113109

src/app/shared/rss-feed/rss.component.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { ConfigurationDataService } from '../../core/data/configuration-data.ser
1212
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
1313
import { environment } from '../../../../src/environments/environment';
1414
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
15-
import { SortOptions } from '../../core/cache/models/sort-options.model';
1615
import { PaginationService } from '../../core/pagination/pagination.service';
1716
import { Router } from '@angular/router';
1817
import { map, switchMap } from 'rxjs/operators';
@@ -39,7 +38,6 @@ export class RSSComponent implements OnInit, OnDestroy {
3938

4039
uuid: string;
4140
configuration$: Observable<string>;
42-
sortOption$: Observable<SortOptions>;
4341

4442
subs: Subscription[] = [];
4543

@@ -93,7 +91,7 @@ export class RSSComponent implements OnInit, OnDestroy {
9391
return null;
9492
}
9593
this.uuid = this.groupDataService.getUUIDFromString(this.router.url);
96-
const route = environment.rest.baseUrl + this.formulateRoute(this.uuid, openSearchUri, searchOptions.sort, searchOptions.query);
94+
const route = environment.rest.baseUrl + this.formulateRoute(this.uuid, openSearchUri, searchOptions.query);
9795
this.addLinks(route);
9896
this.linkHeadService.addTag({
9997
href: environment.rest.baseUrl + '/' + openSearchUri + '/service',
@@ -109,24 +107,20 @@ export class RSSComponent implements OnInit, OnDestroy {
109107
* Function created a route given the different params available to opensearch
110108
* @param uuid The uuid if a scope is present
111109
* @param opensearch openSearch uri
112-
* @param sort The sort options for the opensearch request
113110
* @param query The query string that was provided in the search
114111
* @returns The combine URL to opensearch
115112
*/
116-
formulateRoute(uuid: string, opensearch: string, sort: SortOptions, query: string): string {
117-
let route = 'search?format=atom';
113+
formulateRoute(uuid: string, opensearch: string, query: string): string {
114+
let route = '?format=atom';
118115
if (uuid) {
119116
route += `&scope=${uuid}`;
120117
}
121-
if (sort && sort.direction && sort.field && sort.field !== 'id') {
122-
route += `&sort=${sort.field}&sort_direction=${sort.direction}`;
123-
}
124118
if (query) {
125119
route += `&query=${query}`;
126120
} else {
127121
route += `&query=*`;
128122
}
129-
route = '/' + opensearch + '/' + route;
123+
route = '/' + opensearch + route;
130124
return route;
131125
}
132126

0 commit comments

Comments
 (0)