diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html
index d55cdbffed..61be99cbf2 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html
@@ -14,14 +14,14 @@
0" @fadeIn
[objects]="entriesRD"
[selectionConfig]="{ repeatable: repeatable, listId: listId }"
- [config]="initialPagination"
+ [config]="(currentPagination$ |async)"
[hideGear]="true"
[context]="context"
[importable]="true"
[importConfig]="importConfig"
(importObject)="import($event)">
-
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.spec.ts
index 961a826530..6309b74792 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.spec.ts
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.spec.ts
@@ -24,6 +24,8 @@ import { Collection } from '../../../../../../core/shared/collection.model';
import { RelationshipOptions } from '../../../models/relationship-options.model';
import { ExternalSourceEntryImportModalComponent } from './external-source-entry-import-modal/external-source-entry-import-modal.component';
import { createPaginatedList } from '../../../../../testing/utils.test';
+import { PaginationService } from '../../../../../../core/pagination/pagination.service';
+import { PaginationServiceStub } from '../../../../../testing/pagination-service.stub';
describe('DsDynamicLookupRelationExternalSourceTabComponent', () => {
let component: DsDynamicLookupRelationExternalSourceTabComponent;
@@ -103,7 +105,8 @@ describe('DsDynamicLookupRelationExternalSourceTabComponent', () => {
}
},
{ provide: ExternalSourceService, useValue: externalSourceService },
- { provide: SelectableListService, useValue: selectableListService }
+ { provide: SelectableListService, useValue: selectableListService },
+ { provide: PaginationService, useValue: new PaginationServiceStub() }
],
schemas: [NO_ERRORS_SCHEMA]
}).compileComponents();
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts
index b697dc9280..f0a86fef7c 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts
@@ -3,7 +3,6 @@ import { SEARCH_CONFIG_SERVICE } from '../../../../../../+my-dspace-page/my-dspa
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
import { Router } from '@angular/router';
import { ExternalSourceService } from '../../../../../../core/data/external-source.service';
-import { Observable, Subscription } from 'rxjs';
import { RemoteData } from '../../../../../../core/data/remote-data';
import { PaginatedList } from '../../../../../../core/data/paginated-list.model';
import { ExternalSourceEntry } from '../../../../../../core/shared/external-source-entry.model';
@@ -21,6 +20,8 @@ import { hasValue } from '../../../../../empty.util';
import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service';
import { Item } from '../../../../../../core/shared/item.model';
import { Collection } from '../../../../../../core/shared/collection.model';
+import { PaginationService } from '../../../../../../core/pagination/pagination.service';
+import { Observable, Subscription } from 'rxjs';
@Component({
selector: 'ds-dynamic-lookup-relation-external-source-tab',
@@ -81,10 +82,15 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit
* The initial pagination options
*/
initialPagination = Object.assign(new PaginationComponentOptions(), {
- id: 'submission-external-source-relation-list',
+ id: 'spc',
pageSize: 5
});
+ /**
+ * The current pagination options
+ */
+ currentPagination$: Observable;
+
/**
* The external source we're selecting entries for
*/
@@ -114,17 +120,21 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit
public searchConfigService: SearchConfigurationService,
private externalSourceService: ExternalSourceService,
private modalService: NgbModal,
- private selectableListService: SelectableListService) {
+ private selectableListService: SelectableListService,
+ private paginationService: PaginationService
+ ) {
}
/**
* Get the entries for the selected external source
*/
ngOnInit(): void {
+ this.resetRoute();
this.entriesRD$ = this.searchConfigService.paginatedSearchOptions.pipe(
switchMap((searchOptions: PaginatedSearchOptions) =>
this.externalSourceService.getExternalSourceEntries(this.externalSource.id, searchOptions).pipe(startWith(undefined)))
);
+ this.currentPagination$ = this.paginationService.getCurrentPagination(this.searchConfigService.paginationID, this.initialPagination);
this.importConfig = {
buttonLabel: 'submission.sections.describe.relationship-lookup.external-source.import-button-title.' + this.label
};
@@ -159,4 +169,14 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit
this.importObjectSub.unsubscribe();
}
}
+
+ /**
+ * Method to reset the route when the tab is opened to make sure no strange pagination issues appears
+ */
+ resetRoute() {
+ this.paginationService.updateRoute(this.searchConfigService.paginationID, {
+ page: 1,
+ pageSize: 5
+ });
+ }
}
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts
index 700026ba10..83a8d05217 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts
@@ -17,6 +17,8 @@ import { ItemSearchResult } from '../../../../../object-collection/shared/item-s
import { Item } from '../../../../../../core/shared/item.model';
import { ActivatedRoute } from '@angular/router';
import { LookupRelationService } from '../../../../../../core/data/lookup-relation.service';
+import { PaginationService } from '../../../../../../core/pagination/pagination.service';
+import { PaginationServiceStub } from '../../../../../testing/pagination-service.stub';
describe('DsDynamicLookupRelationSearchTabComponent', () => {
let component: DsDynamicLookupRelationSearchTabComponent;
@@ -88,7 +90,8 @@ describe('DsDynamicLookupRelationSearchTabComponent', () => {
}
},
{ provide: ActivatedRoute, useValue: { snapshot: { queryParams: {} } } },
- { provide: LookupRelationService, useValue: lookupRelationService }
+ { provide: LookupRelationService, useValue: lookupRelationService },
+ { provide: PaginationService, useValue: new PaginationServiceStub() }
],
schemas: [NO_ERRORS_SCHEMA]
})
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts
index f4addf646c..e778b524b0 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts
@@ -19,6 +19,7 @@ import { RouteService } from '../../../../../../core/services/route.service';
import { CollectionElementLinkType } from '../../../../../object-collection/collection-element-link.type';
import { Context } from '../../../../../../core/shared/context.model';
import { LookupRelationService } from '../../../../../../core/data/lookup-relation.service';
+import { PaginationService } from '../../../../../../core/pagination/pagination.service';
@Component({
selector: 'ds-dynamic-lookup-relation-search-tab',
@@ -117,7 +118,8 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
private selectableListService: SelectableListService,
public searchConfigService: SearchConfigurationService,
private routeService: RouteService,
- public lookupRelationService: LookupRelationService
+ public lookupRelationService: LookupRelationService,
+ private paginationService: PaginationService
) {
}
@@ -137,9 +139,7 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest
* Method to reset the route when the window is opened to make sure no strange pagination issues appears
*/
resetRoute() {
- this.router.navigate([], {
- queryParams: Object.assign({ query: this.query }, this.route.snapshot.queryParams, this.initialPagination),
- });
+ this.paginationService.updateRoute(this.searchConfigService.paginationID, this.initialPagination);
}
/**
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.html
index cd55553f5b..8d0053a1df 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.html
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.html
@@ -12,7 +12,7 @@
{
let component: DsDynamicLookupRelationSelectionTabComponent;
@@ -54,6 +56,9 @@ describe('DsDynamicLookupRelationSelectionTabComponent', () => {
},
{
provide: Router, useValue: router
+ },
+ {
+ provide: PaginationService, useValue: new PaginationServiceStub()
}
],
schemas: [NO_ERRORS_SCHEMA]
diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts
index 8fac2ce7d1..2c8bc22bff 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts
@@ -15,6 +15,7 @@ import { PaginatedSearchOptions } from '../../../../../search/paginated-search-o
import { PageInfo } from '../../../../../../core/shared/page-info.model';
import { Context } from '../../../../../../core/shared/context.model';
import { createSuccessfulRemoteDataObject } from '../../../../../remote-data.utils';
+import { PaginationService } from '../../../../../../core/pagination/pagination.service';
@Component({
selector: 'ds-dynamic-lookup-relation-selection-tab',
@@ -76,18 +77,26 @@ export class DsDynamicLookupRelationSelectionTabComponent {
* The initial pagination to use
*/
initialPagination = Object.assign(new PaginationComponentOptions(), {
- id: 'submission-relation-list',
+ id: 'spc',
pageSize: 5
});
+ /**
+ * The current pagination options
+ */
+ currentPagination$: Observable;
+
constructor(private router: Router,
- private searchConfigService: SearchConfigurationService) {
+ private searchConfigService: SearchConfigurationService,
+ private paginationService: PaginationService
+ ) {
}
/**
* Set up the selection and pagination on load
*/
ngOnInit() {
+ this.resetRoute();
this.selectionRD$ = this.searchConfigService.paginatedSearchOptions
.pipe(
map((options: PaginatedSearchOptions) => options.pagination),
@@ -110,5 +119,16 @@ export class DsDynamicLookupRelationSelectionTabComponent {
);
})
);
+ this.currentPagination$ = this.paginationService.getCurrentPagination(this.searchConfigService.paginationID, this.initialPagination);
+ }
+
+ /**
+ * Method to reset the route when the tab is opened to make sure no strange pagination issues appears
+ */
+ resetRoute() {
+ this.paginationService.updateRoute(this.searchConfigService.paginationID, {
+ page: 1,
+ pageSize: 5
+ });
}
}