pageSize}"
diff --git a/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.ts b/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.ts
index bb77bfc0c4..0941a4dfd6 100644
--- a/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.ts
+++ b/src/app/+item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.ts
@@ -10,6 +10,7 @@ import { ResponsiveTableSizes } from '../../../../../shared/responsive-table-siz
import { followLink } from '../../../../../shared/utils/follow-link-config.model';
import { ObjectValuesPipe } from '../../../../../shared/utils/object-values-pipe';
import { RequestService } from '../../../../../core/data/request.service';
+import { PaginationService } from '../../../../../core/pagination/pagination.service';
@Component({
selector: 'ds-paginated-drag-and-drop-bitstream-list',
@@ -37,8 +38,9 @@ export class PaginatedDragAndDropBitstreamListComponent extends AbstractPaginate
protected elRef: ElementRef,
protected objectValuesPipe: ObjectValuesPipe,
protected bundleService: BundleDataService,
+ protected paginationService: PaginationService,
protected requestService: RequestService) {
- super(objectUpdatesService, elRef, objectValuesPipe);
+ super(objectUpdatesService, elRef, objectValuesPipe, paginationService);
}
ngOnInit() {
diff --git a/src/app/+my-dspace-page/my-dspace-configuration.service.ts b/src/app/+my-dspace-page/my-dspace-configuration.service.ts
index 58946c9c16..19eba0fa06 100644
--- a/src/app/+my-dspace-page/my-dspace-configuration.service.ts
+++ b/src/app/+my-dspace-page/my-dspace-configuration.service.ts
@@ -11,6 +11,7 @@ import { SearchConfigurationService } from '../core/shared/search/search-configu
import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model';
import { SortDirection, SortOptions } from '../core/cache/models/sort-options.model';
import { RouteService } from '../core/services/route.service';
+import { PaginationService } from '../core/pagination/pagination.service';
/**
* Service that performs all actions that have to do with the current mydspace configuration
@@ -59,9 +60,10 @@ export class MyDSpaceConfigurationService extends SearchConfigurationService {
*/
constructor(protected roleService: RoleService,
protected routeService: RouteService,
+ protected paginationService: PaginationService,
protected route: ActivatedRoute) {
- super(routeService, route);
+ super(routeService, paginationService, route);
// override parent class initialization
this._defaults = null;
diff --git a/src/app/core/pagination/pagination.service.ts b/src/app/core/pagination/pagination.service.ts
new file mode 100644
index 0000000000..35b38b23f7
--- /dev/null
+++ b/src/app/core/pagination/pagination.service.ts
@@ -0,0 +1,190 @@
+import { Injectable } from '@angular/core';
+import { ActivatedRoute, Router } from '@angular/router';
+import { RouteService } from '../services/route.service';
+import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
+import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
+import { filter, map, take } from 'rxjs/operators';
+import { SortDirection, SortOptions } from '../cache/models/sort-options.model';
+import { FindListOptions } from '../data/request.models';
+import { hasValue, isEmpty, isNotEmpty } from '../../shared/empty.util';
+import { difference } from '../../shared/object.util';
+import { isNumeric } from 'rxjs/internal-compatibility';
+import { Location } from '@angular/common';
+
+
+@Injectable({
+ providedIn: 'root',
+})
+export class PaginationService {
+
+ private defaultSortOptions = new SortOptions('id', SortDirection.ASC);
+
+ constructor(protected routeService: RouteService,
+ protected route: ActivatedRoute,
+ protected router: Router,
+ protected location: Location
+ ) {
+ }
+
+ /**
+ * @returns {Observable
} Emits the current pagination settings
+ */
+ getCurrentPagination(paginationId: string, defaultPagination: PaginationComponentOptions): Observable {
+ const page$ = this.routeService.getQueryParameterValue(`p.${paginationId}`);
+ const size$ = this.routeService.getQueryParameterValue(`rpp.${paginationId}`);
+ return observableCombineLatest([page$, size$]).pipe(map(([page, size]) => {
+ return Object.assign(new PaginationComponentOptions(), defaultPagination, {
+ currentPage: this.convertToNumeric(page, defaultPagination.currentPage),
+ pageSize: this.getBestMatchPageSize(size, defaultPagination)
+ });
+ })
+ );
+ }
+
+ /**
+ * @returns {Observable} Emits the current sorting settings
+ */
+ getCurrentSort(paginationId: string, defaultSort: SortOptions, ignoreDefault?: boolean): Observable {
+ if (!ignoreDefault && (isEmpty(defaultSort) || !hasValue(defaultSort))) {
+ defaultSort = this.defaultSortOptions;
+ }
+ const sortDirection$ = this.routeService.getQueryParameterValue(`sd.${paginationId}`);
+ const sortField$ = this.routeService.getQueryParameterValue(`sf.${paginationId}`);
+ return observableCombineLatest([sortDirection$, sortField$]).pipe(map(([sortDirection, sortField]) => {
+ const field = sortField || defaultSort?.field;
+ const direction = SortDirection[sortDirection] || defaultSort?.direction;
+ return new SortOptions(field, direction);
+ })
+ );
+ }
+
+ getFindListOptions(paginationId: string, defaultFindList: FindListOptions, ignoreDefault?: boolean): Observable {
+ const paginationComponentOptions = new PaginationComponentOptions();
+ paginationComponentOptions.currentPage = defaultFindList.currentPage;
+ paginationComponentOptions.pageSize = defaultFindList.elementsPerPage;
+ const currentPagination$ = this.getCurrentPagination(paginationId, paginationComponentOptions);
+ const currentSortOptions$ = this.getCurrentSort(paginationId, defaultFindList.sort, ignoreDefault);
+
+ return observableCombineLatest([currentPagination$, currentSortOptions$]).pipe(
+ filter(([currentPagination, currentSortOptions]) => hasValue(currentPagination) && hasValue(currentSortOptions)),
+ map(([currentPagination, currentSortOptions]) => {
+ return Object.assign(new FindListOptions(), defaultFindList, {
+ sort: currentSortOptions,
+ currentPage: currentPagination.currentPage,
+ elementsPerPage: currentPagination.pageSize
+ });
+ }));
+ }
+
+ resetPage(paginationId: string) {
+ this.updateRoute(paginationId, {page: 1});
+ }
+
+ getCurrentRouting(paginationId: string) {
+ return this.getFindListOptions(paginationId, {}, true).pipe(
+ take(1),
+ map((findListoptions: FindListOptions) => {
+ return {
+ page: findListoptions.currentPage,
+ pageSize: findListoptions.elementsPerPage,
+ sortField: findListoptions.sort.field,
+ sortDir: findListoptions.sort.direction,
+ };
+ })
+ );
+ }
+
+ updateRoute(paginationId: string, params: {
+ page?: number
+ pageSize?: number
+ sortField?: string
+ sortDirection?: SortDirection
+ }, extraParams?, changeLocationNot?: boolean) {
+ this.getCurrentRouting(paginationId).subscribe((currentFindListOptions) => {
+ const currentParametersWithIdName = this.getParametersWithIdName(paginationId, currentFindListOptions);
+ const parametersWithIdName = this.getParametersWithIdName(paginationId, params);
+ if (isNotEmpty(difference(parametersWithIdName, currentParametersWithIdName)) || isNotEmpty(extraParams)) {
+ const queryParams = Object.assign({}, currentParametersWithIdName,
+ parametersWithIdName, extraParams);
+ if (changeLocationNot) {
+ this.location.go(this.router.createUrlTree([], {
+ relativeTo: this.route, queryParams: queryParams, queryParamsHandling: 'merge'
+ }).toString());
+ } else {
+ this.router.navigate([], {
+ queryParams: queryParams,
+ queryParamsHandling: 'merge'
+ });
+ }
+ }
+ });
+ }
+
+ updateRouteWithUrl(paginationId: string, url: string[], params: {
+ page?: number
+ pageSize?: number
+ sortField?: string
+ sortDirection?: SortDirection
+ }, extraParams?, changeLocationNot?: boolean) {
+ this.getCurrentRouting(paginationId).subscribe((currentFindListOptions) => {
+ const currentParametersWithIdName = this.getParametersWithIdName(paginationId, currentFindListOptions);
+ const parametersWithIdName = this.getParametersWithIdName(paginationId, params);
+ if (isNotEmpty(difference(parametersWithIdName, currentParametersWithIdName)) || isNotEmpty(extraParams)) {
+ const queryParams = Object.assign({}, currentParametersWithIdName,
+ parametersWithIdName, extraParams);
+ if (changeLocationNot) {
+ this.location.go(this.router.createUrlTree([], {
+ relativeTo: this.route, queryParams: queryParams, queryParamsHandling: 'merge'
+ }).toString());
+ } else {
+ this.router.navigate(url, {
+ queryParams: queryParams,
+ queryParamsHandling: 'merge'
+ });
+ }
+ }
+ });
+ }
+
+
+ getParametersWithIdName(paginationId: string, params: {
+ page?: number
+ pageSize?: number
+ sortField?: string
+ sortDirection?: SortDirection
+ }) {
+ const paramsWithIdName = {};
+ if (hasValue(params.page)) {
+ paramsWithIdName[`p.${paginationId}`] = `${params.page}`;
+ }
+ if (hasValue(params.pageSize)) {
+ paramsWithIdName[`rpp.${paginationId}`] = `${params.pageSize}`;
+ }
+ if (hasValue(params.sortField)) {
+ paramsWithIdName[`sf.${paginationId}`] = `${params.sortField}`;
+ }
+ if (hasValue(params.sortDirection)) {
+ paramsWithIdName[`sd.${paginationId}`] = `${params.sortDirection}`;
+ }
+ return paramsWithIdName;
+ }
+
+ private convertToNumeric(param, defaultValue) {
+ let result = defaultValue;
+ if (isNumeric(param)) {
+ result = +param;
+ }
+ return result;
+ }
+
+
+ private getBestMatchPageSize(pageSize: any, defaultPagination: PaginationComponentOptions): number {
+ const numberPageSize = this.convertToNumeric(pageSize, defaultPagination.pageSize);
+ const differenceList = defaultPagination.pageSizeOptions.map((pageSizeOption) => {
+ return Math.abs(pageSizeOption - numberPageSize);
+ });
+ const minDifference = Math.min.apply(Math, differenceList);
+ return defaultPagination.pageSizeOptions[differenceList.indexOf(minDifference)];
+ }
+
+}
diff --git a/src/app/core/shared/search/search-configuration.service.ts b/src/app/core/shared/search/search-configuration.service.ts
index edd3982319..6639b53cb9 100644
--- a/src/app/core/shared/search/search-configuration.service.ts
+++ b/src/app/core/shared/search/search-configuration.service.ts
@@ -14,17 +14,21 @@ import { RouteService } from '../../services/route.service';
import { getFirstSucceededRemoteData } from '../operators';
import { hasNoValue, hasValue, isNotEmpty, isNotEmptyOperator } from '../../../shared/empty.util';
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
+import { PaginationService } from '../../pagination/pagination.service';
+import { tap } from 'rxjs/internal/operators/tap';
/**
* Service that performs all actions that have to do with the current search configuration
*/
@Injectable()
export class SearchConfigurationService implements OnDestroy {
+
+ public paginationID = 'spc';
/**
* Default pagination settings
*/
protected defaultPagination = Object.assign(new PaginationComponentOptions(), {
- id: 'search-page-configuration',
+ id: this.paginationID,
pageSize: 10,
currentPage: 1
});
@@ -75,6 +79,7 @@ export class SearchConfigurationService implements OnDestroy {
* @param {ActivatedRoute} route
*/
constructor(protected routeService: RouteService,
+ protected paginationService: PaginationService,
protected route: ActivatedRoute) {
this.initDefaults();
@@ -91,7 +96,7 @@ export class SearchConfigurationService implements OnDestroy {
this.paginatedSearchOptions = new BehaviorSubject(defs);
this.searchOptions = new BehaviorSubject(defs);
this.subs.push(this.subscribeToSearchOptions(defs));
- this.subs.push(this.subscribeToPaginatedSearchOptions(defs));
+ this.subs.push(this.subscribeToPaginatedSearchOptions(defs.pagination.id, defs));
}
);
}
@@ -140,34 +145,15 @@ export class SearchConfigurationService implements OnDestroy {
/**
* @returns {Observable} Emits the current pagination settings
*/
- getCurrentPagination(defaultPagination: PaginationComponentOptions): Observable {
- const page$ = this.routeService.getQueryParameterValue('page');
- const size$ = this.routeService.getQueryParameterValue('pageSize');
- return observableCombineLatest(page$, size$).pipe(map(([page, size]) => {
- return Object.assign(new PaginationComponentOptions(), defaultPagination, {
- currentPage: page || defaultPagination.currentPage,
- pageSize: size || defaultPagination.pageSize
- });
- })
- );
+ getCurrentPagination(paginationId: string, defaultPagination: PaginationComponentOptions): Observable {
+ return this.paginationService.getCurrentPagination(paginationId, defaultPagination);
}
/**
* @returns {Observable} Emits the current sorting settings
*/
- getCurrentSort(defaultSort: SortOptions): Observable {
- const sortDirection$ = this.routeService.getQueryParameterValue('sortDirection');
- const sortField$ = this.routeService.getQueryParameterValue('sortField');
- return observableCombineLatest(sortDirection$, sortField$).pipe(map(([sortDirection, sortField]) => {
- // Dirty fix because sometimes the observable value is null somehow
- sortField = this.route.snapshot.queryParamMap.get('sortField');
-
- const field = sortField || defaultSort.field;
- const direction = SortDirection[sortDirection] || defaultSort.direction;
- return new SortOptions(field, direction);
- }
- )
- );
+ getCurrentSort(paginationId: string, defaultSort: SortOptions): Observable {
+ return this.paginationService.getCurrentSort(paginationId, defaultSort);
}
/**
@@ -234,10 +220,10 @@ export class SearchConfigurationService implements OnDestroy {
* @param {PaginatedSearchOptions} defaults Default values for when no parameters are available
* @returns {Subscription} The subscription to unsubscribe from
*/
- private subscribeToPaginatedSearchOptions(defaults: PaginatedSearchOptions): Subscription {
+ private subscribeToPaginatedSearchOptions(paginationId: string, defaults: PaginatedSearchOptions): Subscription {
return observableMerge(
- this.getPaginationPart(defaults.pagination),
- this.getSortPart(defaults.sort),
+ this.getPaginationPart(paginationId, defaults.pagination),
+ this.getSortPart(paginationId, defaults.sort),
this.getConfigurationPart(defaults.configuration),
this.getScopePart(defaults.scope),
this.getQueryPart(defaults.query),
@@ -317,8 +303,8 @@ export class SearchConfigurationService implements OnDestroy {
/**
* @returns {Observable} Emits the current pagination settings as a partial SearchOptions object
*/
- private getPaginationPart(defaultPagination: PaginationComponentOptions): Observable {
- return this.getCurrentPagination(defaultPagination).pipe(map((pagination) => {
+ private getPaginationPart(paginationId: string, defaultPagination: PaginationComponentOptions): Observable {
+ return this.getCurrentPagination(paginationId, defaultPagination).pipe(map((pagination) => {
return { pagination };
}));
}
@@ -326,8 +312,8 @@ export class SearchConfigurationService implements OnDestroy {
/**
* @returns {Observable} Emits the current sorting settings as a partial SearchOptions object
*/
- private getSortPart(defaultSort: SortOptions): Observable {
- return this.getCurrentSort(defaultSort).pipe(map((sort) => {
+ private getSortPart(paginationId: string, defaultSort: SortOptions): Observable {
+ return this.getCurrentSort(paginationId, defaultSort).pipe(map((sort) => {
return { sort };
}));
}
diff --git a/src/app/core/shared/search/search.service.ts b/src/app/core/shared/search/search.service.ts
index b380a70d44..4dfd1964c3 100644
--- a/src/app/core/shared/search/search.service.ts
+++ b/src/app/core/shared/search/search.service.ts
@@ -1,7 +1,7 @@
import { combineLatest as observableCombineLatest, Observable, of as observableOf } from 'rxjs';
import { Injectable, OnDestroy } from '@angular/core';
-import { NavigationExtras, Router } from '@angular/router';
-import { first, map, switchMap, take } from 'rxjs/operators';
+import { Router } from '@angular/router';
+import { map, switchMap, take } from 'rxjs/operators';
import { followLink, FollowLinkConfig } from '../../../shared/utils/follow-link-config.model';
import { LinkService } from '../../cache/builders/link.service';
import { PaginatedList } from '../../data/paginated-list.model';
@@ -37,6 +37,10 @@ import { ListableObject } from '../../../shared/object-collection/shared/listabl
import { getSearchResultFor } from '../../../shared/search/search-result-element-decorator';
import { FacetConfigResponse } from '../../../shared/search/facet-config-response.model';
import { FacetValues } from '../../../shared/search/facet-values.model';
+import { PaginationService } from '../../pagination/pagination.service';
+import { SearchConfigurationService } from './search-configuration.service';
+import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
+import { tap } from 'rxjs/internal/operators/tap';
/**
* Service that performs all general actions that have to do with the search page
@@ -75,7 +79,9 @@ export class SearchService implements OnDestroy {
private linkService: LinkService,
private halService: HALEndpointService,
private communityService: CommunityDataService,
- private dspaceObjectService: DSpaceObjectDataService
+ private dspaceObjectService: DSpaceObjectDataService,
+ private paginationService: PaginationService,
+ private searchConfigurationService: SearchConfigurationService
) {
}
@@ -380,20 +386,16 @@ export class SearchService implements OnDestroy {
* @param {ViewMode} viewMode Mode to switch to
*/
setViewMode(viewMode: ViewMode, searchLinkParts?: string[]) {
- this.routeService.getQueryParameterValue('pageSize').pipe(first())
- .subscribe((pageSize) => {
- let queryParams = { view: viewMode, page: 1 };
+ this.paginationService.getCurrentPagination(this.searchConfigurationService.paginationID, new PaginationComponentOptions()).pipe(take(1))
+ .subscribe((config) => {
+ let pageParams = { page: 1 };
+ const queryParams = { view: viewMode };
if (viewMode === ViewMode.DetailedListElement) {
- queryParams = Object.assign(queryParams, {pageSize: '1'});
- } else if (pageSize === '1') {
- queryParams = Object.assign(queryParams, {pageSize: '10'});
+ pageParams = Object.assign(pageParams, {pageSize: 1});
+ } else if (config.pageSize === 1) {
+ pageParams = Object.assign(pageParams, {pageSize: 10});
}
- const navigationExtras: NavigationExtras = {
- queryParams: queryParams,
- queryParamsHandling: 'merge'
- };
-
- this.router.navigate(hasValue(searchLinkParts) ? searchLinkParts : [this.getSearchLink()], navigationExtras);
+ this.paginationService.updateRouteWithUrl(this.searchConfigurationService.paginationID, hasValue(searchLinkParts) ? searchLinkParts : [this.getSearchLink()], pageParams, queryParams);
});
}
diff --git a/src/app/process-page/overview/process-overview.component.html b/src/app/process-page/overview/process-overview.component.html
index 30eb44430e..62b1433b2c 100644
--- a/src/app/process-page/overview/process-overview.component.html
+++ b/src/app/process-page/overview/process-overview.component.html
@@ -8,8 +8,7 @@
[pageInfoState]="(processesRD$ | async)?.payload"
[collectionSize]="(processesRD$ | async)?.payload?.totalElements"
[hideGear]="true"
- [hidePagerWhenSinglePage]="true"
- (pageChange)="onPageChange($event)">
+ [hidePagerWhenSinglePage]="true">
diff --git a/src/app/process-page/overview/process-overview.component.ts b/src/app/process-page/overview/process-overview.component.ts
index 541d6c212e..1ea8c5b9c6 100644
--- a/src/app/process-page/overview/process-overview.component.ts
+++ b/src/app/process-page/overview/process-overview.component.ts
@@ -8,8 +8,9 @@ import { FindListOptions } from '../../core/data/request.models';
import { EPersonDataService } from '../../core/eperson/eperson-data.service';
import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
import { EPerson } from '../../core/eperson/models/eperson.model';
-import { map } from 'rxjs/operators';
+import { map, switchMap } from 'rxjs/operators';
import { ProcessDataService } from '../../core/data/processes/process-data.service';
+import { PaginationService } from '../../core/pagination/pagination.service';
@Component({
selector: 'ds-process-overview',
@@ -36,7 +37,7 @@ export class ProcessOverviewComponent implements OnInit {
* The current pagination configuration for the page
*/
pageConfig: PaginationComponentOptions = Object.assign(new PaginationComponentOptions(), {
- id: 'process-overview-pagination',
+ id: 'po',
pageSize: 20
});
@@ -46,6 +47,7 @@ export class ProcessOverviewComponent implements OnInit {
dateFormat = 'yyyy-MM-dd HH:mm:ss';
constructor(protected processService: ProcessDataService,
+ protected paginationService: PaginationService,
protected ePersonService: EPersonDataService) {
}
@@ -53,23 +55,13 @@ export class ProcessOverviewComponent implements OnInit {
this.setProcesses();
}
- /**
- * When the page is changed, make sure to update the list of processes to match the new page
- * @param event The page change event
- */
- onPageChange(event) {
- this.config = Object.assign(new FindListOptions(), this.config, {
- currentPage: event,
- });
- this.pageConfig.currentPage = event;
- this.setProcesses();
- }
-
/**
* Send a request to fetch all processes for the current page
*/
setProcesses() {
- this.processesRD$ = this.processService.findAll(this.config);
+ this.processesRD$ = this.paginationService.getFindListOptions(this.pageConfig.id, this.config).pipe(
+ switchMap((config) => this.processService.findAll(config))
+ );
}
/**
diff --git a/src/app/search-navbar/search-navbar.component.ts b/src/app/search-navbar/search-navbar.component.ts
index 1bedfb73ef..1e509a180b 100644
--- a/src/app/search-navbar/search-navbar.component.ts
+++ b/src/app/search-navbar/search-navbar.component.ts
@@ -3,6 +3,8 @@ import { FormBuilder } from '@angular/forms';
import { Router } from '@angular/router';
import { SearchService } from '../core/shared/search/search.service';
import { expandSearchInput } from '../shared/animations/slide';
+import { PaginationService } from '../core/pagination/pagination.service';
+import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
/**
* The search box in the header that expands on focus and collapses on focus out
@@ -24,7 +26,9 @@ export class SearchNavbarComponent {
// Search input field
@ViewChild('searchInput') searchField: ElementRef;
- constructor(private formBuilder: FormBuilder, private router: Router, private searchService: SearchService) {
+ constructor(private formBuilder: FormBuilder, private router: Router, private searchService: SearchService,
+ private paginationService: PaginationService,
+ private searchConfig: SearchConfigurationService) {
this.searchForm = this.formBuilder.group(({
query: '',
}));
@@ -63,9 +67,6 @@ export class SearchNavbarComponent {
this.collapse();
const linkToNavigateTo = this.searchService.getSearchLink().split('/');
this.searchForm.reset();
- this.router.navigate(linkToNavigateTo, {
- queryParams: Object.assign({}, { page: 1 }, data),
- queryParamsHandling: 'merge'
- });
+ this.paginationService.updateRouteWithUrl(this.searchConfig.paginationID, linkToNavigateTo, {page: 1}, data);
}
}
diff --git a/src/app/shared/browse-by/browse-by.component.ts b/src/app/shared/browse-by/browse-by.component.ts
index 8706c39e54..8920726c8b 100644
--- a/src/app/shared/browse-by/browse-by.component.ts
+++ b/src/app/shared/browse-by/browse-by.component.ts
@@ -7,6 +7,7 @@ import { fadeIn, fadeInOut } from '../animations/fade';
import { Observable } from 'rxjs';
import { ListableObject } from '../object-collection/shared/listable-object.model';
import { getStartsWithComponent, StartsWithType } from '../starts-with/starts-with-decorator';
+import { PaginationService } from '../../core/pagination/pagination.service';
@Component({
selector: 'ds-browse-by',
@@ -96,7 +97,9 @@ export class BrowseByComponent implements OnInit {
*/
public sortDirections = SortDirection;
- public constructor(private injector: Injector) {
+ public constructor(private injector: Injector,
+ protected paginationService: PaginationService,
+ ) {
}
@@ -119,8 +122,7 @@ export class BrowseByComponent implements OnInit {
* @param size
*/
doPageSizeChange(size) {
- this.paginationConfig.pageSize = size;
- this.pageSizeChange.emit(size);
+ this.paginationService.updateRoute(this.paginationConfig.id,{pageSize: size});
}
/**
@@ -128,8 +130,7 @@ export class BrowseByComponent implements OnInit {
* @param direction
*/
doSortDirectionChange(direction) {
- this.sortConfig.direction = direction;
- this.sortDirectionChange.emit(direction);
+ this.paginationService.updateRoute(this.paginationConfig.id,{sortDirection: direction});
}
/**
@@ -141,7 +142,10 @@ export class BrowseByComponent implements OnInit {
ngOnInit(): void {
this.objectInjector = Injector.create({
- providers: [{ provide: 'startsWithOptions', useFactory: () => (this.startsWithOptions), deps:[] }],
+ providers: [
+ { provide: 'startsWithOptions', useFactory: () => (this.startsWithOptions), deps:[] },
+ { provide: 'paginationId', useFactory: () => (this.paginationConfig.id), deps:[] }
+ ],
parent: this.injector
});
}
diff --git a/src/app/shared/page-size-selector/page-size-selector.component.ts b/src/app/shared/page-size-selector/page-size-selector.component.ts
index dfea7d423f..764a8063db 100644
--- a/src/app/shared/page-size-selector/page-size-selector.component.ts
+++ b/src/app/shared/page-size-selector/page-size-selector.component.ts
@@ -1,11 +1,12 @@
import { Component, Inject, OnInit } from '@angular/core';
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
import { Observable } from 'rxjs';
-import { ActivatedRoute, NavigationExtras, Router } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component';
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
import { PaginatedSearchOptions } from '../search/paginated-search-options.model';
-import { map } from 'rxjs/operators';
+import { map, take } from 'rxjs/operators';
+import { PaginationService } from '../../core/pagination/pagination.service';
@Component({
selector: 'ds-page-size-selector',
@@ -22,8 +23,10 @@ export class PageSizeSelectorComponent implements OnInit {
*/
paginationOptions$: Observable;
+
constructor(private route: ActivatedRoute,
private router: Router,
+ private paginationService: PaginationService,
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigurationService: SearchConfigurationService) {
}
@@ -40,13 +43,10 @@ export class PageSizeSelectorComponent implements OnInit {
*/
reloadRPP(event: Event) {
const value = (event.target as HTMLInputElement).value;
- const navigationExtras: NavigationExtras = {
- queryParams: {
- pageSize: value,
- page: 1
- },
- queryParamsHandling: 'merge'
- };
- this.router.navigate([], navigationExtras);
+ this.paginationOptions$.pipe(
+ take(1)
+ ).subscribe((pagination: PaginationComponentOptions) => {
+ this.paginationService.updateRoute(pagination.id, {page: 1, pageSize: +value});
+ }) ;
}
}
diff --git a/src/app/shared/pagination-drag-and-drop/abstract-paginated-drag-and-drop-list.component.ts b/src/app/shared/pagination-drag-and-drop/abstract-paginated-drag-and-drop-list.component.ts
index 4cc647d091..3b5d8bc3de 100644
--- a/src/app/shared/pagination-drag-and-drop/abstract-paginated-drag-and-drop-list.component.ts
+++ b/src/app/shared/pagination-drag-and-drop/abstract-paginated-drag-and-drop-list.component.ts
@@ -17,6 +17,7 @@ import { Component, ElementRef, EventEmitter, OnDestroy, Output, ViewChild } fro
import { PaginationComponent } from '../pagination/pagination.component';
import { ObjectValuesPipe } from '../utils/object-values-pipe';
import { compareArraysUsing } from '../../+item-page/simple/item-types/shared/item-relationships-utils';
+import { PaginationService } from '../../core/pagination/pagination.service';
/**
* Operator used for comparing {@link FieldUpdate}s by their field's UUID
@@ -81,14 +82,14 @@ export abstract class AbstractPaginatedDragAndDropListComponent {
+ this.currentPage$.next(currentPagination.currentPage);
+ });
+ }
+
/**
* Initialize the field-updates in the store
*/
@@ -164,14 +177,6 @@ export abstract class AbstractPaginatedDragAndDropListComponent
+
0) || !hideGear" class="pagination-masked clearfix top">
0" class="col-auto pagination-info">
{{ 'pagination.showing.label' | translate }}
- {{ 'pagination.showing.detail' | translate:getShowingDetails(collectionSize)}}
+ {{ 'pagination.showing.detail' | translate:(getShowingDetails(collectionSize)|async)}}
@@ -20,15 +20,15 @@
-