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