mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge remote-tracking branch 'contributions/w2p-130081_access-control-bitstreams-pagination-fix-7.6' into w2p-130081_access-control-bitstreams-pagination-fix-8.x
Conflicts: src/app/shared/access-control-form-container/item-access-control-select-bitstreams-modal/item-access-control-select-bitstreams-modal.component.ts
This commit is contained in:
@@ -8,20 +8,19 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<ng-container *ngIf="data$ | async as data">
|
<ng-container *ngIf="bitstreams$ | async as bitstreams">
|
||||||
<ds-viewable-collection
|
<ds-viewable-collection
|
||||||
*ngIf="data.payload.page.length > 0"
|
*ngIf="bitstreams.payload?.page?.length > 0"
|
||||||
[config]="paginationConfig"
|
[config]="paginationConfig"
|
||||||
[context]="context"
|
[context]="context"
|
||||||
[objects]="data"
|
[objects]="bitstreams"
|
||||||
[selectable]="true"
|
[selectable]="true"
|
||||||
[selectionConfig]="{ repeatable: true, listId: LIST_ID }"
|
[selectionConfig]="{ repeatable: true, listId: LIST_ID }"
|
||||||
[showPaginator]="true"
|
[showPaginator]="true">
|
||||||
(pageChange)="loadForPage($event)">
|
|
||||||
</ds-viewable-collection>
|
</ds-viewable-collection>
|
||||||
|
|
||||||
<div *ngIf="data && data.payload.page.length === 0"
|
<div *ngIf="bitstreams && bitstreams.payload?.page?.length === 0"
|
||||||
class="alert alert-info w-100" role="alert">
|
class="alert alert-info w-100" role="alert">
|
||||||
{{'access-control-select-bitstreams-modal.no-items' | translate}}
|
{{'access-control-select-bitstreams-modal.no-items' | translate}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@@ -23,6 +23,7 @@ import { Bitstream } from '../../../core/shared/bitstream.model';
|
|||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { ObjectCollectionComponent } from '../../object-collection/object-collection.component';
|
import { ObjectCollectionComponent } from '../../object-collection/object-collection.component';
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils';
|
import { createSuccessfulRemoteDataObject$ } from '../../remote-data.utils';
|
||||||
|
import { PaginationServiceStub } from '../../testing/pagination-service.stub';
|
||||||
import { createPaginatedList } from '../../testing/utils.test';
|
import { createPaginatedList } from '../../testing/utils.test';
|
||||||
import { FollowLinkConfig } from '../../utils/follow-link-config.model';
|
import { FollowLinkConfig } from '../../utils/follow-link-config.model';
|
||||||
import { ItemAccessControlSelectBitstreamsModalComponent } from './item-access-control-select-bitstreams-modal.component';
|
import { ItemAccessControlSelectBitstreamsModalComponent } from './item-access-control-select-bitstreams-modal.component';
|
||||||
@@ -37,6 +38,8 @@ describe('ItemAccessControlSelectBitstreamsModalComponent', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mockPaginationService = new PaginationServiceStub();
|
||||||
|
|
||||||
const translateServiceStub = {
|
const translateServiceStub = {
|
||||||
get: () => observableOf('test-message'),
|
get: () => observableOf('test-message'),
|
||||||
onLangChange: new EventEmitter(),
|
onLangChange: new EventEmitter(),
|
||||||
@@ -50,7 +53,7 @@ describe('ItemAccessControlSelectBitstreamsModalComponent', () => {
|
|||||||
providers: [
|
providers: [
|
||||||
NgbActiveModal,
|
NgbActiveModal,
|
||||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||||
{ provide: PaginationService, useValue: {} },
|
{ provide: PaginationService, useValue: mockPaginationService },
|
||||||
{ provide: TranslateService, useValue: translateServiceStub },
|
{ provide: TranslateService, useValue: translateServiceStub },
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
@@ -5,6 +5,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
Input,
|
Input,
|
||||||
|
OnDestroy,
|
||||||
OnInit,
|
OnInit,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
@@ -12,7 +13,8 @@ import {
|
|||||||
TranslateModule,
|
TranslateModule,
|
||||||
TranslateService,
|
TranslateService,
|
||||||
} from '@ngx-translate/core';
|
} from '@ngx-translate/core';
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
import { switchMap } from 'rxjs/operators';
|
||||||
import { PaginatedList } from 'src/app/core/data/paginated-list.model';
|
import { PaginatedList } from 'src/app/core/data/paginated-list.model';
|
||||||
import { RemoteData } from 'src/app/core/data/remote-data';
|
import { RemoteData } from 'src/app/core/data/remote-data';
|
||||||
import { Bitstream } from 'src/app/core/shared/bitstream.model';
|
import { Bitstream } from 'src/app/core/shared/bitstream.model';
|
||||||
@@ -21,8 +23,6 @@ import { Context } from 'src/app/core/shared/context.model';
|
|||||||
import { BitstreamDataService } from '../../../core/data/bitstream-data.service';
|
import { BitstreamDataService } from '../../../core/data/bitstream-data.service';
|
||||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
|
||||||
import { hasValue } from '../../empty.util';
|
|
||||||
import { ObjectCollectionComponent } from '../../object-collection/object-collection.component';
|
import { ObjectCollectionComponent } from '../../object-collection/object-collection.component';
|
||||||
import { PaginationComponentOptions } from '../../pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../pagination/pagination-component-options.model';
|
||||||
|
|
||||||
@@ -35,19 +35,22 @@ export const ITEM_ACCESS_CONTROL_SELECT_BITSTREAMS_LIST_ID = 'item-access-contro
|
|||||||
standalone: true,
|
standalone: true,
|
||||||
imports: [NgIf, ObjectCollectionComponent, AsyncPipe, TranslateModule],
|
imports: [NgIf, ObjectCollectionComponent, AsyncPipe, TranslateModule],
|
||||||
})
|
})
|
||||||
export class ItemAccessControlSelectBitstreamsModalComponent implements OnInit {
|
export class ItemAccessControlSelectBitstreamsModalComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
LIST_ID = ITEM_ACCESS_CONTROL_SELECT_BITSTREAMS_LIST_ID;
|
LIST_ID = ITEM_ACCESS_CONTROL_SELECT_BITSTREAMS_LIST_ID;
|
||||||
|
|
||||||
@Input() item!: Item;
|
@Input() item!: Item;
|
||||||
@Input() selectedBitstreams: string[] = [];
|
@Input() selectedBitstreams: string[] = [];
|
||||||
|
|
||||||
data$ = new BehaviorSubject<RemoteData<PaginatedList<Bitstream>> | null>(null);
|
bitstreams$: Observable<RemoteData<PaginatedList<Bitstream>>>;
|
||||||
paginationConfig: PaginationComponentOptions;
|
|
||||||
pageSize = 5;
|
|
||||||
|
|
||||||
context: Context = Context.Bitstream;
|
context: Context = Context.Bitstream;
|
||||||
|
|
||||||
|
paginationConfig = Object.assign(new PaginationComponentOptions(), {
|
||||||
|
id: 'iacsbm',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 5,
|
||||||
|
});
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private bitstreamService: BitstreamDataService,
|
private bitstreamService: BitstreamDataService,
|
||||||
protected paginationService: PaginationService,
|
protected paginationService: PaginationService,
|
||||||
@@ -55,23 +58,20 @@ export class ItemAccessControlSelectBitstreamsModalComponent implements OnInit {
|
|||||||
public activeModal: NgbActiveModal,
|
public activeModal: NgbActiveModal,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit(): void {
|
||||||
this.loadForPage(1);
|
this.bitstreams$ = this.paginationService.getCurrentPagination(this.paginationConfig.id, this.paginationConfig).pipe(
|
||||||
|
switchMap((options: PaginationComponentOptions) => this.bitstreamService.findAllByItemAndBundleName(
|
||||||
this.paginationConfig = new PaginationComponentOptions();
|
this.item,
|
||||||
this.paginationConfig.id = 'iacsbm';
|
'ORIGINAL',
|
||||||
this.paginationConfig.currentPage = 1;
|
{ elementsPerPage: options.pageSize, currentPage: options.currentPage },
|
||||||
if (hasValue(this.pageSize)) {
|
true,
|
||||||
this.paginationConfig.pageSize = this.pageSize;
|
true,
|
||||||
}
|
)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadForPage(page: number) {
|
ngOnDestroy(): void {
|
||||||
this.bitstreamService.findAllByItemAndBundleName(this.item, 'ORIGINAL', { currentPage: page }, false)
|
this.paginationService.clearPagination(this.paginationConfig.id);
|
||||||
.pipe(
|
|
||||||
getFirstCompletedRemoteData(),
|
|
||||||
)
|
|
||||||
.subscribe(this.data$);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user