41914: DSO list with pagination from rest

This commit is contained in:
Lotte Hofstede
2017-06-14 15:03:41 +02:00
parent 3929a49c1d
commit 03208c8261
2 changed files with 15 additions and 6 deletions

View File

@@ -1,9 +1,9 @@
<ds-pagination [paginationOptions]="config"
[collectionSize]="(objects.payload | async)?.length"
(pageChange)="config.currentPage = $event"
(pageSizeChange)="config.pageSize = $event">
[collectionSize]="(pageInfo | async)?.totalElements"
(pageChange)="config.currentPage = pageChange($event)"
(pageSizeChange)="config.pageSize = pageSize($event)">
<ul *ngIf="objects.hasSucceeded | async">
<li *ngFor="let object of (objects.payload | async) | paginate: { itemsPerPage: config.pageSize, currentPage: config.currentPage, totalItems: (objects.payload | async)?.length }">
<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>
</li>
</ul>

View File

@@ -1,7 +1,12 @@
import { Component, Input, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
import {
Component, Input, ViewEncapsulation, ChangeDetectionStrategy,
OnInit
} from '@angular/core';
import { RemoteData } from "../core/data/remote-data";
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 { Observable } from "rxjs";
@Component({
@@ -11,10 +16,11 @@ import { PaginationOptions } from "../core/cache/models/pagination-options.model
styleUrls: ['./object-list.component.css'],
templateUrl: './object-list.component.html'
})
export class ObjectListComponent {
export class ObjectListComponent implements OnInit {
@Input() objects: RemoteData<DSpaceObject[]>;
@Input() config : PaginationOptions;
pageInfo : Observable<PageInfo>;
data: any = {};
constructor() {
@@ -22,7 +28,10 @@ export class ObjectListComponent {
}
universalInit() {
}
ngOnInit(): void {
this.pageInfo = this.objects.pageInfo;
}
}