diff --git a/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.ts b/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.ts index 685ad006e03..b17dadc2c33 100644 --- a/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.ts +++ b/src/app/item-page/edit-item-page/item-bitstreams/item-bitstreams.component.ts @@ -218,7 +218,7 @@ export class ItemBitstreamsComponent extends AbstractItemUpdateComponent impleme this.zone.run(() => { this.displayNotifications('item.edit.bitstreams.notifications.move', [response]); // Remove all cached requests from this bundle and call the event's callback when the requests are cleared - this.requestService.removeByHrefSubstring(bundle.self).pipe( + this.requestService.setStaleByHrefSubstring(bundle.self).pipe( filter((isCached) => isCached), take(1), ).subscribe(() => event.finish()); diff --git a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.html b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.html index 42b9b9eb647..68ff35d75b7 100644 --- a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.html +++ b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.html @@ -15,6 +15,21 @@ title="{{'item.edit.bitstreams.bundle.edit.buttons.upload' | translate}}"> +
+ + +
diff --git a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.spec.ts b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.spec.ts index d39f9eb265d..679ba99aefe 100644 --- a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.spec.ts +++ b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.spec.ts @@ -7,7 +7,13 @@ import { TestBed, waitForAsync, } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; +import { Store } from '@ngrx/store'; import { TranslateModule } from '@ngx-translate/core'; +import { PaginationService } from 'ngx-pagination'; +import { of } from 'rxjs'; +import { ActivatedRouteStub } from 'src/app/shared/testing/active-router.stub'; +import { PaginationServiceStub } from 'src/app/shared/testing/pagination-service.stub'; import { Bundle } from '../../../../core/shared/bundle.model'; import { Item } from '../../../../core/shared/item.model'; @@ -38,10 +44,20 @@ describe('ItemEditBitstreamBundleComponent', () => { self: { href: 'bundle-1-selflink' }, }, }); + const mockStore = { + select: () => of({}), + dispatch: jasmine.createSpy('dispatch'), + }; + beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), ItemEditBitstreamBundleComponent], + providers: [ + { provide: ActivatedRoute, useValue: new ActivatedRouteStub() }, + { provide: PaginationService, useValue: new PaginationServiceStub() }, + { provide: Store, useValue: mockStore }, + ], schemas: [ NO_ERRORS_SCHEMA, ], diff --git a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts index 60654108c94..6b67e0c05ff 100644 --- a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts +++ b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts @@ -1,3 +1,8 @@ +import { + AsyncPipe, + NgClass, + NgFor, +} from '@angular/common'; import { Component, EventEmitter, @@ -9,7 +14,14 @@ import { ViewContainerRef, } from '@angular/core'; import { RouterLink } from '@angular/router'; +import { NgbDropdownModule } from '@ng-bootstrap/ng-bootstrap'; import { TranslateModule } from '@ngx-translate/core'; +import { + map, + Observable, +} from 'rxjs'; +import { PaginationService } from 'src/app/core/pagination/pagination.service'; +import { PaginationComponentOptions } from 'src/app/shared/pagination/pagination-component-options.model'; import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service'; import { Bundle } from '../../../../core/shared/bundle.model'; @@ -29,6 +41,10 @@ import { PaginatedDragAndDropBitstreamListComponent } from './paginated-drag-and TranslateModule, RouterLink, ItemEditBitstreamDragHandleComponent, + NgbDropdownModule, + AsyncPipe, + NgClass, + NgFor, ], standalone: true, }) @@ -77,9 +93,30 @@ export class ItemEditBitstreamBundleComponent implements OnInit, OnDestroy { */ itemPageRoute: string; + /** + * Reference to child paginatedDragAndDropBitstreamListComponent + */ + @ViewChild(PaginatedDragAndDropBitstreamListComponent) paginatedDragAndDropBitstreamListComponent: PaginatedDragAndDropBitstreamListComponent; + + /** + * Options object for PaginationComponent + * ID match with default ID to affect all paginated bundles + */ + options = Object.assign(new PaginationComponentOptions(),{ + id: 'dad', + }); + + /** + * current page size + */ + public pageSize$: Observable; + + public pageSizeOptions: number[]; + constructor( protected viewContainerRef: ViewContainerRef, public dsoNameService: DSONameService, + public paginationService: PaginationService, ) { } @@ -87,10 +124,23 @@ export class ItemEditBitstreamBundleComponent implements OnInit, OnDestroy { this.bundleNameColumn = this.columnSizes.combineColumns(0, 2); this.viewContainerRef.createEmbeddedView(this.bundleView); this.itemPageRoute = getItemPageRoute(this.item); + this.pageSizeOptions = this.options.pageSizeOptions; + this.pageSize$ = this.paginationService.getCurrentPagination(this.options.id, this.options).pipe( + map((currentPagination) => currentPagination.pageSize), + ); } ngOnDestroy(): void { this.viewContainerRef.clear(); } + /** + * Method to update page size in child components + * + * @param pageSize + * The page size being navigated to. + */ + public doPageSizeChange(pageSize: number) { + this.paginatedDragAndDropBitstreamListComponent.paginationComponent.doPageSizeChange(pageSize); + } } diff --git a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.html b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.html index c3d6ebc8239..9ab14d44309 100644 --- a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.html +++ b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/paginated-drag-and-drop-bitstream-list/paginated-drag-and-drop-bitstream-list.component.html @@ -7,7 +7,7 @@
+ *ngVar="(updates$ | async) as updates" cdkDropList (cdkDropListDropped)="drop($event)" [ngbTooltip]="'item.edit.bitstreams.bundle.tooltip' | translate">
{ const event = { previousIndex: 0, currentIndex: 1, + dropPoint: { + x: 0, + y: 0, + }, item: { element: { nativeElement: { id: object1.uuid } } }, } as any; describe('when the user is hovering over a new page', () => { const hoverPage = 3; - const hoverElement = { textContent: '' + hoverPage }; + const hoverElement = document.createElement('div'); + hoverElement.textContent = '' + hoverPage; + hoverElement.classList.add('page-link'); beforeEach(() => { - elRef.nativeElement.querySelector.and.returnValue(hoverElement); + spyOn(document, 'elementFromPoint').and.returnValue(hoverElement); spyOn(component.dropObject, 'emit'); component.drop(event); }); diff --git a/src/app/shared/pagination-drag-and-drop/abstract-paginated-drag-and-drop-list.component.ts b/src/app/shared/pagination-drag-and-drop/abstract-paginated-drag-and-drop-list.component.ts index 444e7bc14cb..b84a5b902e4 100644 --- a/src/app/shared/pagination-drag-and-drop/abstract-paginated-drag-and-drop-list.component.ts +++ b/src/app/shared/pagination-drag-and-drop/abstract-paginated-drag-and-drop-list.component.ts @@ -211,10 +211,9 @@ export abstract class AbstractPaginatedDragAndDropListComponent