mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
76654: Implement feedback
This commit is contained in:
@@ -28,6 +28,7 @@ import { RequestService } from '../../../core/data/request.service';
|
||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('EPeopleRegistryComponent', () => {
|
||||
let component: EPeopleRegistryComponent;
|
||||
@@ -121,15 +122,7 @@ describe('EPeopleRegistryComponent', () => {
|
||||
builderService = getMockFormBuilderService();
|
||||
translateService = getMockTranslateService();
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
||||
TranslateModule.forRoot({
|
||||
|
@@ -70,11 +70,6 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
||||
currentSearchQuery: string;
|
||||
currentSearchScope: string;
|
||||
|
||||
/**
|
||||
* The subscription for the search method
|
||||
*/
|
||||
searchSub: Subscription;
|
||||
|
||||
/**
|
||||
* FindListOptions
|
||||
*/
|
||||
@@ -150,39 +145,35 @@ export class EPeopleRegistryComponent implements OnInit, OnDestroy {
|
||||
if (hasValue(this.findListOptionsSub)) {
|
||||
this.findListOptionsSub.unsubscribe();
|
||||
}
|
||||
this.findListOptionsSub = this.paginationService.getCurrentPagination(this.config.id, this.config).subscribe((findListOptions) => {
|
||||
const query: string = data.query;
|
||||
const scope: string = data.scope;
|
||||
if (query != null && this.currentSearchQuery !== query) {
|
||||
this.router.navigate([], {
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
this.currentSearchQuery = query;
|
||||
this.paginationService.resetPage(this.config.id);
|
||||
}
|
||||
if (scope != null && this.currentSearchScope !== scope) {
|
||||
this.router.navigate([], {
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
this.currentSearchScope = scope;
|
||||
this.paginationService.resetPage(this.config.id);
|
||||
|
||||
}
|
||||
if (hasValue(this.searchSub)) {
|
||||
this.searchSub.unsubscribe();
|
||||
this.subs = this.subs.filter((sub: Subscription) => sub !== this.searchSub);
|
||||
}
|
||||
this.searchSub = this.epersonService.searchByScope(this.currentSearchScope, this.currentSearchQuery, {
|
||||
currentPage: findListOptions.currentPage,
|
||||
elementsPerPage: findListOptions.pageSize
|
||||
}).pipe(
|
||||
getAllSucceededRemoteData(),
|
||||
).subscribe((peopleRD) => {
|
||||
this.ePeople$.next(peopleRD.payload);
|
||||
this.pageInfoState$.next(peopleRD.payload.pageInfo);
|
||||
this.findListOptionsSub = this.paginationService.getCurrentPagination(this.config.id, this.config).pipe(
|
||||
switchMap((findListOptions) => {
|
||||
const query: string = data.query;
|
||||
const scope: string = data.scope;
|
||||
if (query != null && this.currentSearchQuery !== query) {
|
||||
this.router.navigate([], {
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
this.currentSearchQuery = query;
|
||||
this.paginationService.resetPage(this.config.id);
|
||||
}
|
||||
);
|
||||
this.subs.push(this.searchSub);
|
||||
if (scope != null && this.currentSearchScope !== scope) {
|
||||
this.router.navigate([], {
|
||||
queryParamsHandling: 'merge'
|
||||
});
|
||||
this.currentSearchScope = scope;
|
||||
this.paginationService.resetPage(this.config.id);
|
||||
|
||||
}
|
||||
return this.epersonService.searchByScope(this.currentSearchScope, this.currentSearchQuery, {
|
||||
currentPage: findListOptions.currentPage,
|
||||
elementsPerPage: findListOptions.pageSize
|
||||
});
|
||||
}
|
||||
),
|
||||
getAllSucceededRemoteData(),
|
||||
).subscribe((peopleRD) => {
|
||||
this.ePeople$.next(peopleRD.payload);
|
||||
this.pageInfoState$.next(peopleRD.payload.pageInfo);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -29,6 +29,7 @@ import { RequestService } from '../../../../core/data/request.service';
|
||||
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
||||
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('EPersonFormComponent', () => {
|
||||
let component: EPersonFormComponent;
|
||||
@@ -41,7 +42,7 @@ describe('EPersonFormComponent', () => {
|
||||
let authorizationService: AuthorizationDataService;
|
||||
let groupsDataService: GroupDataService;
|
||||
|
||||
let paginationService: PaginationService;
|
||||
let paginationService;
|
||||
|
||||
|
||||
|
||||
@@ -112,16 +113,7 @@ describe('EPersonFormComponent', () => {
|
||||
getGroupRegistryRouterLink: ''
|
||||
});
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
updateRouteWithUrl: {}
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
||||
TranslateModule.forRoot({
|
||||
|
@@ -30,6 +30,7 @@ import { PaginationComponentOptions } from '../../../../../shared/pagination/pag
|
||||
import { SortDirection, SortOptions } from '../../../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('MembersListComponent', () => {
|
||||
let component: MembersListComponent;
|
||||
@@ -119,16 +120,7 @@ describe('MembersListComponent', () => {
|
||||
builderService = getMockFormBuilderService();
|
||||
translateService = getMockTranslateService();
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
clearPagination : {},
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
||||
TranslateModule.forRoot({
|
||||
|
@@ -39,6 +39,7 @@ import { PaginationComponentOptions } from '../../../../../shared/pagination/pag
|
||||
import { SortDirection, SortOptions } from '../../../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('SubgroupsListComponent', () => {
|
||||
let component: SubgroupsListComponent;
|
||||
@@ -106,17 +107,7 @@ describe('SubgroupsListComponent', () => {
|
||||
builderService = getMockFormBuilderService();
|
||||
translateService = getMockTranslateService();
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
updateRouteWithUrl: {},
|
||||
clearPagination: {}
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
||||
TranslateModule.forRoot({
|
||||
|
@@ -32,6 +32,7 @@ import { PaginationComponentOptions } from '../../../shared/pagination/paginatio
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('GroupRegistryComponent', () => {
|
||||
let component: GroupsRegistryComponent;
|
||||
@@ -136,16 +137,7 @@ describe('GroupRegistryComponent', () => {
|
||||
authorizationService = jasmine.createSpyObj('authorizationService', {
|
||||
isAuthorized: observableOf(true)
|
||||
});
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
updateRouteWithUrl: {}
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, NgbModule, FormsModule, ReactiveFormsModule, BrowserModule,
|
||||
TranslateModule.forRoot({
|
||||
|
@@ -27,6 +27,7 @@ import { PaginationComponentOptions } from '../../../shared/pagination/paginatio
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('BitstreamFormatsComponent', () => {
|
||||
let comp: BitstreamFormatsComponent;
|
||||
@@ -104,14 +105,7 @@ describe('BitstreamFormatsComponent', () => {
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
|
||||
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
||||
@@ -236,14 +230,7 @@ describe('BitstreamFormatsComponent', () => {
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
|
||||
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
||||
@@ -292,13 +279,7 @@ describe('BitstreamFormatsComponent', () => {
|
||||
clearBitStreamFormatRequests: observableOf('cleared')
|
||||
});
|
||||
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [CommonModule, RouterTestingModule.withRoutes([]), TranslateModule.forRoot(), NgbModule],
|
||||
|
@@ -28,11 +28,6 @@ export class BitstreamFormatsComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
bitstreamFormats: Observable<RemoteData<PaginatedList<BitstreamFormat>>>;
|
||||
|
||||
/**
|
||||
* A BehaviourSubject that keeps track of the pageState used to update the currently displayed bitstreamFormats
|
||||
*/
|
||||
// pageState: BehaviorSubject<string>;
|
||||
|
||||
/**
|
||||
* The current pagination configuration for the page used by the FindAll method
|
||||
* Currently simply renders all bitstream formats
|
||||
|
@@ -22,12 +22,13 @@ import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../core/data/request.models';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('MetadataRegistryComponent', () => {
|
||||
let comp: MetadataRegistryComponent;
|
||||
let fixture: ComponentFixture<MetadataRegistryComponent>;
|
||||
let registryService: RegistryService;
|
||||
let paginationService: PaginationService;
|
||||
let paginationService;
|
||||
const mockSchemasList = [
|
||||
{
|
||||
id: 1,
|
||||
@@ -67,14 +68,7 @@ describe('MetadataRegistryComponent', () => {
|
||||
};
|
||||
/* tslint:enable:no-empty */
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -27,6 +27,7 @@ import { PaginationComponentOptions } from '../../../shared/pagination/paginatio
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('MetadataSchemaComponent', () => {
|
||||
let comp: MetadataSchemaComponent;
|
||||
@@ -129,15 +130,7 @@ describe('MetadataSchemaComponent', () => {
|
||||
})
|
||||
});
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -22,6 +22,7 @@ import { PaginationComponentOptions } from '../../shared/pagination/pagination-c
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../core/data/request.models';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('BrowseByDatePageComponent', () => {
|
||||
let comp: BrowseByDatePageComponent;
|
||||
@@ -70,15 +71,7 @@ describe('BrowseByDatePageComponent', () => {
|
||||
detectChanges: () => fixture.detectChanges()
|
||||
});
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -17,7 +17,7 @@ import { environment } from '../../../environments/environment';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||
import { SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-browse-by-date-page',
|
||||
@@ -47,13 +47,14 @@ export class BrowseByDatePageComponent extends BrowseByMetadataPageComponent {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
const sortConfig = new SortOptions('default', SortDirection.ASC);
|
||||
this.startsWithType = StartsWithType.date;
|
||||
this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, this.sortConfig));
|
||||
const currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||
const currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, this.sortConfig);
|
||||
this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig));
|
||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||
this.subs.push(
|
||||
observableCombineLatest([this.route.params, this.route.queryParams, this.route.data,
|
||||
currentPagination$, currentSort$]).pipe(
|
||||
this.currentPagination$, this.currentSort$]).pipe(
|
||||
map(([routeParams, queryParams, data, currentPage, currentSort]) => {
|
||||
return [Object.assign({}, routeParams, queryParams, data), currentPage, currentSort];
|
||||
})
|
||||
|
@@ -27,8 +27,8 @@
|
||||
title="{{'browse.title' | translate:{collection: (parent$ | async)?.payload?.name || '', field: 'browse.metadata.' + browseId | translate, value: (value)? '"' + value + '"': ''} }}"
|
||||
parentname="{{(parent$ | async)?.payload?.name || ''}}"
|
||||
[objects$]="(items$ !== undefined)? items$ : browseEntries$"
|
||||
[paginationConfig]="paginationConfig"
|
||||
[sortConfig]="sortConfig"
|
||||
[paginationConfig]="(currentPagination$ |async)"
|
||||
[sortConfig]="(currentSort$ |async)"
|
||||
[type]="startsWithType"
|
||||
[startsWithOptions]="startsWithOptions"
|
||||
[enableArrows]="true"
|
||||
|
@@ -24,16 +24,14 @@ import { VarDirective } from '../../shared/utils/var.directive';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('BrowseByMetadataPageComponent', () => {
|
||||
let comp: BrowseByMetadataPageComponent;
|
||||
let fixture: ComponentFixture<BrowseByMetadataPageComponent>;
|
||||
let browseService: BrowseService;
|
||||
let route: ActivatedRoute;
|
||||
let paginationService: PaginationService;
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
let paginationService;
|
||||
|
||||
const mockCommunity = Object.assign(new Community(), {
|
||||
id: 'test-uuid',
|
||||
@@ -88,11 +86,7 @@ describe('BrowseByMetadataPageComponent', () => {
|
||||
params: observableOf({})
|
||||
});
|
||||
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getRouteParameterValue: observableOf('')
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -16,7 +16,7 @@ import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
||||
import { StartsWithType } from '../../shared/starts-with/starts-with-decorator';
|
||||
import { BrowseByType, rendersBrowseBy } from '../+browse-by-switcher/browse-by-decorator';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { map, switchMap } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-browse-by-metadata-page',
|
||||
@@ -56,9 +56,14 @@ export class BrowseByMetadataPageComponent implements OnInit {
|
||||
});
|
||||
|
||||
/**
|
||||
* The sorting config used to sort the values (defaults to Ascending)
|
||||
* The pagination observable
|
||||
*/
|
||||
sortConfig: SortOptions = new SortOptions('default', SortDirection.ASC);
|
||||
currentPagination$: Observable<PaginationComponentOptions>;
|
||||
|
||||
/**
|
||||
* The sorting config observable
|
||||
*/
|
||||
currentSort$: Observable<SortOptions>;
|
||||
|
||||
/**
|
||||
* List of subscriptions
|
||||
@@ -107,11 +112,12 @@ export class BrowseByMetadataPageComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, this.sortConfig));
|
||||
const currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||
const currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, this.sortConfig);
|
||||
const sortConfig = new SortOptions('default', SortDirection.ASC);
|
||||
this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig));
|
||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||
this.subs.push(
|
||||
observableCombineLatest([this.route.params, this.route.queryParams, currentPagination$, currentSort$]).pipe(
|
||||
observableCombineLatest([this.route.params, this.route.queryParams, this.currentPagination$, this.currentSort$]).pipe(
|
||||
map(([routeParams, queryParams, currentPage, currentSort]) => {
|
||||
return [Object.assign({}, routeParams, queryParams),currentPage,currentSort];
|
||||
})
|
||||
@@ -161,6 +167,7 @@ export class BrowseByMetadataPageComponent implements OnInit {
|
||||
* @param value The value of the browse-entry to display items for
|
||||
*/
|
||||
updatePageWithItems(searchOptions: BrowseEntrySearchOptions, value: string) {
|
||||
console.log('updatePAge', searchOptions);
|
||||
this.items$ = this.browseService.getBrowseItemsFor(value, searchOptions);
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,7 @@ import { PaginationComponentOptions } from '../../shared/pagination/pagination-c
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../core/data/request.models';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('BrowseByTitlePageComponent', () => {
|
||||
let comp: BrowseByTitlePageComponent;
|
||||
@@ -65,15 +66,7 @@ describe('BrowseByTitlePageComponent', () => {
|
||||
data: observableOf({ metadata: 'title' })
|
||||
});
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -35,12 +35,12 @@ export class BrowseByTitlePageComponent extends BrowseByMetadataPageComponent {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
||||
this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, this.sortConfig));
|
||||
const currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||
const currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, this.sortConfig);
|
||||
const sortConfig = new SortOptions('dc.title', SortDirection.ASC);
|
||||
this.updatePage(new BrowseEntrySearchOptions(this.defaultBrowseId, this.paginationConfig, sortConfig));
|
||||
this.currentPagination$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig);
|
||||
this.currentSort$ = this.paginationService.getCurrentSort(this.paginationConfig.id, sortConfig);
|
||||
this.subs.push(
|
||||
observableCombineLatest([this.route.params, this.route.queryParams, currentPagination$, currentSort$]).pipe(
|
||||
observableCombineLatest([this.route.params, this.route.queryParams, this.currentPagination$, this.currentSort$]).pipe(
|
||||
map(([routeParams, queryParams, currentPage, currentSort]) => {
|
||||
return [Object.assign({}, routeParams, queryParams),currentPage,currentSort];
|
||||
})
|
||||
|
@@ -24,6 +24,7 @@ import { of as observableOf } from 'rxjs';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
|
||||
import { ThemeService } from '../../shared/theme-support/theme.service';
|
||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('CommunityPageSubCollectionList Component', () => {
|
||||
let comp: CommunityPageSubCollectionListComponent;
|
||||
@@ -117,16 +118,7 @@ describe('CommunityPageSubCollectionList Component', () => {
|
||||
}
|
||||
};
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
updateRouteWithUrl: {}
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
themeService = getMockThemeService();
|
||||
|
||||
|
@@ -24,6 +24,7 @@ import { of as observableOf } from 'rxjs';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
|
||||
import { ThemeService } from '../../shared/theme-support/theme.service';
|
||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('CommunityPageSubCommunityListComponent Component', () => {
|
||||
let comp: CommunityPageSubCommunityListComponent;
|
||||
@@ -118,15 +119,7 @@ describe('CommunityPageSubCommunityListComponent Component', () => {
|
||||
}
|
||||
};
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
themeService = getMockThemeService();
|
||||
|
||||
|
@@ -24,6 +24,7 @@ import { SortDirection, SortOptions } from '../../core/cache/models/sort-options
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
|
||||
import { ThemeService } from '../../shared/theme-support/theme.service';
|
||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('TopLevelCommunityList Component', () => {
|
||||
let comp: TopLevelCommunityListComponent;
|
||||
@@ -109,14 +110,7 @@ describe('TopLevelCommunityList Component', () => {
|
||||
}
|
||||
};
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getRouteParameterValue: observableOf('')
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
themeService = getMockThemeService();
|
||||
|
||||
|
@@ -20,6 +20,7 @@ import { PaginationService } from '../../../../../core/pagination/pagination.ser
|
||||
import { PaginationComponentOptions } from '../../../../../shared/pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../../../core/data/request.models';
|
||||
import { PaginationServiceStub } from '../../../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('PaginatedDragAndDropBitstreamListComponent', () => {
|
||||
let comp: PaginatedDragAndDropBitstreamListComponent;
|
||||
@@ -28,7 +29,7 @@ describe('PaginatedDragAndDropBitstreamListComponent', () => {
|
||||
let bundleService: BundleDataService;
|
||||
let objectValuesPipe: ObjectValuesPipe;
|
||||
let requestService: RequestService;
|
||||
let paginationService: PaginationService;
|
||||
let paginationService;
|
||||
|
||||
const columnSizes = new ResponsiveTableSizes([
|
||||
new ResponsiveColumnSizes(2, 2, 3, 4, 4),
|
||||
@@ -114,15 +115,7 @@ describe('PaginatedDragAndDropBitstreamListComponent', () => {
|
||||
hasByHref$: observableOf(true)
|
||||
});
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot()],
|
||||
|
@@ -20,6 +20,7 @@ import { PaginationComponentOptions } from '../../../../shared/pagination/pagina
|
||||
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('FullFileSectionComponent', () => {
|
||||
let comp: FullFileSectionComponent;
|
||||
@@ -56,15 +57,7 @@ describe('FullFileSectionComponent', () => {
|
||||
findAllByItemAndBundleName: createSuccessfulRemoteDataObject$(createPaginatedList([mockBitstream, mockBitstream, mockBitstream]))
|
||||
});
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
|
||||
|
@@ -9,6 +9,8 @@ import { ActivatedRouteStub } from '../shared/testing/active-router.stub';
|
||||
import { RoleServiceMock } from '../shared/mocks/role-service.mock';
|
||||
import { cold, hot } from 'jasmine-marbles';
|
||||
import { MyDSpaceConfigurationValueType } from './my-dspace-configuration-value-type';
|
||||
import { PaginationServiceStub } from '../shared/testing/pagination-service.stub';
|
||||
import { PaginationService } from '../core/pagination/pagination.service';
|
||||
|
||||
describe('MyDSpaceConfigurationService', () => {
|
||||
let service: MyDSpaceConfigurationService;
|
||||
@@ -34,18 +36,13 @@ describe('MyDSpaceConfigurationService', () => {
|
||||
getRouteDataValue: observableOf({})
|
||||
});
|
||||
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(defaults.pagination),
|
||||
getCurrentSort: observableOf(defaults.sort),
|
||||
getRouteParameterValue: observableOf('')
|
||||
});
|
||||
|
||||
const paginationService = new PaginationServiceStub();
|
||||
const activatedRoute: any = new ActivatedRouteStub();
|
||||
|
||||
const roleService: any = new RoleServiceMock();
|
||||
|
||||
beforeEach(() => {
|
||||
service = new MyDSpaceConfigurationService(roleService, spy, paginationService, activatedRoute);
|
||||
service = new MyDSpaceConfigurationService(roleService, spy, paginationService as any, activatedRoute);
|
||||
});
|
||||
|
||||
describe('when the scope is called', () => {
|
||||
|
@@ -16,6 +16,12 @@ import { isNumeric } from 'rxjs/internal-compatibility';
|
||||
})
|
||||
/**
|
||||
* Service to manage the pagination of different components
|
||||
* The pagination information will be stored in the route based on a paginationID.
|
||||
* The following params are used for the different kind of pagination information:
|
||||
* - For the page: p.{paginationID}
|
||||
* - For the page size: rpp.{paginationID}
|
||||
* - For the sort direction: sd.{paginationID}
|
||||
* - For the sort field: sf.{paginationID}
|
||||
*/
|
||||
export class PaginationService {
|
||||
|
||||
|
@@ -5,6 +5,7 @@ import { SortDirection, SortOptions } from '../../cache/models/sort-options.mode
|
||||
import { PaginatedSearchOptions } from '../../../shared/search/paginated-search-options.model';
|
||||
import { SearchFilter } from '../../../shared/search/search-filter.model';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('SearchConfigurationService', () => {
|
||||
let service: SearchConfigurationService;
|
||||
@@ -30,17 +31,13 @@ describe('SearchConfigurationService', () => {
|
||||
getRouteParameterValue: observableOf('')
|
||||
});
|
||||
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(defaults.pagination),
|
||||
getCurrentSort: observableOf(defaults.sort),
|
||||
getRouteParameterValue: observableOf('')
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
|
||||
const activatedRoute: any = new ActivatedRouteStub();
|
||||
|
||||
beforeEach(() => {
|
||||
service = new SearchConfigurationService(routeService, paginationService, activatedRoute);
|
||||
service = new SearchConfigurationService(routeService, paginationService as any, activatedRoute);
|
||||
});
|
||||
describe('when the scope is called', () => {
|
||||
beforeEach(() => {
|
||||
|
@@ -27,6 +27,7 @@ import { PaginationComponentOptions } from '../../../shared/pagination/paginatio
|
||||
import { SortDirection, SortOptions } from '../../cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../data/request.models';
|
||||
import { SearchConfigurationService } from './search-configuration.service';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
|
||||
@Component({ template: '' })
|
||||
class DummyComponent {
|
||||
@@ -102,16 +103,7 @@ describe('SearchService', () => {
|
||||
}
|
||||
};
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
updateRouteWithUrl: {}
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
const searchConfigService = {paginationID: 'page-id'};
|
||||
|
||||
beforeEach(() => {
|
||||
|
@@ -17,6 +17,7 @@ import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../core/data/request.models';
|
||||
import { PaginationServiceStub } from '../../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('ProcessOverviewComponent', () => {
|
||||
let component: ProcessOverviewComponent;
|
||||
@@ -24,15 +25,11 @@ describe('ProcessOverviewComponent', () => {
|
||||
|
||||
let processService: ProcessDataService;
|
||||
let ePersonService: EPersonDataService;
|
||||
let paginationService: PaginationService;
|
||||
let paginationService;
|
||||
|
||||
let processes: Process[];
|
||||
let ePerson: EPerson;
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
|
||||
function init() {
|
||||
processes = [
|
||||
Object.assign(new Process(), {
|
||||
@@ -80,11 +77,7 @@ describe('ProcessOverviewComponent', () => {
|
||||
findById: createSuccessfulRemoteDataObject$(ePerson)
|
||||
});
|
||||
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
}
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
|
@@ -13,6 +13,7 @@ import { SortDirection, SortOptions } from '../core/cache/models/sort-options.mo
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationService } from '../core/pagination/pagination.service';
|
||||
import { SearchConfigurationService } from '../core/shared/search/search-configuration.service';
|
||||
import { PaginationServiceStub } from '../shared/testing/pagination-service.stub';
|
||||
|
||||
describe('SearchNavbarComponent', () => {
|
||||
let component: SearchNavbarComponent;
|
||||
@@ -33,16 +34,7 @@ describe('SearchNavbarComponent', () => {
|
||||
navigate: (commands) => commands
|
||||
};
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getRouteParameterValue: observableOf(''),
|
||||
updateRouteWithUrl: {},
|
||||
clearPagination : {}
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
|
@@ -20,6 +20,7 @@ import { createSuccessfulRemoteDataObject$ } from '../remote-data.utils';
|
||||
import { storeModuleConfig } from '../../app.reducer';
|
||||
import { FindListOptions } from '../../core/data/request.models';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../testing/pagination-service.stub';
|
||||
|
||||
describe('BrowseByComponent', () => {
|
||||
let comp: BrowseByComponent;
|
||||
@@ -53,15 +54,7 @@ describe('BrowseByComponent', () => {
|
||||
pageSizeOptions: [5, 10, 15, 20],
|
||||
pageSize: 15
|
||||
});
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(paginationConfig),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
updateRoute: {},
|
||||
resetPage: {},
|
||||
});
|
||||
const paginationService = new PaginationServiceStub(paginationConfig);
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -15,14 +15,12 @@ import { PaginationComponentOptions } from '../../pagination/pagination-componen
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../testing/pagination-service.stub';
|
||||
|
||||
describe('ItemVersionsComponent', () => {
|
||||
let component: ItemVersionsComponent;
|
||||
let fixture: ComponentFixture<ItemVersionsComponent>;
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
|
||||
const versionHistory = Object.assign(new VersionHistory(), {
|
||||
id: '1'
|
||||
});
|
||||
@@ -59,11 +57,7 @@ describe('ItemVersionsComponent', () => {
|
||||
getVersions: createSuccessfulRemoteDataObject$(createPaginatedList(versions))
|
||||
});
|
||||
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getRouteParameterValue: observableOf('')
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -17,6 +17,7 @@ import { SortDirection, SortOptions } from '../../../core/cache/models/sort-opti
|
||||
import { FindListOptions } from '../../../core/data/request.models';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../testing/pagination-service.stub';
|
||||
|
||||
describe('CollectionSelectComponent', () => {
|
||||
let comp: CollectionSelectComponent;
|
||||
@@ -40,16 +41,7 @@ describe('CollectionSelectComponent', () => {
|
||||
currentPage: 1
|
||||
});
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
|
||||
const paginationService = new PaginationServiceStub();
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), SharedModule, RouterTestingModule.withRoutes([])],
|
||||
|
@@ -17,12 +17,13 @@ import { createPaginatedList } from '../../testing/utils.test';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../core/data/request.models';
|
||||
import { PaginationServiceStub } from '../../testing/pagination-service.stub';
|
||||
|
||||
describe('ItemSelectComponent', () => {
|
||||
let comp: ItemSelectComponent;
|
||||
let fixture: ComponentFixture<ItemSelectComponent>;
|
||||
let objectSelectService: ObjectSelectService;
|
||||
let paginationService: PaginationService;
|
||||
let paginationService;
|
||||
|
||||
const mockItemList = [
|
||||
Object.assign(new Item(), {
|
||||
@@ -63,14 +64,7 @@ describe('ItemSelectComponent', () => {
|
||||
currentPage: 1
|
||||
});
|
||||
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(mockPaginationOptions),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
paginationService = new PaginationServiceStub(mockPaginationOptions);
|
||||
|
||||
|
||||
|
||||
|
@@ -13,6 +13,7 @@ import { EnumKeysPipe } from '../utils/enum-keys-pipe';
|
||||
import { VarDirective } from '../utils/var.directive';
|
||||
import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../testing/pagination-service.stub';
|
||||
|
||||
describe('PageSizeSelectorComponent', () => {
|
||||
|
||||
@@ -34,11 +35,7 @@ describe('PageSizeSelectorComponent', () => {
|
||||
sort
|
||||
};
|
||||
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getRouteParameterValue: observableOf('')
|
||||
});
|
||||
const paginationService = new PaginationServiceStub(pagination, sort);
|
||||
|
||||
const activatedRouteStub = {
|
||||
queryParams: observableOf({
|
||||
|
@@ -14,6 +14,7 @@ import { ObjectValuesPipe } from '../utils/object-values-pipe';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { PaginationServiceStub } from '../testing/pagination-service.stub';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-mock-paginated-drag-drop-abstract',
|
||||
@@ -47,8 +48,6 @@ describe('AbstractPaginatedDragAndDropListComponent', () => {
|
||||
|
||||
const url = 'mock-abstract-paginated-drag-and-drop-list-component';
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
|
||||
const object1 = Object.assign(new DSpaceObject(), { uuid: 'object-1' });
|
||||
const object2 = Object.assign(new DSpaceObject(), { uuid: 'object-2' });
|
||||
@@ -77,11 +76,7 @@ describe('AbstractPaginatedDragAndDropListComponent', () => {
|
||||
paginationComponent = jasmine.createSpyObj('paginationComponent', {
|
||||
doPageChange: {}
|
||||
});
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getRouteParameterValue: observableOf('')
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
objectsRD$ = new BehaviorSubject(objectsRD);
|
||||
component = new MockAbstractPaginatedDragAndDropListComponent(objectUpdatesService, elRef, objectValuesPipe, url, paginationService, objectsRD$);
|
||||
component.paginationComponent = paginationComponent;
|
||||
|
@@ -34,6 +34,7 @@ import { storeModuleConfig } from '../../app.reducer';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { FindListOptions } from '../../core/data/request.models';
|
||||
import { BehaviorSubject, of as observableOf } from 'rxjs';
|
||||
import { PaginationServiceStub } from '../testing/pagination-service.stub';
|
||||
|
||||
function expectPages(fixture: ComponentFixture<any>, pagesDef: string[]): void {
|
||||
const de = fixture.debugElement.query(By.css('.pagination'));
|
||||
@@ -108,7 +109,7 @@ describe('Pagination component', () => {
|
||||
let activatedRouteStub: MockActivatedRoute;
|
||||
let routerStub: RouterMock;
|
||||
|
||||
let paginationService: PaginationService;
|
||||
let paginationService;
|
||||
|
||||
// Define initial state and test state
|
||||
const _initialState = { width: 1600, height: 770 };
|
||||
|
@@ -99,9 +99,8 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
@Input() public hidePagerWhenSinglePage = true;
|
||||
|
||||
/**
|
||||
* Option for disabling updating and reading route parameters on pagination changes
|
||||
* In other words, changing pagination won't add or update the url parameters on the current page, and the url
|
||||
* parameters won't affect the pagination of this component
|
||||
* Option for retaining the scroll position upon navigating to an url with updated params.
|
||||
* After the page update the page will scroll back to the current pagination component.
|
||||
*/
|
||||
@Input() public retainScrollPosition = false;
|
||||
|
||||
@@ -121,8 +120,8 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
public hostWindow: Observable<HostWindowState>;
|
||||
|
||||
/**
|
||||
* ID for the pagination instance. Only useful if you wish to
|
||||
* have more than once instance at a time in a given component.
|
||||
* ID for the pagination instance. This ID is used in the routing to retrieve the pagination options.
|
||||
* This ID needs to be unique between different pagination components when more than one will be displayed on the same page.
|
||||
*/
|
||||
public id: string;
|
||||
|
||||
@@ -156,7 +155,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
||||
* Name of the field that's used to sort by
|
||||
*/
|
||||
public sortField$;
|
||||
public defaultSortField = 'id';
|
||||
public defaultSortField = 'name';
|
||||
|
||||
/**
|
||||
* Array to track all subscriptions and unsubscribe them onDestroy
|
||||
|
@@ -22,6 +22,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../testing/pagination-service.stub';
|
||||
|
||||
describe('EpersonGroupListComponent test suite', () => {
|
||||
let comp: EpersonGroupListComponent;
|
||||
@@ -64,15 +65,7 @@ describe('EpersonGroupListComponent test suite', () => {
|
||||
const groupPaginatedList = buildPaginatedList(new PageInfo(), [GroupMock, GroupMock]);
|
||||
const groupPaginatedListRD = createSuccessfulRemoteDataObject(groupPaginatedList);
|
||||
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(paginationOptions),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
clearPagination: {}
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -14,6 +14,7 @@ import { FindListOptions } from '../../core/data/request.models';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
|
||||
import { PaginationServiceStub } from '../testing/pagination-service.stub';
|
||||
|
||||
describe('SearchFormComponent', () => {
|
||||
let comp: SearchFormComponent;
|
||||
@@ -21,16 +22,7 @@ describe('SearchFormComponent', () => {
|
||||
let de: DebugElement;
|
||||
let el: HTMLElement;
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
updateRouteWithUrl: {}
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
const searchConfigService = {paginationID: 'test-id'};
|
||||
|
||||
|
@@ -19,6 +19,7 @@ import { PaginationComponentOptions } from '../../../../../pagination/pagination
|
||||
import { SortDirection, SortOptions } from '../../../../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../../../testing/pagination-service.stub';
|
||||
|
||||
describe('SearchFacetOptionComponent', () => {
|
||||
let comp: SearchFacetOptionComponent;
|
||||
@@ -85,17 +86,8 @@ describe('SearchFacetOptionComponent', () => {
|
||||
let router;
|
||||
const page = observableOf(0);
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
getPageParam: 'p.page-id',
|
||||
});
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { id: 'page-id', currentPage: 1, pageSize: 20 });
|
||||
const paginationService = new PaginationServiceStub(pagination);
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), NoopAnimationsModule, FormsModule],
|
||||
|
@@ -23,6 +23,7 @@ import { PaginationComponentOptions } from '../../../../../pagination/pagination
|
||||
import { SortDirection, SortOptions } from '../../../../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../../../testing/pagination-service.stub';
|
||||
|
||||
describe('SearchFacetRangeOptionComponent', () => {
|
||||
let comp: SearchFacetRangeOptionComponent;
|
||||
@@ -58,17 +59,8 @@ describe('SearchFacetRangeOptionComponent', () => {
|
||||
let router;
|
||||
const page = observableOf(0);
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
updateRouteWithUrl: {},
|
||||
getPageParam: 'p.page-id',
|
||||
});
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { id: 'page-id', currentPage: 1, pageSize: 20 });
|
||||
const paginationService = new PaginationServiceStub(pagination);
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -18,6 +18,7 @@ import { PaginationComponentOptions } from '../../../../../pagination/pagination
|
||||
import { SortDirection, SortOptions } from '../../../../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../../../testing/pagination-service.stub';
|
||||
|
||||
describe('SearchFacetSelectedOptionComponent', () => {
|
||||
let comp: SearchFacetSelectedOptionComponent;
|
||||
@@ -110,17 +111,8 @@ describe('SearchFacetSelectedOptionComponent', () => {
|
||||
let router;
|
||||
const page = observableOf(0);
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
updateRouteWithUrl: {},
|
||||
getPageParam: 'p.page-id'
|
||||
});
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { id: 'page-id', currentPage: 1, pageSize: 20 });
|
||||
const paginationService = new PaginationServiceStub(pagination);
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -16,6 +16,7 @@ import { SortDirection, SortOptions } from '../../../../core/cache/models/sort-o
|
||||
import { FindListOptions } from '../../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../../core/pagination/pagination.service';
|
||||
import { SearchConfigurationService } from '../../../../core/shared/search/search-configuration.service';
|
||||
import { PaginationServiceStub } from '../../../testing/pagination-service.stub';
|
||||
|
||||
describe('SearchLabelComponent', () => {
|
||||
let comp: SearchLabelComponent;
|
||||
@@ -38,17 +39,8 @@ describe('SearchLabelComponent', () => {
|
||||
filter2
|
||||
];
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
updateRouteWithUrl: {},
|
||||
getPageParam: 'p.test-id'
|
||||
});
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { id: 'page-id', currentPage: 1, pageSize: 20 });
|
||||
const paginationService = new PaginationServiceStub(pagination);
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -17,6 +17,7 @@ import { SEARCH_CONFIG_SERVICE } from '../../../+my-dspace-page/my-dspace-page.c
|
||||
import { SidebarService } from '../../sidebar/sidebar.service';
|
||||
import { SidebarServiceStub } from '../../testing/sidebar-service.stub';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../testing/pagination-service.stub';
|
||||
|
||||
describe('SearchSettingsComponent', () => {
|
||||
|
||||
@@ -65,11 +66,7 @@ describe('SearchSettingsComponent', () => {
|
||||
}),
|
||||
};
|
||||
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
resetPage: {},
|
||||
});
|
||||
paginationService = new PaginationServiceStub(pagination, sort);
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([])],
|
||||
|
@@ -15,6 +15,7 @@ import { PaginationComponentOptions } from '../../pagination/pagination-componen
|
||||
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../../core/data/request.models';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../testing/pagination-service.stub';
|
||||
|
||||
describe('StartsWithDateComponent', () => {
|
||||
let comp: StartsWithDateComponent;
|
||||
@@ -30,15 +31,7 @@ describe('StartsWithDateComponent', () => {
|
||||
queryParams: observableOf({})
|
||||
});
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
|
||||
paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
});
|
||||
paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
@@ -13,6 +13,7 @@ import { SortDirection, SortOptions } from '../../../core/cache/models/sort-opti
|
||||
import { FindListOptions } from '../../../core/data/request.models';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../testing/pagination-service.stub';
|
||||
|
||||
describe('StartsWithTextComponent', () => {
|
||||
let comp: StartsWithTextComponent;
|
||||
@@ -22,15 +23,7 @@ describe('StartsWithTextComponent', () => {
|
||||
|
||||
const options = ['0-9', 'A', 'B', 'C'];
|
||||
|
||||
const pagination = Object.assign(new PaginationComponentOptions(), { currentPage: 1, pageSize: 20 });
|
||||
const sort = new SortOptions('score', SortDirection.DESC);
|
||||
const findlistOptions = Object.assign(new FindListOptions(), { currentPage: 1, elementsPerPage: 20 });
|
||||
const paginationService = jasmine.createSpyObj('PaginationService', {
|
||||
getCurrentPagination: observableOf(pagination),
|
||||
getCurrentSort: observableOf(sort),
|
||||
getFindListOptions: observableOf(findlistOptions),
|
||||
resetPage: {},
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
|
25
src/app/shared/testing/pagination-service.stub.ts
Normal file
25
src/app/shared/testing/pagination-service.stub.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { PaginationComponentOptions } from '../pagination/pagination-component-options.model';
|
||||
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
|
||||
import { FindListOptions } from '../../core/data/request.models';
|
||||
|
||||
export class PaginationServiceStub {
|
||||
|
||||
constructor(
|
||||
public pagination = Object.assign(new PaginationComponentOptions(), {currentPage: 1, pageSize: 20}),
|
||||
public sort = new SortOptions('score', SortDirection.DESC),
|
||||
public findlistOptions = Object.assign(new FindListOptions(), {currentPage: 1, elementsPerPage: 20}),
|
||||
) {
|
||||
}
|
||||
|
||||
getCurrentPagination = jasmine.createSpy('getCurrentPagination').and.returnValue(observableOf(this.pagination));
|
||||
getCurrentSort = jasmine.createSpy('getCurrentSort').and.returnValue(observableOf(this.sort));
|
||||
getFindListOptions = jasmine.createSpy('getFindListOptions').and.returnValue(observableOf(this.findlistOptions));
|
||||
resetPage = jasmine.createSpy('resetPage');
|
||||
updateRoute = jasmine.createSpy('updateRoute');
|
||||
updateRouteWithUrl = jasmine.createSpy('updateRouteWithUrl');
|
||||
clearPagination = jasmine.createSpy('clearPagination');
|
||||
getRouteParameterValue = jasmine.createSpy('getRouteParameterValue').and.returnValue(observableOf(''));
|
||||
getPageParam = jasmine.createSpy('getPageParam').and.returnValue(`p.${this.pagination.id}`);
|
||||
|
||||
}
|
@@ -2,13 +2,13 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { BehaviorSubject, combineLatest, Subscription } from 'rxjs';
|
||||
import { filter, mergeMap, take } from 'rxjs/operators';
|
||||
import { filter, mergeMap, switchMap, take } from 'rxjs/operators';
|
||||
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
|
||||
|
||||
import { ExternalSourceService } from '../../core/data/external-source.service';
|
||||
import { ExternalSourceData } from './import-external-searchbar/submission-import-external-searchbar.component';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { PaginatedList, buildPaginatedList } from '../../core/data/paginated-list.model';
|
||||
import { buildPaginatedList, PaginatedList } from '../../core/data/paginated-list.model';
|
||||
import { ExternalSourceEntry } from '../../core/shared/external-source-entry.model';
|
||||
import { SearchConfigurationService } from '../../core/shared/search/search-configuration.service';
|
||||
import { Context } from '../../core/shared/context.model';
|
||||
@@ -167,25 +167,27 @@ export class SubmissionImportExternalComponent implements OnInit, OnDestroy {
|
||||
* @param query The query string to search
|
||||
*/
|
||||
private retrieveExternalSources(): void {
|
||||
this.reload$.subscribe((sourceQueryObject: {source: string, query: string}) => {
|
||||
const source = sourceQueryObject.source;
|
||||
const query = sourceQueryObject.query;
|
||||
if (isNotEmpty(source) && isNotEmpty(query)) {
|
||||
this.routeData.sourceId = source;
|
||||
this.routeData.query = query;
|
||||
this.isLoading$.next(true);
|
||||
this.subs.push(
|
||||
this.searchConfigService.paginatedSearchOptions.pipe(
|
||||
filter((searchOptions) => searchOptions.query === query),
|
||||
mergeMap((searchOptions) => this.externalService.getExternalSourceEntries(this.routeData.sourceId, searchOptions).pipe(
|
||||
getFinishedRemoteData(),
|
||||
)),
|
||||
).subscribe((rdData) => {
|
||||
this.entriesRD$.next(rdData);
|
||||
this.isLoading$.next(false);
|
||||
})
|
||||
);
|
||||
}
|
||||
this.reload$.pipe(
|
||||
switchMap(
|
||||
(sourceQueryObject: { source: string, query: string }) => {
|
||||
const source = sourceQueryObject.source;
|
||||
const query = sourceQueryObject.query;
|
||||
if (isNotEmpty(source) && isNotEmpty(query)) {
|
||||
this.routeData.sourceId = source;
|
||||
this.routeData.query = query;
|
||||
this.isLoading$.next(true);
|
||||
return this.searchConfigService.paginatedSearchOptions.pipe(
|
||||
filter((searchOptions) => searchOptions.query === query),
|
||||
mergeMap((searchOptions) => this.externalService.getExternalSourceEntries(this.routeData.sourceId, searchOptions).pipe(
|
||||
getFinishedRemoteData(),
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
),
|
||||
).subscribe((rdData) => {
|
||||
this.entriesRD$.next(rdData);
|
||||
this.isLoading$.next(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user