[Task 72397] applied feedback on the file section and full file section components

This commit is contained in:
Raf Ponsaerts
2020-08-17 10:14:05 +02:00
parent 82d780b6c2
commit 18fb47c9b6
4 changed files with 33 additions and 30 deletions

View File

@@ -9,6 +9,7 @@ import { FileSectionComponent } from '../../../simple/field-components/file-sect
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
import { PaginatedList } from '../../../../core/data/paginated-list';
import { RemoteData } from '../../../../core/data/remote-data';
import { switchMap } from "rxjs/operators";
/**
* This component renders the file section of the item
@@ -55,23 +56,23 @@ export class FullFileSectionComponent extends FileSectionComponent implements On
}
initialize(): void {
this.originalCurrentPage$.subscribe((value) => {
this.originals$ = this.bitstreamDataService.findAllByItemAndBundleName(
this.originals$ = this.originalCurrentPage$.pipe(
switchMap((pageNumber: number) => this.bitstreamDataService.findAllByItemAndBundleName(
this.item,
'ORIGINAL',
{ elementsPerPage: this.pageSize, currentPage: value },
{ elementsPerPage: this.pageSize, currentPage: pageNumber },
followLink( 'format')
))
);
});
this.licenseCurrentPage$.subscribe((value) => {
this.licenses$ = this.bitstreamDataService.findAllByItemAndBundleName(
this.licenses$ = this.licenseCurrentPage$.pipe(
switchMap((pageNumber: number) => this.bitstreamDataService.findAllByItemAndBundleName(
this.item,
'LICENSE',
{ elementsPerPage: this.pageSize, currentPage: value },
{ elementsPerPage: this.pageSize, currentPage: pageNumber },
followLink( 'format')
))
);
});
}

View File

@@ -6,12 +6,12 @@
<span>({{(file?.sizeBytes) | dsFileSize }})</span>
<span *ngIf="!last" innerHTML="{{separator}}"></span>
</ds-file-download-link>
<ds-loading *ngIf="isLoading" message="{{'loading.default' | translate}}"></ds-loading>
<ds-loading *ngIf="isLoading" message="{{'loading.default' | translate}}" [showMessage]="false"></ds-loading>
<div *ngIf="!isLastPage" class="mt-1" id="view-more">
<a class="bitstream-view-more" [routerLink]="" (click)="getNextPage()">{{'item.page.bitstreams.view-more' | translate}}</a>
<a class="bitstream-view-more btn btn-outline-secondary btn-sm" [routerLink]="" (click)="getNextPage()">{{'item.page.bitstreams.view-more' | translate}}</a>
</div>
<div *ngIf="isLastPage && currentPage != 1" class="mt-1" id="view-less">
<a class="bitstream-view-less" [routerLink]="" (click)="currentPage = undefined; getNextPage();">{{'item.page.bitstreams.view-less' | translate}}</a>
<a class="bitstream-view-less btn btn-outline-secondary btn-sm" [routerLink]="" (click)="currentPage = undefined; getNextPage();">{{'item.page.bitstreams.view-less' | translate}}</a>
</div>
</div>
</ds-metadata-field-wrapper>

View File

@@ -135,12 +135,12 @@ describe('FileSectionComponent', () => {
it('should not contain a view more link', () => {
const viewMore = fixture.debugElement.query(By.css('.bitstream-view-more'));
expect(viewMore).toBeFalsy();
expect(viewMore).toBeNull();
})
it('should contain a view less link', () => {
const viewLess = fixture.debugElement.query(By.css('.bitstream-view-less'));
expect(viewLess).toBeTruthy();
expect(viewLess).toBeDefined();
})
it('clicking on the view less link should reset the pages and call getNextPage()', () => {

View File

@@ -33,6 +33,8 @@ export class FileSectionComponent implements OnInit {
isLastPage: boolean;
pageSize: number = 5;
constructor(
protected bitstreamDataService: BitstreamDataService
) {
@@ -56,7 +58,7 @@ export class FileSectionComponent implements OnInit {
} else {
this.currentPage++;
}
this.bitstreamDataService.findAllByItemAndBundleName(this.item, 'ORIGINAL', { currentPage: this.currentPage }).pipe(
this.bitstreamDataService.findAllByItemAndBundleName(this.item, 'ORIGINAL', { currentPage: this.currentPage, elementsPerPage: this.pageSize }).pipe(
filter((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => hasValue(bitstreamsRD)),
takeWhile((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => hasNoValue(bitstreamsRD.payload) && hasNoValue(bitstreamsRD.error), true)
).subscribe((bitstreamsRD: RemoteData<PaginatedList<Bitstream>>) => {