Skip to content

Commit

Permalink
Merge pull request DSpace#2642 from alexandrevryghem/fix-broken-item-…
Browse files Browse the repository at this point in the history
…mapper-pagination_contribute-main

Fixed pagination issues on item mapper
tdonohue authored Apr 19, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents e96ca2f + a5f49ba commit a4387bb
Showing 27 changed files with 107 additions and 117 deletions.
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@
<ng-template ngbNavContent>
<ds-pagination
[paginationOptions]="(paginationOptions$ | async)"
[pageInfoState]="(objectsSelected$|async)?.payload.pageInfo"
[collectionSize]="(objectsSelected$|async)?.payload?.totalElements"
[objects]="(objectsSelected$|async)"
[showPaginator]="false"
Original file line number Diff line number Diff line change
@@ -45,7 +45,6 @@ <h2 id="search" class="border-bottom pb-2">
<ds-pagination
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && (searching$ | async) !== true"
[paginationOptions]="config"
[pageInfoState]="pageInfoState$"
[collectionSize]="(pageInfoState$ | async)?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Original file line number Diff line number Diff line change
@@ -52,7 +52,6 @@ <h2>{{messagePrefix + '.groupsEPersonIsMemberOf' | translate}}</h2>
<ds-pagination
*ngIf="(groups$ | async)?.payload?.totalElements > 0"
[paginationOptions]="config"
[pageInfoState]="groupsPageInfoState$"
[collectionSize]="(groups$ | async)?.payload?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true"
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ <h3>{{messagePrefix + '.headMembers' | translate}}</h3>

<ds-pagination *ngIf="(ePeopleMembersOfGroup | async)?.totalElements > 0"
[paginationOptions]="config"
[pageInfoState]="(ePeopleMembersOfGroup | async)"
[collectionSize]="(ePeopleMembersOfGroup | async)?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
@@ -86,7 +85,6 @@ <h3 id="search" class="border-bottom pb-2">

<ds-pagination *ngIf="(ePeopleSearch | async)?.totalElements > 0"
[paginationOptions]="configSearch"
[pageInfoState]="(ePeopleSearch | async)"
[collectionSize]="(ePeopleSearch | async)?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@ <h4>{{messagePrefix + '.headSubgroups' | translate}}</h4>

<ds-pagination *ngIf="(subGroups$ | async)?.payload?.totalElements > 0"
[paginationOptions]="config"
[pageInfoState]="(subGroups$ | async)?.payload"
[collectionSize]="(subGroups$ | async)?.payload?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
@@ -84,7 +83,6 @@ <h4 id="search" class="border-bottom pb-2">

<ds-pagination *ngIf="(searchResults$ | async)?.payload?.totalElements > 0"
[paginationOptions]="configSearch"
[pageInfoState]="(searchResults$ | async)?.payload"
[collectionSize]="(searchResults$ | async)?.payload?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Original file line number Diff line number Diff line change
@@ -37,7 +37,6 @@ <h2 id="search" class="border-bottom pb-2">{{messagePrefix + 'search.head' | tra
<ds-pagination
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && (loading$ | async) !== true"
[paginationOptions]="config"
[pageInfoState]="pageInfoState$"
[collectionSize]="(pageInfoState$ | async)?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ <h1 class="flex-grow-1">{{ 'ldn-registered-services.title' | translate }}</h1>
[collectionSize]="(ldnServicesRD$ | async)?.payload?.totalElements"
[hideGear]="true"
[hidePagerWhenSinglePage]="true"
[pageInfoState]="(ldnServicesRD$ | async)?.payload"
[paginationOptions]="pageConfig">
<div class="table-responsive">
<table class="table table-striped table-hover">
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ <h1 id="header" class="border-bottom pb-2">{{'admin.registries.bitstream-formats
<ds-pagination
*ngIf="(bitstreamFormats | async)?.payload?.totalElements > 0"
[paginationOptions]="pageConfig"
[pageInfoState]="(bitstreamFormats | async)?.payload"
[collectionSize]="(bitstreamFormats | async)?.payload?.totalElements"
[hideGear]="false"
[hidePagerWhenSinglePage]="true">
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ <h2>{{'admin.registries.schema.fields.head' | translate}}</h2>
<ds-pagination
*ngIf="fields?.totalElements > 0"
[paginationOptions]="config"
[pageInfoState]="fields"
[collectionSize]="fields?.totalElements"
[hideGear]="false"
[hidePagerWhenSinglePage]="true">
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ import {
SortDirection,
SortOptions,
} from '../../core/cache/models/sort-options.model';
import { CollectionDataService } from '../../core/data/collection-data.service';
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
import { ItemDataService } from '../../core/data/item-data.service';
@@ -39,6 +38,7 @@ import { SEARCH_CONFIG_SERVICE } from '../../my-dspace-page/my-dspace-configurat
import { ErrorComponent } from '../../shared/error/error.component';
import { HostWindowService } from '../../shared/host-window.service';
import { LoadingComponent } from '../../shared/loading/loading.component';
import { getMockThemeService } from '../../shared/mocks/theme-service.mock';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { ItemSelectComponent } from '../../shared/object-select/item-select/item-select.component';
import { ObjectSelectService } from '../../shared/object-select/object-select.service';
@@ -58,6 +58,7 @@ import { RouterStub } from '../../shared/testing/router.stub';
import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service.stub';
import { SearchServiceStub } from '../../shared/testing/search-service.stub';
import { createPaginatedList } from '../../shared/testing/utils.test';
import { ThemeService } from '../../shared/theme-support/theme.service';
import { EnumKeysPipe } from '../../shared/utils/enum-keys-pipe';
import { VarDirective } from '../../shared/utils/var.directive';
import { CollectionItemMapperComponent } from './collection-item-mapper.component';
@@ -190,7 +191,6 @@ describe('CollectionItemMapperComponent', () => {
{ provide: SearchService, useValue: searchServiceStub },
{ provide: NotificationsService, useValue: new NotificationsServiceStub() },
{ provide: ItemDataService, useValue: itemDataServiceStub },
{ provide: CollectionDataService, useValue: collectionDataServiceStub },
{ provide: TranslateService, useValue: translateServiceStub },
{ provide: HostWindowService, useValue: new HostWindowServiceStub(0) },
{ provide: ObjectSelectService, useValue: new ObjectSelectServiceStub() },
@@ -199,6 +199,7 @@ describe('CollectionItemMapperComponent', () => {
{ provide: GroupDataService, useValue: groupDataService },
{ provide: LinkHeadService, useValue: linkHeadService },
{ provide: ConfigurationDataService, useValue: configurationDataService },
{ provide: ThemeService, useValue: getMockThemeService() },
],
}).overrideComponent(CollectionItemMapperComponent, {
set: {
Original file line number Diff line number Diff line change
@@ -35,7 +35,6 @@ import {
SortDirection,
SortOptions,
} from '../../core/cache/models/sort-options.model';
import { CollectionDataService } from '../../core/data/collection-data.service';
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
import { ItemDataService } from '../../core/data/item-data.service';
import { PaginatedList } from '../../core/data/paginated-list.model';
@@ -150,7 +149,6 @@ export class CollectionItemMapperComponent implements OnInit {
private searchService: SearchService,
private notificationsService: NotificationsService,
private itemDataService: ItemDataService,
private collectionDataService: CollectionDataService,
private translateService: TranslateService,
private dsoNameService: DSONameService) {
}
@@ -187,6 +185,8 @@ export class CollectionItemMapperComponent implements OnInit {
this.shouldUpdate$.next(false);
}
return this.itemDataService.findListByHref(collectionRD.payload._links.mappedItems.href, Object.assign(options, {
currentPage: options.pagination.currentPage,
elementsPerPage: options.pagination.pageSize,
sort: this.defaultSortOptions,
}),!shouldUpdate, false, followLink('owningCollection')).pipe(
getAllSucceededRemoteData(),
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
[hidePagerWhenSinglePage]="true"
[hidePaginationDetail]="true"
[paginationOptions]="options"
[pageInfoState]="(objectsRD$ | async)?.payload"
[collectionSize]="(objectsRD$ | async)?.payload?.totalElements">
<ng-container *ngIf="(loading$ | async) !== true">
<div [id]="bundle.id" class="bundle-bitstreams-list"
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ <h2 class="h4">
<ng-container *ngVar="updates | dsObjectValues as updateValues">
<ds-pagination
[paginationOptions]="paginationConfig"
[pageInfoState]="(relationshipsRd$ | async)?.payload?.pageInfo"
[collectionSize]="(relationshipsRd$ | async)?.payload?.totalElements + (this.nbAddedFields$ | async)"
[hideGear]="true"
[hidePagerWhenSinglePage]="true">
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ <h3 class="h5 simple-view-element-header">{{"item.page.filesection.original.bund
[hideGear]="true"
[hidePagerWhenSinglePage]="true"
[paginationOptions]="originalOptions"
[pageInfoState]="originals"
[collectionSize]="originals?.totalElements"
[retainScrollPosition]="true">

@@ -49,7 +48,6 @@ <h3 class="h5 simple-view-element-header">{{"item.page.filesection.license.bundl
[hideGear]="true"
[hidePagerWhenSinglePage]="true"
[paginationOptions]="licenseOptions"
[pageInfoState]="licenses"
[collectionSize]="licenses?.totalElements"
[retainScrollPosition]="true">

1 change: 0 additions & 1 deletion src/app/item-page/versions/item-versions.component.html
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@ <h2 *ngIf="displayTitle" class="h4">{{"item.version.history.head" | translate}}<
[hideGear]="true"
[hidePagerWhenSinglePage]="true"
[paginationOptions]="options"
[pageInfoState]="versions"
[collectionSize]="versions?.totalElements"
[retainScrollPosition]="true">
<table class="table table-striped table-bordered align-middle my-2">
1 change: 0 additions & 1 deletion src/app/shared/object-detail/object-detail.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<ds-pagination
[paginationOptions]="config"
[pageInfoState]="objects?.payload"
[collectionSize]="objects?.payload?.totalElements"
[sortOptions]="sortConfig"
[objects]="objects"
1 change: 0 additions & 1 deletion src/app/shared/object-grid/object-grid.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<ds-pagination
[paginationOptions]="config"
[pageInfoState]="objects?.payload"
[collectionSize]="objects?.payload?.totalElements"
[sortOptions]="sortConfig"
[hideGear]="hideGear"
1 change: 0 additions & 1 deletion src/app/shared/object-list/object-list.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<ds-pagination
[paginationOptions]="config"
[pageInfoState]="$any(objects?.payload)"
[collectionSize]="objects?.payload?.totalElements"
[objects]="objects"
[sortOptions]="sortConfig"
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
*ngIf="collectionsRD?.payload?.totalElements > 0 || collectionsRD?.payload?.page?.length > 0"
[paginationOptions]="paginationOptions"
[sortOptions]="sortOptions"
[pageInfoState]="collectionsRD?.payload"
[collectionSize]="collectionsRD?.payload?.totalElements"
[hidePagerWhenSinglePage]="true"
[hideGear]="true">
@@ -16,9 +15,9 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let collection of collectionsRD?.payload?.page">
<td><input #selectCollectionBtn [attr.aria-label]="(selectCollectionBtn.checked ? 'collection.select.table.deselect' : 'collection.select.table.select') | translate" class="collection-checkbox" [ngModel]="getSelected(collection.id) | async" (change)="switch(collection.id)" type="checkbox" name="{{collection.id}}"></td>
<td><a [routerLink]="['/collections', collection.id]">{{ dsoNameService.getName(collection) }}</a></td>
<tr *ngFor="let selectCollection of selectCollections$ | async">
<td><input #selectCollectionBtn [attr.aria-label]="(selectCollectionBtn.checked ? 'collection.select.table.deselect' : 'collection.select.table.select') | translate" [disabled]="(selectCollection.canSelect$ | async) === false" class="collection-checkbox" [ngModel]="selectCollection.selected$ | async" (change)="switch(selectCollection.dso.id)" type="checkbox" name="{{selectCollection.dso.id}}"></td>
<td><a [routerLink]="selectCollection.route">{{ dsoNameService.getName(selectCollection.dso) }}</a></td>
</tr>
</tbody>
</table>
Original file line number Diff line number Diff line change
@@ -4,20 +4,31 @@ import {
NgFor,
NgIf,
} from '@angular/common';
import { Component } from '@angular/core';
import {
Component,
OnInit,
} from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterLink } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import {
map,
Observable,
} from 'rxjs';

import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
import { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { Collection } from '../../../core/shared/collection.model';
import { isNotEmpty } from '../../empty.util';
import { getAllSucceededRemoteDataPayload } from '../../../core/shared/operators';
import {
hasValueOperator,
isNotEmpty,
} from '../../empty.util';
import { ErrorComponent } from '../../error/error.component';
import { ThemedLoadingComponent } from '../../loading/themed-loading.component';
import { PaginationComponent } from '../../pagination/pagination.component';
import { VarDirective } from '../../utils/var.directive';
import { ObjectSelectService } from '../object-select.service';
import { DSpaceObjectSelect } from '../object-select.model';
import { ObjectSelectComponent } from '../object-select/object-select.component';

@Component({
@@ -31,21 +42,29 @@ import { ObjectSelectComponent } from '../object-select/object-select.component'
/**
* A component used to select collections from a specific list and returning the UUIDs of the selected collections
*/
export class CollectionSelectComponent extends ObjectSelectComponent<Collection> {
export class CollectionSelectComponent extends ObjectSelectComponent<Collection> implements OnInit {

constructor(
protected objectSelectService: ObjectSelectService,
protected authorizationService: AuthorizationDataService,
public dsoNameService: DSONameService,
) {
super(objectSelectService, authorizationService);
}
/**
* Collection of all the data that is used to display the {@link Collection} in the HTML.
* By collecting this data here it doesn't need to be recalculated on evey change detection.
*/
selectCollections$: Observable<DSpaceObjectSelect<Collection>[]>;

ngOnInit(): void {
super.ngOnInit();
if (!isNotEmpty(this.confirmButton)) {
this.confirmButton = 'collection.select.confirm';
}
this.selectCollections$ = this.dsoRD$.pipe(
hasValueOperator(),
getAllSucceededRemoteDataPayload(),
map((collections: PaginatedList<Collection>) => collections.page.map((collection: Collection) => Object.assign(new DSpaceObjectSelect<Collection>(), {
dso: collection,
canSelect$: this.canSelect(collection),
selected$: this.getSelected(collection.id),
route: getCollectionPageRoute(collection.id),
} as DSpaceObjectSelect<Collection>))),
);
}

}
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@
*ngIf="itemsRD?.payload?.totalElements > 0"
[paginationOptions]="paginationOptions"
[sortOptions]="sortOptions"
[pageInfoState]="itemsRD?.payload"
[collectionSize]="itemsRD?.payload?.totalElements"
[hidePagerWhenSinglePage]="true"
[hideGear]="true">
@@ -18,17 +17,17 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let item of itemsRD?.payload?.page">
<td><input #selectItemBtn [attr.aria-label]="(selectItemBtn.checked ? 'item.select.table.deselect' : 'item.select.table.select') | translate" [disabled]="(canSelect(item) | async) !== true" class="item-checkbox" [ngModel]="getSelected(item.id) | async" (change)="switch(item.id)" type="checkbox" name="{{item.id}}"></td>
<tr *ngFor="let selectItem of selectItems$ | async">
<td><input #selectItemBtn [attr.aria-label]="(selectItemBtn.checked ? 'item.select.table.deselect' : 'item.select.table.select') | translate" [disabled]="(selectItem.canSelect$ | async) === false" class="item-checkbox" [ngModel]="selectItem.selected$ | async" (change)="switch(selectItem.dso.id)" type="checkbox" name="{{selectItem.dso.id}}"></td>
<td *ngIf="!hideCollection">
<span *ngVar="(item.owningCollection | async)?.payload as collection">
<span *ngVar="(selectItem.dso.owningCollection | async)?.payload as collection">
<a *ngIf="collection" [routerLink]="['/collections', collection?.id]">
{{ dsoNameService.getName(collection) }}
</a>
</span>
</td>
<td><span *ngIf="item.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])">{{item.firstMetadataValue(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])}}</span></td>
<td><a [routerLink]="[(itemPageRoutes$ | async)[item.id]]">{{ dsoNameService.getName(item) }}</a></td>
<td><span *ngIf="selectItem.dso.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])">{{selectItem.dso.firstMetadataValue(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])}}</span></td>
<td><a [routerLink]="selectItem.route">{{ dsoNameService.getName(selectItem.dso) }}</a></td>
</tr>
</tbody>
</table>
Original file line number Diff line number Diff line change
@@ -187,15 +187,16 @@ describe('ItemSelectComponent', () => {
beforeEach(() => {
comp.featureId = FeatureID.CanManageMappings;
spyOn(authorizationDataService, 'isAuthorized').and.returnValue(of(false));
comp.ngOnInit();
});

it('should disable the checkbox', waitForAsync(() => {
it('should disable the checkbox', waitForAsync(async () => {
fixture.detectChanges();
fixture.whenStable().then(() => {
const checkbox = fixture.debugElement.query(By.css('input.item-checkbox')).nativeElement;
expect(authorizationDataService.isAuthorized).toHaveBeenCalled();
expect(checkbox.disabled).toBeTrue();
});
await fixture.whenStable();

const checkbox = fixture.debugElement.query(By.css('input.item-checkbox')).nativeElement;
expect(authorizationDataService.isAuthorized).toHaveBeenCalled();
expect(checkbox.disabled).toBeTrue();
}));
});
});
38 changes: 14 additions & 24 deletions src/app/shared/object-select/item-select/item-select.component.ts
Original file line number Diff line number Diff line change
@@ -7,15 +7,15 @@ import {
import {
Component,
Input,
OnInit,
} from '@angular/core';
import { FormsModule } from '@angular/forms';
import { RouterLink } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
import { PaginatedList } from '../../../core/data/paginated-list.model';
import { Item } from '../../../core/shared/item.model';
import { getAllSucceededRemoteDataPayload } from '../../../core/shared/operators';
import { getItemPageRoute } from '../../../item-page/item-page-routing-paths';
@@ -27,7 +27,7 @@ import { ErrorComponent } from '../../error/error.component';
import { ThemedLoadingComponent } from '../../loading/themed-loading.component';
import { PaginationComponent } from '../../pagination/pagination.component';
import { VarDirective } from '../../utils/var.directive';
import { ObjectSelectService } from '../object-select.service';
import { DSpaceObjectSelect } from '../object-select.model';
import { ObjectSelectComponent } from '../object-select/object-select.component';

@Component({
@@ -40,7 +40,7 @@ import { ObjectSelectComponent } from '../object-select/object-select.component'
/**
* A component used to select items from a specific list and returning the UUIDs of the selected items
*/
export class ItemSelectComponent extends ObjectSelectComponent<Item> {
export class ItemSelectComponent extends ObjectSelectComponent<Item> implements OnInit {

/**
* Whether or not to hide the collection column
@@ -49,35 +49,25 @@ export class ItemSelectComponent extends ObjectSelectComponent<Item> {
hideCollection = false;

/**
* The routes to the items their pages
* Key: Item ID
* Value: Route to item page
* Collection of all the data that is used to display the {@link Item} in the HTML.
* By collecting this data here it doesn't need to be recalculated on evey change detection.
*/
itemPageRoutes$: Observable<{
[itemId: string]: string
}>;

constructor(
protected objectSelectService: ObjectSelectService,
protected authorizationService: AuthorizationDataService,
public dsoNameService: DSONameService,
) {
super(objectSelectService, authorizationService);
}
selectItems$: Observable<DSpaceObjectSelect<Item>[]>;

ngOnInit(): void {
super.ngOnInit();
if (!isNotEmpty(this.confirmButton)) {
this.confirmButton = 'item.select.confirm';
}
this.itemPageRoutes$ = this.dsoRD$.pipe(
this.selectItems$ = this.dsoRD$.pipe(
hasValueOperator(),
getAllSucceededRemoteDataPayload(),
map((items) => {
const itemPageRoutes = {};
items.page.forEach((item) => itemPageRoutes[item.uuid] = getItemPageRoute(item));
return itemPageRoutes;
}),
map((items: PaginatedList<Item>) => items.page.map((item: Item) => Object.assign(new DSpaceObjectSelect<Item>(), {
dso: item,
canSelect$: this.canSelect(item),
selected$: this.getSelected(item.id),
route: getItemPageRoute(item),
} as DSpaceObjectSelect<Item>))),
);
}

30 changes: 30 additions & 0 deletions src/app/shared/object-select/object-select.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Observable } from 'rxjs';

import { DSpaceObject } from '../../core/shared/dspace-object.model';

/**
* Class used to collect all the data that that is used by the {@link ObjectSelectComponent} in the HTML.
*/
export class DSpaceObjectSelect<T extends DSpaceObject> {

/**
* The {@link DSpaceObject} to display
*/
dso: T;

/**
* Whether the {@link DSpaceObject} can be selected
*/
canSelect$: Observable<boolean>;

/**
* Whether the {@link DSpaceObject} is selected
*/
selected$: Observable<boolean>;

/**
* The {@link DSpaceObject}'s route
*/
route: string;

}
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import {
take,
} from 'rxjs/operators';

import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
import { SortOptions } from '../../../core/cache/models/sort-options.model';
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
@@ -31,7 +32,7 @@ import { ObjectSelectService } from '../object-select.service';
selector: 'ds-object-select-abstract',
template: '',
})
export abstract class ObjectSelectComponent<TDomain> implements OnInit, OnDestroy {
export abstract class ObjectSelectComponent<TDomain extends DSpaceObject> implements OnInit, OnDestroy {

/**
* A unique key used for the object select service
@@ -102,8 +103,11 @@ export abstract class ObjectSelectComponent<TDomain> implements OnInit, OnDestro
*/
selectedIds$: Observable<string[]>;

constructor(protected objectSelectService: ObjectSelectService,
protected authorizationService: AuthorizationDataService) {
constructor(
protected objectSelectService: ObjectSelectService,
protected authorizationService: AuthorizationDataService,
public dsoNameService: DSONameService,
) {
}

ngOnInit(): void {
1 change: 0 additions & 1 deletion src/app/shared/object-table/object-table.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<ds-pagination
[paginationOptions]="config"
[pageInfoState]="objects?.payload"
[collectionSize]="objects?.payload?.totalElements"
[sortOptions]="sortConfig"
[hideGear]="hideGear"
41 changes: 4 additions & 37 deletions src/app/shared/pagination/pagination.component.ts
Original file line number Diff line number Diff line change
@@ -39,13 +39,11 @@ import { PaginatedList } from '../../core/data/paginated-list.model';
import { RemoteData } from '../../core/data/remote-data';
import { PaginationService } from '../../core/pagination/pagination.service';
import { PaginationRouteParams } from '../../core/pagination/pagination-route-params.interface';
import { PageInfo } from '../../core/shared/page-info.model';
import { ViewMode } from '../../core/shared/view-mode.model';
import { hasValue } from '../empty.util';
import { HostWindowService } from '../host-window.service';
import { ListableObject } from '../object-collection/shared/listable-object.model';
import { RSSComponent } from '../rss-feed/rss.component';
import { HostWindowState } from '../search/host-window.reducer';
import { EnumKeysPipe } from '../utils/enum-keys-pipe';
import { PaginationComponentOptions } from './pagination-component-options.model';

@@ -73,11 +71,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
*/
@Input() collectionSize: number;

/**
* Page state of a Remote paginated objects.
*/
@Input() pageInfoState: Observable<PageInfo> = undefined;

/**
* Configuration for the NgbPagination component.
*/
@@ -167,18 +160,13 @@ export class PaginationComponent implements OnDestroy, OnInit {
/**
* Current page.
*/
public currentPage$;
public currentPage$: Observable<number>;

/**
* Current page in the state of a Remote paginated objects.
*/
public currentPageState: number = undefined;

/**
* An observable of HostWindowState type
*/
public hostWindow: Observable<HostWindowState>;

/**
* 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.
@@ -268,7 +256,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
map((currentPagination) => currentPagination.pageSize),
);

let sortOptions;
let sortOptions: SortOptions;
if (this.sortOptions) {
sortOptions = this.sortOptions;
} else {
@@ -282,16 +270,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
);
}

/**
* @param cdRef
* ChangeDetectorRef is a singleton service provided by Angular.
* @param route
* Route is a singleton service provided by Angular.
* @param router
* Router is a singleton service provided by Angular.
* @param hostWindowService
* the HostWindowService singleton.
*/
constructor(private cdRef: ChangeDetectorRef,
private paginationService: PaginationService,
public hostWindowService: HostWindowService) {
@@ -330,17 +308,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
this.emitPaginationChange();
}

/**
* Method to change the route to the given sort field
*
* @param sortField
* The sort field being navigated to.
*/
public doSortFieldChange(field: string) {
this.updateParams({ page: 1, sortField: field });
this.emitPaginationChange();
}

/**
* Method to emit a general pagination change event
*/
@@ -364,10 +331,10 @@ export class PaginationComponent implements OnDestroy, OnInit {
if (collectionSize) {
showingDetails = this.paginationService.getCurrentPagination(this.id, this.paginationOptions).pipe(
map((currentPaginationOptions) => {
let lastItem;
let lastItem: number;
const pageMax = currentPaginationOptions.pageSize * currentPaginationOptions.currentPage;

const firstItem = currentPaginationOptions.pageSize * (currentPaginationOptions.currentPage - 1) + 1;
const firstItem: number = currentPaginationOptions.pageSize * (currentPaginationOptions.currentPage - 1) + 1;
if (collectionSize > pageMax) {
lastItem = pageMax;
} else {

0 comments on commit a4387bb

Please sign in to comment.