mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Merge branch 'master' into live-rest-backend
This commit is contained in:
@@ -247,12 +247,12 @@ describe('Pagination component', () => {
|
||||
|
||||
changePage(testFixture, 3);
|
||||
tick();
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith([{pageId: 'test', page: 3, pageSize: 10}]);
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith([], { queryParams: { pageId: 'test', page: 3, pageSize: 10 } });
|
||||
expect(paginationComponent.currentPage).toEqual(3);
|
||||
|
||||
changePageSize(testFixture, '20');
|
||||
tick();
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith([{pageId: 'test', page: 3, pageSize: 20}]);
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith([], { queryParams: { pageId: 'test', page: 3, pageSize: 20 } });
|
||||
expect(paginationComponent.pageSize).toEqual(20);
|
||||
}));
|
||||
|
||||
|
@@ -57,6 +57,11 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
* Current page.
|
||||
*/
|
||||
public currentPage = 1;
|
||||
|
||||
/**
|
||||
* Current URL query parameters
|
||||
*/
|
||||
public currentQueryParams = {};
|
||||
|
||||
/**
|
||||
* An observable of HostWindowState type
|
||||
@@ -121,14 +126,15 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
this.pageSize = this.paginationOptions.pageSize;
|
||||
this.pageSizeOptions = this.paginationOptions.pageSizeOptions;
|
||||
|
||||
this.routeSubscription = this.route.params
|
||||
.map(params => params)
|
||||
.subscribe(params => {
|
||||
if(this.id == params['pageId']
|
||||
&& (this.paginationOptions.currentPage != params['page']
|
||||
|| this.paginationOptions.pageSize != params['pageSize'])
|
||||
this.routeSubscription = this.route.queryParams
|
||||
.map(queryParams => queryParams)
|
||||
.subscribe(queryParams => {
|
||||
this.currentQueryParams = queryParams;
|
||||
if(this.id == queryParams['pageId']
|
||||
&& (this.paginationOptions.currentPage != queryParams['page']
|
||||
|| this.paginationOptions.pageSize != queryParams['pageSize'])
|
||||
) {
|
||||
this.validateParams(params['page'], params['pageSize']);
|
||||
this.validateParams(queryParams['page'], queryParams['pageSize']);
|
||||
}
|
||||
});
|
||||
this.setShowingDetail();
|
||||
@@ -162,7 +168,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
* The page being navigated to.
|
||||
*/
|
||||
public doPageChange(page: number) {
|
||||
this.router.navigate([{ pageId: this.id, page: page, pageSize: this.pageSize }]);
|
||||
this.router.navigate([], { queryParams: Object.assign({}, this.currentQueryParams, { pageId: this.id, page: page, pageSize: this.pageSize }) });
|
||||
this.currentPage = page;
|
||||
this.setShowingDetail();
|
||||
this.pageChange.emit(page);
|
||||
@@ -175,7 +181,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
* The new page size.
|
||||
*/
|
||||
public setPageSize(pageSize: number) {
|
||||
this.router.navigate([{ pageId: this.id, page: this.currentPage, pageSize: pageSize }]);
|
||||
this.router.navigate([], { queryParams: Object.assign({}, this.currentQueryParams, { pageId: this.id, page: this.currentPage, pageSize: pageSize }) });
|
||||
this.pageSize = pageSize;
|
||||
this.setShowingDetail();
|
||||
this.pageSizeChange.emit(pageSize);
|
||||
|
@@ -4,7 +4,6 @@ import { BehaviorSubject } from "rxjs";
|
||||
export class RouterStub {
|
||||
//noinspection TypeScriptUnresolvedFunction
|
||||
navigate = jasmine.createSpy('navigate');
|
||||
//navigate1: jasmine.createSpy('navigate');
|
||||
}
|
||||
|
||||
export class ActivatedRouteStub {
|
||||
@@ -12,6 +11,7 @@ export class ActivatedRouteStub {
|
||||
// ActivatedRoute.params is Observable
|
||||
private subject = new BehaviorSubject(this.testParams);
|
||||
params = this.subject.asObservable();
|
||||
queryParams = this.subject.asObservable();
|
||||
|
||||
constructor(params?: Params) {
|
||||
if (params) {
|
||||
|
@@ -52,6 +52,7 @@ export const BITSTREAMS = {
|
||||
},
|
||||
"id": "8934",
|
||||
"uuid": "ba7d24f2-8fc7-4b8e-b7b6-6c32be1c12a6",
|
||||
"type": "bitstream",
|
||||
"name": "license.txt",
|
||||
"size": 41183,
|
||||
"checksum": {
|
||||
|
@@ -37,6 +37,25 @@ export const BUNDLES = {
|
||||
"metadata": [
|
||||
{ "key": "dc.title", "value": "THUMBNAIL", "language": "en" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"_links": {
|
||||
"self": { "href": "/bundles/8475" },
|
||||
"items": [
|
||||
{ "href": "/items/8871" }
|
||||
],
|
||||
"bitstreams": [
|
||||
{ "href": "/bitstreams/8934" },
|
||||
],
|
||||
"primaryBitstream": { "href": "/bitstreams/8934" }
|
||||
},
|
||||
"id": "8475",
|
||||
"uuid": "99f78e5e-3677-43b0-aaef-cddaa1a49092",
|
||||
"type": "bundle",
|
||||
"name": "LICENSE",
|
||||
"metadata": [
|
||||
{ "key": "dc.title", "value": "LICENSE", "language": "en" }
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
@@ -94,20 +94,7 @@ export const ITEMS = {
|
||||
],
|
||||
"_embedded": {
|
||||
"parents": [
|
||||
{
|
||||
"_links": {
|
||||
"self": { "href": "/collections/5179" },
|
||||
"items": [
|
||||
{ "href": "/items/8871" },
|
||||
{ "href": "/items/9978" }
|
||||
]
|
||||
},
|
||||
"id": "5179",
|
||||
"uuid": "9e32a2e2-6b91-4236-a361-995ccdc14c60",
|
||||
"type": "collection",
|
||||
"name": "A Test Collection",
|
||||
"handle": "123456789/5179",
|
||||
},
|
||||
|
||||
{
|
||||
"_links": {
|
||||
"self": { "href": "/collections/6547" },
|
||||
|
Reference in New Issue
Block a user