Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ <h4 class="modal-title">
</button>
</div>
<div class="modal-body">
<ng-container *ngIf="data$ | async as data">
<ng-container *ngIf="bitstreams$ | async as bitstreams">
<ds-viewable-collection
*ngIf="data.payload.page.length > 0"
*ngIf="bitstreams.payload?.page?.length > 0"
[config]="paginationConfig"
[context]="context"
[objects]="data"
[objects]="bitstreams"
[selectable]="true"
[selectionConfig]="{ repeatable: true, listId: LIST_ID }"
[showPaginator]="true"
(pageChange)="loadForPage($event)">
[showPaginator]="true">
</ds-viewable-collection>

<div *ngIf="data && data.payload.page.length === 0"
class="alert alert-info w-100" role="alert">
<div *ngIf="bitstreams && bitstreams.payload?.page?.length === 0"
class="alert alert-info w-100" role="alert">
{{'access-control-select-bitstreams-modal.no-items' | translate}}
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { BehaviorSubject } from 'rxjs';
import { Observable } from 'rxjs';
import { PaginatedList } from 'src/app/core/data/paginated-list.model';
import { RemoteData } from 'src/app/core/data/remote-data';
import { Bitstream } from 'src/app/core/shared/bitstream.model';
Expand All @@ -10,8 +10,7 @@
import { BitstreamDataService } from '../../../core/data/bitstream-data.service';
import { PaginationService } from '../../../core/pagination/pagination.service';
import { TranslateService } from '@ngx-translate/core';
import { hasValue } from '../../empty.util';
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
import { switchMap } from 'rxjs/operators';

export const ITEM_ACCESS_CONTROL_SELECT_BITSTREAMS_LIST_ID = 'item-access-control-select-bitstreams';

Expand All @@ -20,43 +19,43 @@
templateUrl: './item-access-control-select-bitstreams-modal.component.html',
styleUrls: [ './item-access-control-select-bitstreams-modal.component.scss' ]
})
export class ItemAccessControlSelectBitstreamsModalComponent implements OnInit {
export class ItemAccessControlSelectBitstreamsModalComponent implements OnInit, OnDestroy {

LIST_ID = ITEM_ACCESS_CONTROL_SELECT_BITSTREAMS_LIST_ID;

@Input() item!: Item;
@Input() selectedBitstreams: string[] = [];

data$ = new BehaviorSubject<RemoteData<PaginatedList<Bitstream>> | null>(null);
paginationConfig: PaginationComponentOptions;
pageSize = 5;

bitstreams$: Observable<RemoteData<PaginatedList<Bitstream>>>;
context: Context = Context.Bitstream;

paginationConfig = Object.assign(new PaginationComponentOptions(), {

Check warning on line 32 in src/app/shared/access-control-form-container/item-access-control-select-bitstreams-modal/item-access-control-select-bitstreams-modal.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/shared/access-control-form-container/item-access-control-select-bitstreams-modal/item-access-control-select-bitstreams-modal.component.ts#L32

Added line #L32 was not covered by tests
id: 'iacsbm',
currentPage: 1,
pageSize: 5
});

constructor(
private bitstreamService: BitstreamDataService,
protected paginationService: PaginationService,
protected translateService: TranslateService,
public activeModal: NgbActiveModal
) { }

ngOnInit() {
this.loadForPage(1);

this.paginationConfig = new PaginationComponentOptions();
this.paginationConfig.id = 'iacsbm';
this.paginationConfig.currentPage = 1;
if (hasValue(this.pageSize)) {
this.paginationConfig.pageSize = this.pageSize;
}
ngOnInit(): void {
this.bitstreams$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig).pipe(
switchMap((options: PaginationComponentOptions) => this.bitstreamService.findAllByItemAndBundleName(

Check warning on line 47 in src/app/shared/access-control-form-container/item-access-control-select-bitstreams-modal/item-access-control-select-bitstreams-modal.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/shared/access-control-form-container/item-access-control-select-bitstreams-modal/item-access-control-select-bitstreams-modal.component.ts#L46-L47

Added lines #L46 - L47 were not covered by tests
this.item,
'ORIGINAL',
{ elementsPerPage: options.pageSize, currentPage: options.currentPage },
true,
true,
))
);
}

loadForPage(page: number) {
this.bitstreamService.findAllByItemAndBundleName(this.item, 'ORIGINAL', { currentPage: page}, false)
.pipe(
getFirstCompletedRemoteData(),
)
.subscribe(this.data$);
ngOnDestroy(): void {
this.paginationService.clearPagination(this.paginationConfig.id);

Check warning on line 58 in src/app/shared/access-control-form-container/item-access-control-select-bitstreams-modal/item-access-control-select-bitstreams-modal.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/shared/access-control-form-container/item-access-control-select-bitstreams-modal/item-access-control-select-bitstreams-modal.component.ts#L58

Added line #L58 was not covered by tests
}

}
Loading