mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +00:00
Merge branch 'fix-broken-item-mapper-pagination_contribute-7.6' into fix-broken-item-mapper-pagination_contribute-main
# Conflicts: # src/app/access-control/bulk-access/browse/bulk-access-browse.component.html # src/app/access-control/epeople-registry/epeople-registry.component.html # src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html # src/app/access-control/group-registry/group-form/members-list/members-list.component.html # src/app/access-control/group-registry/group-form/subgroup-list/subgroups-list.component.html # src/app/process-page/overview/process-overview.component.html # src/app/shared/object-select/collection-select/collection-select.component.html # src/app/shared/object-select/collection-select/collection-select.component.ts # src/app/shared/object-select/item-select/item-select.component.html # src/app/shared/object-select/item-select/item-select.component.ts # src/app/shared/object-select/object-select/object-select.component.ts # src/app/shared/pagination/pagination.component.ts
This commit is contained in:
@@ -37,7 +37,6 @@
|
|||||||
<ng-template ngbNavContent>
|
<ng-template ngbNavContent>
|
||||||
<ds-pagination
|
<ds-pagination
|
||||||
[paginationOptions]="(paginationOptions$ | async)"
|
[paginationOptions]="(paginationOptions$ | async)"
|
||||||
[pageInfoState]="(objectsSelected$|async)?.payload.pageInfo"
|
|
||||||
[collectionSize]="(objectsSelected$|async)?.payload?.totalElements"
|
[collectionSize]="(objectsSelected$|async)?.payload?.totalElements"
|
||||||
[objects]="(objectsSelected$|async)"
|
[objects]="(objectsSelected$|async)"
|
||||||
[showPaginator]="false"
|
[showPaginator]="false"
|
||||||
|
@@ -45,7 +45,6 @@
|
|||||||
<ds-pagination
|
<ds-pagination
|
||||||
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && (searching$ | async) !== true"
|
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && (searching$ | async) !== true"
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="pageInfoState$"
|
|
||||||
[collectionSize]="(pageInfoState$ | async)?.totalElements"
|
[collectionSize]="(pageInfoState$ | async)?.totalElements"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
@@ -52,7 +52,6 @@
|
|||||||
<ds-pagination
|
<ds-pagination
|
||||||
*ngIf="(groups$ | async)?.payload?.totalElements > 0"
|
*ngIf="(groups$ | async)?.payload?.totalElements > 0"
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="groupsPageInfoState$"
|
|
||||||
[collectionSize]="(groups$ | async)?.payload?.totalElements"
|
[collectionSize]="(groups$ | async)?.payload?.totalElements"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true"
|
[hidePagerWhenSinglePage]="true"
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
<ds-pagination *ngIf="(ePeopleMembersOfGroup | async)?.totalElements > 0"
|
<ds-pagination *ngIf="(ePeopleMembersOfGroup | async)?.totalElements > 0"
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="(ePeopleMembersOfGroup | async)"
|
|
||||||
[collectionSize]="(ePeopleMembersOfGroup | async)?.totalElements"
|
[collectionSize]="(ePeopleMembersOfGroup | async)?.totalElements"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
@@ -86,7 +85,6 @@
|
|||||||
|
|
||||||
<ds-pagination *ngIf="(ePeopleSearch | async)?.totalElements > 0"
|
<ds-pagination *ngIf="(ePeopleSearch | async)?.totalElements > 0"
|
||||||
[paginationOptions]="configSearch"
|
[paginationOptions]="configSearch"
|
||||||
[pageInfoState]="(ePeopleSearch | async)"
|
|
||||||
[collectionSize]="(ePeopleSearch | async)?.totalElements"
|
[collectionSize]="(ePeopleSearch | async)?.totalElements"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
|
|
||||||
<ds-pagination *ngIf="(subGroups$ | async)?.payload?.totalElements > 0"
|
<ds-pagination *ngIf="(subGroups$ | async)?.payload?.totalElements > 0"
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="(subGroups$ | async)?.payload"
|
|
||||||
[collectionSize]="(subGroups$ | async)?.payload?.totalElements"
|
[collectionSize]="(subGroups$ | async)?.payload?.totalElements"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
@@ -84,7 +83,6 @@
|
|||||||
|
|
||||||
<ds-pagination *ngIf="(searchResults$ | async)?.payload?.totalElements > 0"
|
<ds-pagination *ngIf="(searchResults$ | async)?.payload?.totalElements > 0"
|
||||||
[paginationOptions]="configSearch"
|
[paginationOptions]="configSearch"
|
||||||
[pageInfoState]="(searchResults$ | async)?.payload"
|
|
||||||
[collectionSize]="(searchResults$ | async)?.payload?.totalElements"
|
[collectionSize]="(searchResults$ | async)?.payload?.totalElements"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
@@ -37,7 +37,6 @@
|
|||||||
<ds-pagination
|
<ds-pagination
|
||||||
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && (loading$ | async) !== true"
|
*ngIf="(pageInfoState$ | async)?.totalElements > 0 && (loading$ | async) !== true"
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="pageInfoState$"
|
|
||||||
[collectionSize]="(pageInfoState$ | async)?.totalElements"
|
[collectionSize]="(pageInfoState$ | async)?.totalElements"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
[collectionSize]="(ldnServicesRD$ | async)?.payload?.totalElements"
|
[collectionSize]="(ldnServicesRD$ | async)?.payload?.totalElements"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true"
|
[hidePagerWhenSinglePage]="true"
|
||||||
[pageInfoState]="(ldnServicesRD$ | async)?.payload"
|
|
||||||
[paginationOptions]="pageConfig">
|
[paginationOptions]="pageConfig">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
<ds-pagination
|
<ds-pagination
|
||||||
*ngIf="(bitstreamFormats | async)?.payload?.totalElements > 0"
|
*ngIf="(bitstreamFormats | async)?.payload?.totalElements > 0"
|
||||||
[paginationOptions]="pageConfig"
|
[paginationOptions]="pageConfig"
|
||||||
[pageInfoState]="(bitstreamFormats | async)?.payload"
|
|
||||||
[collectionSize]="(bitstreamFormats | async)?.payload?.totalElements"
|
[collectionSize]="(bitstreamFormats | async)?.payload?.totalElements"
|
||||||
[hideGear]="false"
|
[hideGear]="false"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
<ds-pagination
|
<ds-pagination
|
||||||
*ngIf="fields?.totalElements > 0"
|
*ngIf="fields?.totalElements > 0"
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="fields"
|
|
||||||
[collectionSize]="fields?.totalElements"
|
[collectionSize]="fields?.totalElements"
|
||||||
[hideGear]="false"
|
[hideGear]="false"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
[hidePagerWhenSinglePage]="true"
|
[hidePagerWhenSinglePage]="true"
|
||||||
[hidePaginationDetail]="true"
|
[hidePaginationDetail]="true"
|
||||||
[paginationOptions]="options"
|
[paginationOptions]="options"
|
||||||
[pageInfoState]="(objectsRD$ | async)?.payload"
|
|
||||||
[collectionSize]="(objectsRD$ | async)?.payload?.totalElements">
|
[collectionSize]="(objectsRD$ | async)?.payload?.totalElements">
|
||||||
<ng-container *ngIf="(loading$ | async) !== true">
|
<ng-container *ngIf="(loading$ | async) !== true">
|
||||||
<div [id]="bundle.id" class="bundle-bitstreams-list"
|
<div [id]="bundle.id" class="bundle-bitstreams-list"
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
<ng-container *ngVar="updates | dsObjectValues as updateValues">
|
<ng-container *ngVar="updates | dsObjectValues as updateValues">
|
||||||
<ds-pagination
|
<ds-pagination
|
||||||
[paginationOptions]="paginationConfig"
|
[paginationOptions]="paginationConfig"
|
||||||
[pageInfoState]="(relationshipsRd$ | async)?.payload?.pageInfo"
|
|
||||||
[collectionSize]="(relationshipsRd$ | async)?.payload?.totalElements + (this.nbAddedFields$ | async)"
|
[collectionSize]="(relationshipsRd$ | async)?.payload?.totalElements + (this.nbAddedFields$ | async)"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true">
|
[hidePagerWhenSinglePage]="true">
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true"
|
[hidePagerWhenSinglePage]="true"
|
||||||
[paginationOptions]="originalOptions"
|
[paginationOptions]="originalOptions"
|
||||||
[pageInfoState]="originals"
|
|
||||||
[collectionSize]="originals?.totalElements"
|
[collectionSize]="originals?.totalElements"
|
||||||
[retainScrollPosition]="true">
|
[retainScrollPosition]="true">
|
||||||
|
|
||||||
@@ -49,7 +48,6 @@
|
|||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true"
|
[hidePagerWhenSinglePage]="true"
|
||||||
[paginationOptions]="licenseOptions"
|
[paginationOptions]="licenseOptions"
|
||||||
[pageInfoState]="licenses"
|
|
||||||
[collectionSize]="licenses?.totalElements"
|
[collectionSize]="licenses?.totalElements"
|
||||||
[retainScrollPosition]="true">
|
[retainScrollPosition]="true">
|
||||||
|
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true"
|
[hidePagerWhenSinglePage]="true"
|
||||||
[paginationOptions]="options"
|
[paginationOptions]="options"
|
||||||
[pageInfoState]="versions"
|
|
||||||
[collectionSize]="versions?.totalElements"
|
[collectionSize]="versions?.totalElements"
|
||||||
[retainScrollPosition]="true">
|
[retainScrollPosition]="true">
|
||||||
<table class="table table-striped table-bordered align-middle my-2">
|
<table class="table table-striped table-bordered align-middle my-2">
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
<ds-pagination
|
<ds-pagination
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="objects?.payload"
|
|
||||||
[collectionSize]="objects?.payload?.totalElements"
|
[collectionSize]="objects?.payload?.totalElements"
|
||||||
[sortOptions]="sortConfig"
|
[sortOptions]="sortConfig"
|
||||||
[objects]="objects"
|
[objects]="objects"
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
<ds-pagination
|
<ds-pagination
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="objects?.payload"
|
|
||||||
[collectionSize]="objects?.payload?.totalElements"
|
[collectionSize]="objects?.payload?.totalElements"
|
||||||
[sortOptions]="sortConfig"
|
[sortOptions]="sortConfig"
|
||||||
[hideGear]="hideGear"
|
[hideGear]="hideGear"
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
<ds-pagination
|
<ds-pagination
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="objects?.payload"
|
|
||||||
[collectionSize]="objects?.payload?.totalElements"
|
[collectionSize]="objects?.payload?.totalElements"
|
||||||
[objects]="objects"
|
[objects]="objects"
|
||||||
[sortOptions]="sortConfig"
|
[sortOptions]="sortConfig"
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
*ngIf="collectionsRD?.payload?.totalElements > 0 || collectionsRD?.payload?.page?.length > 0"
|
*ngIf="collectionsRD?.payload?.totalElements > 0 || collectionsRD?.payload?.page?.length > 0"
|
||||||
[paginationOptions]="paginationOptions"
|
[paginationOptions]="paginationOptions"
|
||||||
[sortOptions]="sortOptions"
|
[sortOptions]="sortOptions"
|
||||||
[pageInfoState]="collectionsRD?.payload"
|
|
||||||
[collectionSize]="collectionsRD?.payload?.totalElements"
|
[collectionSize]="collectionsRD?.payload?.totalElements"
|
||||||
[hidePagerWhenSinglePage]="true"
|
[hidePagerWhenSinglePage]="true"
|
||||||
[hideGear]="true">
|
[hideGear]="true">
|
||||||
@@ -16,9 +15,9 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let collection of collectionsRD?.payload?.page">
|
<tr *ngFor="let selectCollection of selectCollections$ | async">
|
||||||
<td><input #selectCollectionBtn [attr.aria-label]="(selectCollectionBtn.checked ? 'collection.select.table.deselect' : 'collection.select.table.select') | translate" class="collection-checkbox" [ngModel]="getSelected(collection.id) | async" (change)="switch(collection.id)" type="checkbox" name="{{collection.id}}"></td>
|
<td><input #selectCollectionBtn [attr.aria-label]="(selectCollectionBtn.checked ? 'collection.select.table.deselect' : 'collection.select.table.select') | translate" [disabled]="(selectCollection.canSelect$ | async) === false" class="collection-checkbox" [ngModel]="selectCollection.selected$ | async" (change)="switch(selectCollection.dso.id)" type="checkbox" name="{{selectCollection.dso.id}}"></td>
|
||||||
<td><a [routerLink]="['/collections', collection.id]">{{ dsoNameService.getName(collection) }}</a></td>
|
<td><a [routerLink]="selectCollection.route">{{ dsoNameService.getName(selectCollection.dso) }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@@ -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 { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths';
|
||||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||||
import { Collection } from '../../../core/shared/collection.model';
|
import { Collection } from '../../../core/shared/collection.model';
|
||||||
import { isNotEmpty } from '../../empty.util';
|
import { getAllSucceededRemoteDataPayload } from '../../../core/shared/operators';
|
||||||
import { ObjectSelectService } from '../object-select.service';
|
import {
|
||||||
|
hasValueOperator,
|
||||||
|
isNotEmpty,
|
||||||
|
} from '../../empty.util';
|
||||||
|
import { DSpaceObjectSelect } from '../object-select.model';
|
||||||
import { ObjectSelectComponent } from '../object-select/object-select.component';
|
import { ObjectSelectComponent } from '../object-select/object-select.component';
|
||||||
|
|
||||||
@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
|
* A component used to select collections from a specific list and returning the UUIDs of the selected collections
|
||||||
*/
|
*/
|
||||||
export class CollectionSelectComponent extends ObjectSelectComponent<Collection> {
|
export class CollectionSelectComponent extends ObjectSelectComponent<Collection> implements OnInit {
|
||||||
|
|
||||||
constructor(
|
/**
|
||||||
protected objectSelectService: ObjectSelectService,
|
* Collection of all the data that is used to display the {@link Collection} in the HTML.
|
||||||
protected authorizationService: AuthorizationDataService,
|
* By collecting this data here it doesn't need to be recalculated on evey change detection.
|
||||||
public dsoNameService: DSONameService,
|
*/
|
||||||
) {
|
selectCollections$: Observable<DSpaceObjectSelect<Collection>[]>;
|
||||||
super(objectSelectService, authorizationService);
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
if (!isNotEmpty(this.confirmButton)) {
|
if (!isNotEmpty(this.confirmButton)) {
|
||||||
this.confirmButton = 'collection.select.confirm';
|
this.confirmButton = 'collection.select.confirm';
|
||||||
}
|
}
|
||||||
|
this.selectCollections$ = this.dsoRD$.pipe(
|
||||||
|
hasValueOperator(),
|
||||||
|
getAllSucceededRemoteDataPayload(),
|
||||||
|
map((collections: PaginatedList<Collection>) => collections.page.map((collection: Collection) => Object.assign(new DSpaceObjectSelect<Collection>(), {
|
||||||
|
dso: collection,
|
||||||
|
canSelect$: this.canSelect(collection),
|
||||||
|
selected$: this.getSelected(collection.id),
|
||||||
|
route: getCollectionPageRoute(collection.id),
|
||||||
|
} as DSpaceObjectSelect<Collection>))),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
*ngIf="itemsRD?.payload?.totalElements > 0"
|
*ngIf="itemsRD?.payload?.totalElements > 0"
|
||||||
[paginationOptions]="paginationOptions"
|
[paginationOptions]="paginationOptions"
|
||||||
[sortOptions]="sortOptions"
|
[sortOptions]="sortOptions"
|
||||||
[pageInfoState]="itemsRD?.payload"
|
|
||||||
[collectionSize]="itemsRD?.payload?.totalElements"
|
[collectionSize]="itemsRD?.payload?.totalElements"
|
||||||
[hidePagerWhenSinglePage]="true"
|
[hidePagerWhenSinglePage]="true"
|
||||||
[hideGear]="true">
|
[hideGear]="true">
|
||||||
@@ -18,17 +17,17 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let item of itemsRD?.payload?.page">
|
<tr *ngFor="let selectItem of selectItems$ | async">
|
||||||
<td><input #selectItemBtn [attr.aria-label]="(selectItemBtn.checked ? 'item.select.table.deselect' : 'item.select.table.select') | translate" [disabled]="(canSelect(item) | async) !== true" class="item-checkbox" [ngModel]="getSelected(item.id) | async" (change)="switch(item.id)" type="checkbox" name="{{item.id}}"></td>
|
<td><input #selectItemBtn [attr.aria-label]="(selectItemBtn.checked ? 'item.select.table.deselect' : 'item.select.table.select') | translate" [disabled]="(selectItem.canSelect$ | async) === false" class="item-checkbox" [ngModel]="selectItem.selected$ | async" (change)="switch(selectItem.dso.id)" type="checkbox" name="{{selectItem.dso.id}}"></td>
|
||||||
<td *ngIf="!hideCollection">
|
<td *ngIf="!hideCollection">
|
||||||
<span *ngVar="(item.owningCollection | async)?.payload as collection">
|
<span *ngVar="(selectItem.dso.owningCollection | async)?.payload as collection">
|
||||||
<a *ngIf="collection" [routerLink]="['/collections', collection?.id]">
|
<a *ngIf="collection" [routerLink]="['/collections', collection?.id]">
|
||||||
{{ dsoNameService.getName(collection) }}
|
{{ dsoNameService.getName(collection) }}
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td><span *ngIf="item.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])">{{item.firstMetadataValue(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])}}</span></td>
|
<td><span *ngIf="selectItem.dso.hasMetadata(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])">{{selectItem.dso.firstMetadataValue(['dc.contributor.author', 'dc.creator', 'dc.contributor.*'])}}</span></td>
|
||||||
<td><a [routerLink]="[(itemPageRoutes$ | async)[item.id]]">{{ dsoNameService.getName(item) }}</a></td>
|
<td><a [routerLink]="selectItem.route">{{ dsoNameService.getName(selectItem.dso) }}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@@ -189,15 +189,16 @@ describe('ItemSelectComponent', () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
comp.featureId = FeatureID.CanManageMappings;
|
comp.featureId = FeatureID.CanManageMappings;
|
||||||
spyOn(authorizationDataService, 'isAuthorized').and.returnValue(of(false));
|
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.detectChanges();
|
||||||
fixture.whenStable().then(() => {
|
await fixture.whenStable();
|
||||||
|
|
||||||
const checkbox = fixture.debugElement.query(By.css('input.item-checkbox')).nativeElement;
|
const checkbox = fixture.debugElement.query(By.css('input.item-checkbox')).nativeElement;
|
||||||
expect(authorizationDataService.isAuthorized).toHaveBeenCalled();
|
expect(authorizationDataService.isAuthorized).toHaveBeenCalled();
|
||||||
expect(checkbox.disabled).toBeTrue();
|
expect(checkbox.disabled).toBeTrue();
|
||||||
});
|
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
import {
|
import {
|
||||||
Component,
|
Component,
|
||||||
Input,
|
Input,
|
||||||
|
OnInit,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
import { PaginatedList } from '../../../core/data/paginated-list.model';
|
||||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
|
||||||
import { Item } from '../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { getAllSucceededRemoteDataPayload } from '../../../core/shared/operators';
|
import { getAllSucceededRemoteDataPayload } from '../../../core/shared/operators';
|
||||||
import { getItemPageRoute } from '../../../item-page/item-page-routing-paths';
|
import { getItemPageRoute } from '../../../item-page/item-page-routing-paths';
|
||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
hasValueOperator,
|
hasValueOperator,
|
||||||
isNotEmpty,
|
isNotEmpty,
|
||||||
} from '../../empty.util';
|
} from '../../empty.util';
|
||||||
import { ObjectSelectService } from '../object-select.service';
|
import { DSpaceObjectSelect } from '../object-select.model';
|
||||||
import { ObjectSelectComponent } from '../object-select/object-select.component';
|
import { ObjectSelectComponent } from '../object-select/object-select.component';
|
||||||
|
|
||||||
@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
|
* A component used to select items from a specific list and returning the UUIDs of the selected items
|
||||||
*/
|
*/
|
||||||
export class ItemSelectComponent extends ObjectSelectComponent<Item> {
|
export class ItemSelectComponent extends ObjectSelectComponent<Item> implements OnInit {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not to hide the collection column
|
* Whether or not to hide the collection column
|
||||||
@@ -34,35 +34,25 @@ export class ItemSelectComponent extends ObjectSelectComponent<Item> {
|
|||||||
hideCollection = false;
|
hideCollection = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The routes to the items their pages
|
* Collection of all the data that is used to display the {@link Item} in the HTML.
|
||||||
* Key: Item ID
|
* By collecting this data here it doesn't need to be recalculated on evey change detection.
|
||||||
* Value: Route to item page
|
|
||||||
*/
|
*/
|
||||||
itemPageRoutes$: Observable<{
|
selectItems$: Observable<DSpaceObjectSelect<Item>[]>;
|
||||||
[itemId: string]: string
|
|
||||||
}>;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
protected objectSelectService: ObjectSelectService,
|
|
||||||
protected authorizationService: AuthorizationDataService,
|
|
||||||
public dsoNameService: DSONameService,
|
|
||||||
) {
|
|
||||||
super(objectSelectService, authorizationService);
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
super.ngOnInit();
|
super.ngOnInit();
|
||||||
if (!isNotEmpty(this.confirmButton)) {
|
if (!isNotEmpty(this.confirmButton)) {
|
||||||
this.confirmButton = 'item.select.confirm';
|
this.confirmButton = 'item.select.confirm';
|
||||||
}
|
}
|
||||||
this.itemPageRoutes$ = this.dsoRD$.pipe(
|
this.selectItems$ = this.dsoRD$.pipe(
|
||||||
hasValueOperator(),
|
hasValueOperator(),
|
||||||
getAllSucceededRemoteDataPayload(),
|
getAllSucceededRemoteDataPayload(),
|
||||||
map((items) => {
|
map((items: PaginatedList<Item>) => items.page.map((item: Item) => Object.assign(new DSpaceObjectSelect<Item>(), {
|
||||||
const itemPageRoutes = {};
|
dso: item,
|
||||||
items.page.forEach((item) => itemPageRoutes[item.uuid] = getItemPageRoute(item));
|
canSelect$: this.canSelect(item),
|
||||||
return itemPageRoutes;
|
selected$: this.getSelected(item.id),
|
||||||
}),
|
route: getItemPageRoute(item),
|
||||||
|
} as DSpaceObjectSelect<Item>))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
30
src/app/shared/object-select/object-select.model.ts
Normal file
30
src/app/shared/object-select/object-select.model.ts
Normal file
@@ -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<T extends DSpaceObject> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link DSpaceObject} to display
|
||||||
|
*/
|
||||||
|
dso: T;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the {@link DSpaceObject} can be selected
|
||||||
|
*/
|
||||||
|
canSelect$: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the {@link DSpaceObject} is selected
|
||||||
|
*/
|
||||||
|
selected$: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link DSpaceObject}'s route
|
||||||
|
*/
|
||||||
|
route: string;
|
||||||
|
|
||||||
|
}
|
@@ -15,6 +15,7 @@ import {
|
|||||||
take,
|
take,
|
||||||
} from 'rxjs/operators';
|
} from 'rxjs/operators';
|
||||||
|
|
||||||
|
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
|
||||||
import { SortOptions } from '../../../core/cache/models/sort-options.model';
|
import { SortOptions } from '../../../core/cache/models/sort-options.model';
|
||||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||||
@@ -31,7 +32,7 @@ import { ObjectSelectService } from '../object-select.service';
|
|||||||
selector: 'ds-object-select-abstract',
|
selector: 'ds-object-select-abstract',
|
||||||
template: '',
|
template: '',
|
||||||
})
|
})
|
||||||
export abstract class ObjectSelectComponent<TDomain> implements OnInit, OnDestroy {
|
export abstract class ObjectSelectComponent<TDomain extends DSpaceObject> implements OnInit, OnDestroy {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A unique key used for the object select service
|
* A unique key used for the object select service
|
||||||
@@ -102,8 +103,11 @@ export abstract class ObjectSelectComponent<TDomain> implements OnInit, OnDestro
|
|||||||
*/
|
*/
|
||||||
selectedIds$: Observable<string[]>;
|
selectedIds$: Observable<string[]>;
|
||||||
|
|
||||||
constructor(protected objectSelectService: ObjectSelectService,
|
constructor(
|
||||||
protected authorizationService: AuthorizationDataService) {
|
protected objectSelectService: ObjectSelectService,
|
||||||
|
protected authorizationService: AuthorizationDataService,
|
||||||
|
public dsoNameService: DSONameService,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
<ds-pagination
|
<ds-pagination
|
||||||
[paginationOptions]="config"
|
[paginationOptions]="config"
|
||||||
[pageInfoState]="objects?.payload"
|
|
||||||
[collectionSize]="objects?.payload?.totalElements"
|
[collectionSize]="objects?.payload?.totalElements"
|
||||||
[sortOptions]="sortConfig"
|
[sortOptions]="sortConfig"
|
||||||
[hideGear]="hideGear"
|
[hideGear]="hideGear"
|
||||||
|
@@ -27,12 +27,10 @@ import { PaginatedList } from '../../core/data/paginated-list.model';
|
|||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { PaginationService } from '../../core/pagination/pagination.service';
|
import { PaginationService } from '../../core/pagination/pagination.service';
|
||||||
import { PaginationRouteParams } from '../../core/pagination/pagination-route-params.interface';
|
import { PaginationRouteParams } from '../../core/pagination/pagination-route-params.interface';
|
||||||
import { PageInfo } from '../../core/shared/page-info.model';
|
|
||||||
import { ViewMode } from '../../core/shared/view-mode.model';
|
import { ViewMode } from '../../core/shared/view-mode.model';
|
||||||
import { hasValue } from '../empty.util';
|
import { hasValue } from '../empty.util';
|
||||||
import { HostWindowService } from '../host-window.service';
|
import { HostWindowService } from '../host-window.service';
|
||||||
import { ListableObject } from '../object-collection/shared/listable-object.model';
|
import { ListableObject } from '../object-collection/shared/listable-object.model';
|
||||||
import { HostWindowState } from '../search/host-window.reducer';
|
|
||||||
import { PaginationComponentOptions } from './pagination-component-options.model';
|
import { PaginationComponentOptions } from './pagination-component-options.model';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,11 +55,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
|||||||
*/
|
*/
|
||||||
@Input() collectionSize: number;
|
@Input() collectionSize: number;
|
||||||
|
|
||||||
/**
|
|
||||||
* Page state of a Remote paginated objects.
|
|
||||||
*/
|
|
||||||
@Input() pageInfoState: Observable<PageInfo> = undefined;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration for the NgbPagination component.
|
* Configuration for the NgbPagination component.
|
||||||
*/
|
*/
|
||||||
@@ -151,18 +144,13 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
|||||||
/**
|
/**
|
||||||
* Current page.
|
* Current page.
|
||||||
*/
|
*/
|
||||||
public currentPage$;
|
public currentPage$: Observable<number>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current page in the state of a Remote paginated objects.
|
* Current page in the state of a Remote paginated objects.
|
||||||
*/
|
*/
|
||||||
public currentPageState: number = undefined;
|
public currentPageState: number = undefined;
|
||||||
|
|
||||||
/**
|
|
||||||
* An observable of HostWindowState type
|
|
||||||
*/
|
|
||||||
public hostWindow: Observable<HostWindowState>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID for the pagination instance. This ID is used in the routing to retrieve the pagination options.
|
* 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.
|
* 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),
|
map((currentPagination) => currentPagination.pageSize),
|
||||||
);
|
);
|
||||||
|
|
||||||
let sortOptions;
|
let sortOptions: SortOptions;
|
||||||
if (this.sortOptions) {
|
if (this.sortOptions) {
|
||||||
sortOptions = this.sortOptions;
|
sortOptions = this.sortOptions;
|
||||||
} else {
|
} 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,
|
constructor(private cdRef: ChangeDetectorRef,
|
||||||
private paginationService: PaginationService,
|
private paginationService: PaginationService,
|
||||||
public hostWindowService: HostWindowService) {
|
public hostWindowService: HostWindowService) {
|
||||||
@@ -314,17 +292,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
|||||||
this.emitPaginationChange();
|
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
|
* Method to emit a general pagination change event
|
||||||
*/
|
*/
|
||||||
@@ -348,10 +315,10 @@ export class PaginationComponent implements OnDestroy, OnInit {
|
|||||||
if (collectionSize) {
|
if (collectionSize) {
|
||||||
showingDetails = this.paginationService.getCurrentPagination(this.id, this.paginationOptions).pipe(
|
showingDetails = this.paginationService.getCurrentPagination(this.id, this.paginationOptions).pipe(
|
||||||
map((currentPaginationOptions) => {
|
map((currentPaginationOptions) => {
|
||||||
let lastItem;
|
let lastItem: number;
|
||||||
const pageMax = currentPaginationOptions.pageSize * currentPaginationOptions.currentPage;
|
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) {
|
if (collectionSize > pageMax) {
|
||||||
lastItem = pageMax;
|
lastItem = pageMax;
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user