mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-10 19:43:04 +00:00
removed sorting parameters from RSSComponent
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { GroupDataService } from '../../core/eperson/group-data.service';
|
||||
@@ -23,7 +22,6 @@ import { RouterMock } from '../mocks/router.mock';
|
||||
|
||||
describe('RssComponent', () => {
|
||||
let comp: RSSComponent;
|
||||
let options: SortOptions;
|
||||
let fixture: ComponentFixture<RSSComponent>;
|
||||
let uuid: string;
|
||||
let query: string;
|
||||
@@ -63,7 +61,6 @@ describe('RssComponent', () => {
|
||||
pageSize: 10,
|
||||
currentPage: 1
|
||||
}),
|
||||
sort: new SortOptions('dc.title', SortDirection.ASC),
|
||||
}));
|
||||
groupDataService = jasmine.createSpyObj('groupsDataService', {
|
||||
findListByHref: createSuccessfulRemoteDataObject$(createPaginatedList([])),
|
||||
@@ -88,7 +85,6 @@ describe('RssComponent', () => {
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
options = new SortOptions('dc.title', SortDirection.DESC);
|
||||
uuid = '2cfcf65e-0a51-4bcb-8592-b8db7b064790';
|
||||
query = 'test';
|
||||
fixture = TestBed.createComponent(RSSComponent);
|
||||
@@ -96,18 +92,18 @@ describe('RssComponent', () => {
|
||||
});
|
||||
|
||||
it('should formulate the correct url given params in url', () => {
|
||||
const route = comp.formulateRoute(uuid, 'opensearch/search', options, query);
|
||||
expect(route).toBe('/opensearch/search?format=atom&scope=2cfcf65e-0a51-4bcb-8592-b8db7b064790&sort=dc.title&sort_direction=DESC&query=test');
|
||||
const route = comp.formulateRoute(uuid, 'opensearch/search', query);
|
||||
expect(route).toBe('/opensearch/search?format=atom&scope=2cfcf65e-0a51-4bcb-8592-b8db7b064790&query=test');
|
||||
});
|
||||
|
||||
it('should skip uuid if its null', () => {
|
||||
const route = comp.formulateRoute(null, 'opensearch/search', options, query);
|
||||
expect(route).toBe('/opensearch/search?format=atom&sort=dc.title&sort_direction=DESC&query=test');
|
||||
const route = comp.formulateRoute(null, 'opensearch/search', query);
|
||||
expect(route).toBe('/opensearch/search?format=atom&query=test');
|
||||
});
|
||||
|
||||
it('should default to query * if none provided', () => {
|
||||
const route = comp.formulateRoute(null, 'opensearch/search', options, null);
|
||||
expect(route).toBe('/opensearch/search?format=atom&sort=dc.title&sort_direction=DESC&query=*');
|
||||
const route = comp.formulateRoute(null, 'opensearch/search', null);
|
||||
expect(route).toBe('/opensearch/search?format=atom&query=*');
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -12,7 +12,6 @@ import { ConfigurationDataService } from '../../core/data/configuration-data.ser
|
||||
import { getFirstCompletedRemoteData } from '../../core/shared/operators';
|
||||
import { environment } from '../../../../src/environments/environment';
|
||||
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
|
||||
import { SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { Router } from '@angular/router';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
@@ -39,7 +38,6 @@ export class RSSComponent implements OnInit, OnDestroy {
|
||||
|
||||
uuid: string;
|
||||
configuration$: Observable<string>;
|
||||
sortOption$: Observable<SortOptions>;
|
||||
|
||||
subs: Subscription[] = [];
|
||||
|
||||
@@ -93,7 +91,7 @@ export class RSSComponent implements OnInit, OnDestroy {
|
||||
return null;
|
||||
}
|
||||
this.uuid = this.groupDataService.getUUIDFromString(this.router.url);
|
||||
const route = environment.rest.baseUrl + this.formulateRoute(this.uuid, openSearchUri, searchOptions.sort, searchOptions.query);
|
||||
const route = environment.rest.baseUrl + this.formulateRoute(this.uuid, openSearchUri, searchOptions.query);
|
||||
this.addLinks(route);
|
||||
this.linkHeadService.addTag({
|
||||
href: environment.rest.baseUrl + '/' + openSearchUri + '/service',
|
||||
@@ -109,18 +107,14 @@ export class RSSComponent implements OnInit, OnDestroy {
|
||||
* Function created a route given the different params available to opensearch
|
||||
* @param uuid The uuid if a scope is present
|
||||
* @param opensearch openSearch uri
|
||||
* @param sort The sort options for the opensearch request
|
||||
* @param query The query string that was provided in the search
|
||||
* @returns The combine URL to opensearch
|
||||
*/
|
||||
formulateRoute(uuid: string, opensearch: string, sort: SortOptions, query: string): string {
|
||||
formulateRoute(uuid: string, opensearch: string, query: string): string {
|
||||
let route = '?format=atom';
|
||||
if (uuid) {
|
||||
route += `&scope=${uuid}`;
|
||||
}
|
||||
if (sort && sort.direction && sort.field && sort.field !== 'id') {
|
||||
route += `&sort=${sort.field}&sort_direction=${sort.direction}`;
|
||||
}
|
||||
if (query) {
|
||||
route += `&query=${query}`;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user