diff --git a/src/app/item-page/versions/item-versions.component.html b/src/app/item-page/versions/item-versions.component.html index e9ea3bb0f95..ce5107aaa25 100644 --- a/src/app/item-page/versions/item-versions.component.html +++ b/src/app/item-page/versions/item-versions.component.html @@ -1,16 +1,16 @@ -
-
-
+
+
+

{{"item.version.history.head" | translate}}

- + {{ "item.version.history.selected.alert" | translate : {version: itemVersion.version} }} - @@ -22,10 +22,10 @@

{{"item.version.history.head" | translate}}<

- +
{{"item.version.history.head" | translate}}< > - {{version?.submitterName}} + {{versionDTO.version.submitterName}} - {{version?.created | date : 'yyyy-MM-dd HH:mm:ss'}} + {{versionDTO.version.created | date : 'yyyy-MM-dd HH:mm:ss'}}
- - {{version?.summary}} + + {{versionDTO.version.summary}} {{"item.version.history.head" | translate}}<
-
- - - - - - - + + + + +
- -
* {{"item.version.history.selected" | translate}}
-
+ + + + + diff --git a/src/app/item-page/versions/item-versions.component.ts b/src/app/item-page/versions/item-versions.component.ts index a4f9d9328b8..43a6fd44a4e 100644 --- a/src/app/item-page/versions/item-versions.component.ts +++ b/src/app/item-page/versions/item-versions.component.ts @@ -12,13 +12,11 @@ import { OnInit, } from '@angular/core'; import { FormsModule } from '@angular/forms'; -import { RouterLink } from '@angular/router'; import { TranslateModule, TranslateService, } from '@ngx-translate/core'; import { - BehaviorSubject, combineLatest, Observable, Subscription, @@ -41,7 +39,6 @@ import { PaginationService } from '../../core/pagination/pagination.service'; import { Item } from '../../core/shared/item.model'; import { getAllSucceededRemoteData, - getAllSucceededRemoteDataPayload, getFirstCompletedRemoteData, getFirstSucceededRemoteData, getFirstSucceededRemoteDataPayload, @@ -60,16 +57,35 @@ import { PaginationComponent } from '../../shared/pagination/pagination.componen import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; import { PaginatedSearchOptions } from '../../shared/search/models/paginated-search-options.model'; import { followLink } from '../../shared/utils/follow-link-config.model'; -import { VarDirective } from '../../shared/utils/var.directive'; -import { getItemPageRoute } from '../item-page-routing-paths'; import { ItemVersionsRowElementVersionComponent } from './item-versions-row-element-version/item-versions-row-element-version.component'; +interface VersionsDTO { + totalElements: number; + versionDTOs: VersionDTO[]; +} + +interface VersionDTO { + version: Version; + canEditVersion: Observable; +} + @Component({ selector: 'ds-item-versions', templateUrl: './item-versions.component.html', styleUrls: ['./item-versions.component.scss'], standalone: true, - imports: [VarDirective, NgIf, AlertComponent, PaginationComponent, NgFor, RouterLink, NgClass, FormsModule, AsyncPipe, DatePipe, TranslateModule, ItemVersionsRowElementVersionComponent], + imports: [ + AlertComponent, + AsyncPipe, + DatePipe, + FormsModule, + ItemVersionsRowElementVersionComponent, + NgClass, + NgFor, + NgIf, + PaginationComponent, + TranslateModule, + ], }) /** @@ -128,13 +144,7 @@ export class ItemVersionsComponent implements OnDestroy, OnInit { /** * The version history's list of versions */ - versionsRD$: BehaviorSubject>> = new BehaviorSubject>>(null); - - /** - * Verify if the list of versions has at least one e-person to display - * Used to hide the "Editor" column when no e-persons are present to display - */ - hasEpersons$: Observable; + versionsDTO$: Observable; /** * Verify if there is an inprogress submission in the version history @@ -162,15 +172,6 @@ export class ItemVersionsComponent implements OnDestroy, OnInit { pageSize: this.pageSize, }); - /** - * The routes to the versions their item pages - * Key: Item ID - * Value: Route to item page - */ - itemPageRoutes$: Observable<{ - [itemId: string]: string - }>; - /** * The number of the version whose summary is currently being edited */ @@ -186,9 +187,6 @@ export class ItemVersionsComponent implements OnDestroy, OnInit { */ versionBeingEditedSummary: string; - canCreateVersion$: Observable; - createVersionTitle$: Observable; - constructor(private versionHistoryService: VersionHistoryDataService, private versionService: VersionDataService, private paginationService: PaginationService, @@ -257,8 +255,7 @@ export class ItemVersionsComponent implements OnDestroy, OnInit { this.notificationsService.warning(null, this.translateService.get(failureMessageKey, { 'version': this.versionBeingEditedNumber })); } this.disableVersionEditing(); - }, - ); + }); } /** @@ -305,16 +302,22 @@ export class ItemVersionsComponent implements OnDestroy, OnInit { */ getAllVersions(versionHistory$: Observable): void { const currentPagination = this.paginationService.getCurrentPagination(this.options.id, this.options); - combineLatest([versionHistory$, currentPagination]).pipe( + this.versionsDTO$ = combineLatest([versionHistory$, currentPagination]).pipe( switchMap(([versionHistory, options]: [VersionHistory, PaginationComponentOptions]) => { return this.versionHistoryService.getVersions(versionHistory.id, new PaginatedSearchOptions({ pagination: Object.assign({}, options, { currentPage: options.currentPage }) }), false, true, followLink('item'), followLink('eperson')); }), getFirstCompletedRemoteData(), - ).subscribe((res: RemoteData>) => { - this.versionsRD$.next(res); - }); + getRemoteDataPayload(), + map((versions: PaginatedList) => ({ + totalElements: versions.totalElements, + versionDTOs: (versions?.page ?? []).map((version: Version) => ({ + version: version, + canEditVersion: this.canEditVersion$(version), + })), + })), + ); } /** @@ -348,22 +351,6 @@ export class ItemVersionsComponent implements OnDestroy, OnInit { ); this.getAllVersions(this.versionHistory$); - this.hasEpersons$ = this.versionsRD$.pipe( - getAllSucceededRemoteData(), - getRemoteDataPayload(), - hasValueOperator(), - map((versions: PaginatedList) => versions.page.filter((version: Version) => version.eperson !== undefined).length > 0), - startWith(false), - ); - this.itemPageRoutes$ = this.versionsRD$.pipe( - getAllSucceededRemoteDataPayload(), - switchMap((versions) => combineLatest(versions.page.map((version) => version.item.pipe(getAllSucceededRemoteDataPayload())))), - map((versions) => { - const itemPageRoutes = {}; - versions.forEach((item) => itemPageRoutes[item.uuid] = getItemPageRoute(item)); - return itemPageRoutes; - }), - ); } } @@ -380,3 +367,4 @@ export class ItemVersionsComponent implements OnDestroy, OnInit { } } +