mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
41914: Finished pagination feature for object list
This commit is contained in:
@@ -1,13 +1,7 @@
|
|||||||
<div *ngIf="topLevelCommunities.hasSucceeded | async">
|
<div *ngIf="topLevelCommunities.hasSucceeded | async">
|
||||||
<h2>{{'home.top-level-communities.head' | translate}}</h2>
|
<h2>{{'home.top-level-communities.head' | translate}}</h2>
|
||||||
<p class="lead">{{'home.top-level-communities.help' | translate}}</p>
|
<p class="lead">{{'home.top-level-communities.help' | translate}}</p>
|
||||||
<ds-object-list [config]="config" [objects]="topLevelCommunities"></ds-object-list>
|
<ds-object-list [config]="config" [objects]="topLevelCommunities"
|
||||||
<!--<ul>-->
|
(pageChange)="onPageChange($event)"
|
||||||
<!--<li *ngFor="let community of (topLevelCommunities.payload | async)">-->
|
(pageSizeChange)="onPageSizeChange($event)"></ds-object-list>
|
||||||
<!--<p>-->
|
|
||||||
<!--<span class="lead"><a [routerLink]="['/communities', community.id]">{{community.name}}</a></span><br>-->
|
|
||||||
<!--<span class="text-muted">{{community.shortDescription}}</span>-->
|
|
||||||
<!--</p>-->
|
|
||||||
<!--</li>-->
|
|
||||||
<!--</ul>-->
|
|
||||||
</div>
|
</div>
|
||||||
|
@@ -2,7 +2,8 @@ import { Component, OnInit } from '@angular/core';
|
|||||||
import { RemoteData } from "../../core/data/remote-data";
|
import { RemoteData } from "../../core/data/remote-data";
|
||||||
import { ItemDataService } from "../../core/data/item-data.service";
|
import { ItemDataService } from "../../core/data/item-data.service";
|
||||||
import { Item } from "../../core/shared/item.model";
|
import { Item } from "../../core/shared/item.model";
|
||||||
import { PaginationOptions } from "../../core/cache/models/pagination-options.model";
|
import { PaginationComponentOptions } from "../../shared/pagination/pagination-component-options.model";
|
||||||
|
import { SortOptions } from "../../core/cache/models/sort-options.model";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-top-level-community-list',
|
selector: 'ds-top-level-community-list',
|
||||||
@@ -11,7 +12,7 @@ import { PaginationOptions } from "../../core/cache/models/pagination-options.mo
|
|||||||
})
|
})
|
||||||
export class TopLevelCommunityListComponent implements OnInit {
|
export class TopLevelCommunityListComponent implements OnInit {
|
||||||
topLevelCommunities: RemoteData<Item[]>;
|
topLevelCommunities: RemoteData<Item[]>;
|
||||||
config : PaginationOptions;
|
config : PaginationComponentOptions;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private cds: ItemDataService
|
private cds: ItemDataService
|
||||||
@@ -25,8 +26,22 @@ export class TopLevelCommunityListComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.topLevelCommunities = this.cds.findAll();
|
this.topLevelCommunities = this.cds.findAll();
|
||||||
this.config = new PaginationOptions();
|
this.config = new PaginationComponentOptions();
|
||||||
this.config.id = "top-level-pagination"
|
this.config.id = "top-level-pagination"
|
||||||
this.config.pageSizeOptions = [ 5, 10, 20, 40, 60, 80, 100 ];
|
this.config.pageSizeOptions = [ 5, 10, 20, 40, 60, 80, 100 ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPageChange(currentPage): void {
|
||||||
|
this.config.currentPage = currentPage;
|
||||||
|
this.updateResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
onPageSizeChange(elementsPerPage): void {
|
||||||
|
this.config.pageSize = elementsPerPage;
|
||||||
|
this.updateResults();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateResults() {
|
||||||
|
this.topLevelCommunities = this.cds.findAll({ currentPage: this.config.currentPage, elementsPerPage: this.config.pageSize });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
<ds-pagination [paginationOptions]="config"
|
<ds-pagination [paginationOptions]="config"
|
||||||
[collectionSize]="(pageInfo | async)?.totalElements"
|
[collectionSize]="(pageInfo | async)?.totalElements"
|
||||||
(pageChange)="config.currentPage = pageChange($event)"
|
(pageChange)="onPageChange($event)"
|
||||||
(pageSizeChange)="config.pageSize = pageSize($event)">
|
(pageSizeChange)="onPageSizeChange($event)">
|
||||||
<ul *ngIf="objects.hasSucceeded | async">
|
<ul *ngIf="objects.hasSucceeded | async">
|
||||||
<li *ngFor="let object of (objects.payload | async) | paginate: { itemsPerPage: (pageInfo | async)?.elementsPerPage, currentPage: (pageInfo | async)?.currentPage, totalItems: (pageInfo | async)?.totalElements }">
|
<li *ngFor="let object of (objects.payload | async) | paginate: { itemsPerPage: (pageInfo | async)?.elementsPerPage, currentPage: (pageInfo | async)?.currentPage, totalItems: (pageInfo | async)?.totalElements }">
|
||||||
<ds-object-list-element [object]="object"></ds-object-list-element>
|
<ds-object-list-element [object]="object"></ds-object-list-element>
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
Component, Input, ViewEncapsulation, ChangeDetectionStrategy,
|
Component, Input, ViewEncapsulation, ChangeDetectionStrategy,
|
||||||
OnInit
|
OnInit, Output
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { RemoteData } from "../core/data/remote-data";
|
import { RemoteData } from "../core/data/remote-data";
|
||||||
import { DSpaceObject } from "../core/shared/dspace-object.model";
|
import { DSpaceObject } from "../core/shared/dspace-object.model";
|
||||||
import { PaginationOptions } from "../core/cache/models/pagination-options.model";
|
|
||||||
import { PageInfo } from "../core/shared/page-info.model";
|
import { PageInfo } from "../core/shared/page-info.model";
|
||||||
import { Observable } from "rxjs";
|
import { Observable } from "rxjs";
|
||||||
|
import { PaginationComponentOptions } from "../shared/pagination/pagination-component-options.model";
|
||||||
|
import { EventEmitter } from "@angular/common/src/facade/async";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -19,8 +20,11 @@ import { Observable } from "rxjs";
|
|||||||
export class ObjectListComponent implements OnInit {
|
export class ObjectListComponent implements OnInit {
|
||||||
|
|
||||||
@Input() objects: RemoteData<DSpaceObject[]>;
|
@Input() objects: RemoteData<DSpaceObject[]>;
|
||||||
@Input() config : PaginationOptions;
|
@Input() config : PaginationComponentOptions;
|
||||||
pageInfo : Observable<PageInfo>;
|
pageInfo : Observable<PageInfo>;
|
||||||
|
|
||||||
|
@Output() pageChange = new EventEmitter();
|
||||||
|
@Output() pageSizeChange = new EventEmitter();
|
||||||
data: any = {};
|
data: any = {};
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -34,4 +38,11 @@ export class ObjectListComponent implements OnInit {
|
|||||||
this.pageInfo = this.objects.pageInfo;
|
this.pageInfo = this.objects.pageInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPageChange(event) {
|
||||||
|
this.pageChange.emit(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
onPageSizeChange(event) {
|
||||||
|
this.pageSizeChange.emit(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user