diff --git a/src/app/access-control/bulk-access/browse/bulk-access-browse.component.html b/src/app/access-control/bulk-access/browse/bulk-access-browse.component.html index 6e967b53b5..131cb49d6b 100644 --- a/src/app/access-control/bulk-access/browse/bulk-access-browse.component.html +++ b/src/app/access-control/bulk-access/browse/bulk-access-browse.component.html @@ -37,7 +37,6 @@ diff --git a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html index 9168bbaf8e..72c0f5d8c1 100644 --- a/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html +++ b/src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html @@ -52,7 +52,6 @@ @@ -86,7 +85,6 @@ diff --git a/src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.html b/src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.html index ab7bd84f6b..66404bde0d 100644 --- a/src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.html +++ b/src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.html @@ -5,7 +5,6 @@ @@ -84,7 +83,6 @@ diff --git a/src/app/access-control/group-registry/groups-registry.component.html b/src/app/access-control/group-registry/groups-registry.component.html index 2ef67ddf54..201e1cfe24 100644 --- a/src/app/access-control/group-registry/groups-registry.component.html +++ b/src/app/access-control/group-registry/groups-registry.component.html @@ -37,7 +37,6 @@ diff --git a/src/app/admin/admin-ldn-services/ldn-services-directory/ldn-services-directory.component.html b/src/app/admin/admin-ldn-services/ldn-services-directory/ldn-services-directory.component.html index 0aaa39bda2..3dcce659c2 100644 --- a/src/app/admin/admin-ldn-services/ldn-services-directory/ldn-services-directory.component.html +++ b/src/app/admin/admin-ldn-services/ldn-services-directory/ldn-services-directory.component.html @@ -10,7 +10,6 @@ [collectionSize]="(ldnServicesRD$ | async)?.payload?.totalElements" [hideGear]="true" [hidePagerWhenSinglePage]="true" - [pageInfoState]="(ldnServicesRD$ | async)?.payload" [paginationOptions]="pageConfig">
diff --git a/src/app/admin/admin-registries/bitstream-formats/bitstream-formats.component.html b/src/app/admin/admin-registries/bitstream-formats/bitstream-formats.component.html index b61d7ea525..896dd77b65 100644 --- a/src/app/admin/admin-registries/bitstream-formats/bitstream-formats.component.html +++ b/src/app/admin/admin-registries/bitstream-formats/bitstream-formats.component.html @@ -11,7 +11,6 @@ diff --git a/src/app/admin/admin-registries/metadata-schema/metadata-schema.component.html b/src/app/admin/admin-registries/metadata-schema/metadata-schema.component.html index 97123d29a5..f748279a1d 100644 --- a/src/app/admin/admin-registries/metadata-schema/metadata-schema.component.html +++ b/src/app/admin/admin-registries/metadata-schema/metadata-schema.component.html @@ -16,7 +16,6 @@ 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 e43c504858..20b5dc708f 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 @@ -3,7 +3,6 @@ [hidePagerWhenSinglePage]="true" [hidePaginationDetail]="true" [paginationOptions]="options" - [pageInfoState]="(objectsRD$ | async)?.payload" [collectionSize]="(objectsRD$ | async)?.payload?.totalElements">
diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.html b/src/app/item-page/full/field-components/file-section/full-file-section.component.html index 7774754079..d4b58742c4 100644 --- a/src/app/item-page/full/field-components/file-section/full-file-section.component.html +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.html @@ -6,7 +6,6 @@ [hideGear]="true" [hidePagerWhenSinglePage]="true" [paginationOptions]="originalOptions" - [pageInfoState]="originals" [collectionSize]="originals?.totalElements" [retainScrollPosition]="true"> @@ -49,7 +48,6 @@ [hideGear]="true" [hidePagerWhenSinglePage]="true" [paginationOptions]="licenseOptions" - [pageInfoState]="licenses" [collectionSize]="licenses?.totalElements" [retainScrollPosition]="true"> diff --git a/src/app/item-page/versions/item-versions.component.html b/src/app/item-page/versions/item-versions.component.html index b3c34aaf70..e1706f6b23 100644 --- a/src/app/item-page/versions/item-versions.component.html +++ b/src/app/item-page/versions/item-versions.component.html @@ -10,7 +10,6 @@ [hideGear]="true" [hidePagerWhenSinglePage]="true" [paginationOptions]="options" - [pageInfoState]="versions" [collectionSize]="versions?.totalElements" [retainScrollPosition]="true">
diff --git a/src/app/shared/object-detail/object-detail.component.html b/src/app/shared/object-detail/object-detail.component.html index d077e2fd2b..98034ca621 100644 --- a/src/app/shared/object-detail/object-detail.component.html +++ b/src/app/shared/object-detail/object-detail.component.html @@ -1,6 +1,5 @@ @@ -16,9 +15,9 @@ - - - + + +
{{ dsoNameService.getName(collection) }}
{{ dsoNameService.getName(selectCollection.dso) }}
diff --git a/src/app/shared/object-select/collection-select/collection-select.component.ts b/src/app/shared/object-select/collection-select/collection-select.component.ts index fdb3103748..4e1a095e35 100644 --- a/src/app/shared/object-select/collection-select/collection-select.component.ts +++ b/src/app/shared/object-select/collection-select/collection-select.component.ts @@ -1,10 +1,19 @@ -import { Component } from '@angular/core'; +import { + Component, + OnInit, +} from '@angular/core'; +import { Observable } from 'rxjs'; +import { map } from 'rxjs/operators'; -import { DSONameService } from '../../../core/breadcrumbs/dso-name.service'; -import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service'; +import { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths'; +import { PaginatedList } from '../../../core/data/paginated-list.model'; import { Collection } from '../../../core/shared/collection.model'; -import { isNotEmpty } from '../../empty.util'; -import { ObjectSelectService } from '../object-select.service'; +import { getAllSucceededRemoteDataPayload } from '../../../core/shared/operators'; +import { + hasValueOperator, + isNotEmpty, +} from '../../empty.util'; +import { DSpaceObjectSelect } from '../object-select.model'; import { ObjectSelectComponent } from '../object-select/object-select.component'; @Component({ @@ -16,21 +25,29 @@ import { ObjectSelectComponent } from '../object-select/object-select.component' /** * A component used to select collections from a specific list and returning the UUIDs of the selected collections */ -export class CollectionSelectComponent extends ObjectSelectComponent { +export class CollectionSelectComponent extends ObjectSelectComponent implements OnInit { - constructor( - protected objectSelectService: ObjectSelectService, - protected authorizationService: AuthorizationDataService, - public dsoNameService: DSONameService, - ) { - super(objectSelectService, authorizationService); - } + /** + * Collection of all the data that is used to display the {@link Collection} in the HTML. + * By collecting this data here it doesn't need to be recalculated on evey change detection. + */ + selectCollections$: Observable[]>; ngOnInit(): void { super.ngOnInit(); if (!isNotEmpty(this.confirmButton)) { this.confirmButton = 'collection.select.confirm'; } + this.selectCollections$ = this.dsoRD$.pipe( + hasValueOperator(), + getAllSucceededRemoteDataPayload(), + map((collections: PaginatedList) => collections.page.map((collection: Collection) => Object.assign(new DSpaceObjectSelect(), { + dso: collection, + canSelect$: this.canSelect(collection), + selected$: this.getSelected(collection.id), + route: getCollectionPageRoute(collection.id), + } as DSpaceObjectSelect))), + ); } } diff --git a/src/app/shared/object-select/item-select/item-select.component.html b/src/app/shared/object-select/item-select/item-select.component.html index 54ce54d9f3..8271633bcf 100644 --- a/src/app/shared/object-select/item-select/item-select.component.html +++ b/src/app/shared/object-select/item-select/item-select.component.html @@ -3,7 +3,6 @@ *ngIf="itemsRD?.payload?.totalElements > 0" [paginationOptions]="paginationOptions" [sortOptions]="sortOptions" - [pageInfoState]="itemsRD?.payload" [collectionSize]="itemsRD?.payload?.totalElements" [hidePagerWhenSinglePage]="true" [hideGear]="true"> @@ -18,17 +17,17 @@ - - + + - + {{ dsoNameService.getName(collection) }} - {{item.firstMetadataValue(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])}} - {{ dsoNameService.getName(item) }} + {{selectItem.dso.firstMetadataValue(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])}} + {{ dsoNameService.getName(selectItem.dso) }} diff --git a/src/app/shared/object-select/item-select/item-select.component.spec.ts b/src/app/shared/object-select/item-select/item-select.component.spec.ts index 4969121bf8..060c96c9e1 100644 --- a/src/app/shared/object-select/item-select/item-select.component.spec.ts +++ b/src/app/shared/object-select/item-select/item-select.component.spec.ts @@ -189,15 +189,16 @@ describe('ItemSelectComponent', () => { beforeEach(() => { comp.featureId = FeatureID.CanManageMappings; spyOn(authorizationDataService, 'isAuthorized').and.returnValue(of(false)); + comp.ngOnInit(); }); - it('should disable the checkbox', waitForAsync(() => { + it('should disable the checkbox', waitForAsync(async () => { fixture.detectChanges(); - fixture.whenStable().then(() => { - const checkbox = fixture.debugElement.query(By.css('input.item-checkbox')).nativeElement; - expect(authorizationDataService.isAuthorized).toHaveBeenCalled(); - expect(checkbox.disabled).toBeTrue(); - }); + await fixture.whenStable(); + + const checkbox = fixture.debugElement.query(By.css('input.item-checkbox')).nativeElement; + expect(authorizationDataService.isAuthorized).toHaveBeenCalled(); + expect(checkbox.disabled).toBeTrue(); })); }); }); diff --git a/src/app/shared/object-select/item-select/item-select.component.ts b/src/app/shared/object-select/item-select/item-select.component.ts index 18eda8374f..5b9f87744f 100644 --- a/src/app/shared/object-select/item-select/item-select.component.ts +++ b/src/app/shared/object-select/item-select/item-select.component.ts @@ -1,12 +1,12 @@ import { Component, Input, + OnInit, } from '@angular/core'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { DSONameService } from '../../../core/breadcrumbs/dso-name.service'; -import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service'; +import { PaginatedList } from '../../../core/data/paginated-list.model'; import { Item } from '../../../core/shared/item.model'; import { getAllSucceededRemoteDataPayload } from '../../../core/shared/operators'; import { getItemPageRoute } from '../../../item-page/item-page-routing-paths'; @@ -14,7 +14,7 @@ import { hasValueOperator, isNotEmpty, } from '../../empty.util'; -import { ObjectSelectService } from '../object-select.service'; +import { DSpaceObjectSelect } from '../object-select.model'; import { ObjectSelectComponent } from '../object-select/object-select.component'; @Component({ @@ -25,7 +25,7 @@ import { ObjectSelectComponent } from '../object-select/object-select.component' /** * A component used to select items from a specific list and returning the UUIDs of the selected items */ -export class ItemSelectComponent extends ObjectSelectComponent { +export class ItemSelectComponent extends ObjectSelectComponent implements OnInit { /** * Whether or not to hide the collection column @@ -34,35 +34,25 @@ export class ItemSelectComponent extends ObjectSelectComponent { hideCollection = false; /** - * The routes to the items their pages - * Key: Item ID - * Value: Route to item page + * Collection of all the data that is used to display the {@link Item} in the HTML. + * By collecting this data here it doesn't need to be recalculated on evey change detection. */ - itemPageRoutes$: Observable<{ - [itemId: string]: string - }>; - - constructor( - protected objectSelectService: ObjectSelectService, - protected authorizationService: AuthorizationDataService, - public dsoNameService: DSONameService, - ) { - super(objectSelectService, authorizationService); - } + selectItems$: Observable[]>; ngOnInit(): void { super.ngOnInit(); if (!isNotEmpty(this.confirmButton)) { this.confirmButton = 'item.select.confirm'; } - this.itemPageRoutes$ = this.dsoRD$.pipe( + this.selectItems$ = this.dsoRD$.pipe( hasValueOperator(), getAllSucceededRemoteDataPayload(), - map((items) => { - const itemPageRoutes = {}; - items.page.forEach((item) => itemPageRoutes[item.uuid] = getItemPageRoute(item)); - return itemPageRoutes; - }), + map((items: PaginatedList) => items.page.map((item: Item) => Object.assign(new DSpaceObjectSelect(), { + dso: item, + canSelect$: this.canSelect(item), + selected$: this.getSelected(item.id), + route: getItemPageRoute(item), + } as DSpaceObjectSelect))), ); } diff --git a/src/app/shared/object-select/object-select.model.ts b/src/app/shared/object-select/object-select.model.ts new file mode 100644 index 0000000000..e3b66dac31 --- /dev/null +++ b/src/app/shared/object-select/object-select.model.ts @@ -0,0 +1,30 @@ +import { Observable } from 'rxjs'; + +import { DSpaceObject } from '../../core/shared/dspace-object.model'; + +/** + * Class used to collect all the data that that is used by the {@link ObjectSelectComponent} in the HTML. + */ +export class DSpaceObjectSelect { + + /** + * The {@link DSpaceObject} to display + */ + dso: T; + + /** + * Whether the {@link DSpaceObject} can be selected + */ + canSelect$: Observable; + + /** + * Whether the {@link DSpaceObject} is selected + */ + selected$: Observable; + + /** + * The {@link DSpaceObject}'s route + */ + route: string; + +} diff --git a/src/app/shared/object-select/object-select/object-select.component.ts b/src/app/shared/object-select/object-select/object-select.component.ts index 12a4baf66a..78acfea18b 100644 --- a/src/app/shared/object-select/object-select/object-select.component.ts +++ b/src/app/shared/object-select/object-select/object-select.component.ts @@ -15,6 +15,7 @@ import { take, } from 'rxjs/operators'; +import { DSONameService } from '../../../core/breadcrumbs/dso-name.service'; import { SortOptions } from '../../../core/cache/models/sort-options.model'; import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service'; import { FeatureID } from '../../../core/data/feature-authorization/feature-id'; @@ -31,7 +32,7 @@ import { ObjectSelectService } from '../object-select.service'; selector: 'ds-object-select-abstract', template: '', }) -export abstract class ObjectSelectComponent implements OnInit, OnDestroy { +export abstract class ObjectSelectComponent implements OnInit, OnDestroy { /** * A unique key used for the object select service @@ -102,8 +103,11 @@ export abstract class ObjectSelectComponent implements OnInit, OnDestro */ selectedIds$: Observable; - constructor(protected objectSelectService: ObjectSelectService, - protected authorizationService: AuthorizationDataService) { + constructor( + protected objectSelectService: ObjectSelectService, + protected authorizationService: AuthorizationDataService, + public dsoNameService: DSONameService, + ) { } ngOnInit(): void { diff --git a/src/app/shared/object-table/object-table.component.html b/src/app/shared/object-table/object-table.component.html index 39743a5922..506eaaf505 100644 --- a/src/app/shared/object-table/object-table.component.html +++ b/src/app/shared/object-table/object-table.component.html @@ -1,6 +1,5 @@ = undefined; - /** * Configuration for the NgbPagination component. */ @@ -151,18 +144,13 @@ export class PaginationComponent implements OnDestroy, OnInit { /** * Current page. */ - public currentPage$; + public currentPage$: Observable; /** * Current page in the state of a Remote paginated objects. */ public currentPageState: number = undefined; - /** - * An observable of HostWindowState type - */ - public hostWindow: Observable; - /** * ID for the pagination instance. This ID is used in the routing to retrieve the pagination options. * This ID needs to be unique between different pagination components when more than one will be displayed on the same page. @@ -252,7 +240,7 @@ export class PaginationComponent implements OnDestroy, OnInit { map((currentPagination) => currentPagination.pageSize), ); - let sortOptions; + let sortOptions: SortOptions; if (this.sortOptions) { sortOptions = this.sortOptions; } else { @@ -266,16 +254,6 @@ export class PaginationComponent implements OnDestroy, OnInit { ); } - /** - * @param cdRef - * ChangeDetectorRef is a singleton service provided by Angular. - * @param route - * Route is a singleton service provided by Angular. - * @param router - * Router is a singleton service provided by Angular. - * @param hostWindowService - * the HostWindowService singleton. - */ constructor(private cdRef: ChangeDetectorRef, private paginationService: PaginationService, public hostWindowService: HostWindowService) { @@ -314,17 +292,6 @@ export class PaginationComponent implements OnDestroy, OnInit { this.emitPaginationChange(); } - /** - * Method to change the route to the given sort field - * - * @param sortField - * The sort field being navigated to. - */ - public doSortFieldChange(field: string) { - this.updateParams({ page: 1, sortField: field }); - this.emitPaginationChange(); - } - /** * Method to emit a general pagination change event */ @@ -348,10 +315,10 @@ export class PaginationComponent implements OnDestroy, OnInit { if (collectionSize) { showingDetails = this.paginationService.getCurrentPagination(this.id, this.paginationOptions).pipe( map((currentPaginationOptions) => { - let lastItem; + let lastItem: number; const pageMax = currentPaginationOptions.pageSize * currentPaginationOptions.currentPage; - const firstItem = currentPaginationOptions.pageSize * (currentPaginationOptions.currentPage - 1) + 1; + const firstItem: number = currentPaginationOptions.pageSize * (currentPaginationOptions.currentPage - 1) + 1; if (collectionSize > pageMax) { lastItem = pageMax; } else {