mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
Merge branch 'w2p-117287_fix-item-version-performance-issues_contribute-7.6' into w2p-117287_fix-item-version-performance-issues_contribute-main
# Conflicts: # src/app/item-page/versions/item-versions.component.html # src/app/item-page/versions/item-versions.component.ts
This commit is contained in:
@@ -1,16 +1,16 @@
|
|||||||
<div *ngVar="(versionsRD$ | async)?.payload as versions">
|
<div *ngIf="(versionsDTO$ | async) as versionsDTO; else noItemVersion">
|
||||||
<div *ngVar="(versionRD$ | async)?.payload as itemVersion">
|
<div *ngIf="(versionRD$ | async)?.payload as itemVersion">
|
||||||
<div class="mb-2" *ngIf="versions?.page?.length > 0 || displayWhenEmpty">
|
<div class="mb-2" *ngIf="versionsDTO.versionDTOs.length > 0 || displayWhenEmpty">
|
||||||
<h2 *ngIf="displayTitle" class="h4">{{"item.version.history.head" | translate}}</h2>
|
<h2 *ngIf="displayTitle" class="h4">{{"item.version.history.head" | translate}}</h2>
|
||||||
<ds-alert [type]="AlertTypeEnum.Info" *ngIf="itemVersion">
|
<ds-alert [type]="AlertTypeEnum.Info">
|
||||||
{{ "item.version.history.selected.alert" | translate : {version: itemVersion.version} }}
|
{{ "item.version.history.selected.alert" | translate : {version: itemVersion.version} }}
|
||||||
</ds-alert>
|
</ds-alert>
|
||||||
<ds-pagination *ngIf="versions?.page?.length > 0"
|
<ds-pagination *ngIf="versionsDTO.versionDTOs.length > 0"
|
||||||
(paginationChange)="onPageChange()"
|
(paginationChange)="onPageChange()"
|
||||||
[hideGear]="true"
|
[hideGear]="true"
|
||||||
[hidePagerWhenSinglePage]="true"
|
[hidePagerWhenSinglePage]="true"
|
||||||
[paginationOptions]="options"
|
[paginationOptions]="options"
|
||||||
[collectionSize]="versions?.totalElements"
|
[collectionSize]="versionsDTO.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">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -22,10 +22,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr *ngFor="let version of versions?.page" [id]="'version-row-' + version.id">
|
<tr *ngFor="let versionDTO of versionsDTO.versionDTOs" [id]="'version-row-' + versionDTO.version.id">
|
||||||
<td class="version-row-element-version">
|
<td class="version-row-element-version">
|
||||||
<ds-item-versions-row-element-version [hasDraftVersion]="hasDraftVersion$ | async"
|
<ds-item-versions-row-element-version [hasDraftVersion]="hasDraftVersion$ | async"
|
||||||
[version]="version"
|
[version]="versionDTO.version"
|
||||||
[item]="item" [displayActions]="displayActions"
|
[item]="item" [displayActions]="displayActions"
|
||||||
[itemVersion]="itemVersion"
|
[itemVersion]="itemVersion"
|
||||||
[versionBeingEditedNumber]="versionBeingEditedNumber"
|
[versionBeingEditedNumber]="versionBeingEditedNumber"
|
||||||
@@ -33,15 +33,15 @@
|
|||||||
></ds-item-versions-row-element-version>
|
></ds-item-versions-row-element-version>
|
||||||
</td>
|
</td>
|
||||||
<td class="version-row-element-editor" *ngIf="(showSubmitter$ | async)">
|
<td class="version-row-element-editor" *ngIf="(showSubmitter$ | async)">
|
||||||
{{version?.submitterName}}
|
{{versionDTO.version.submitterName}}
|
||||||
</td>
|
</td>
|
||||||
<td class="version-row-element-date">
|
<td class="version-row-element-date">
|
||||||
{{version?.created | date : 'yyyy-MM-dd HH:mm:ss'}}
|
{{versionDTO.version.created | date : 'yyyy-MM-dd HH:mm:ss'}}
|
||||||
</td>
|
</td>
|
||||||
<td class="version-row-element-summary">
|
<td class="version-row-element-summary">
|
||||||
<div class="float-left">
|
<div class="float-left">
|
||||||
<ng-container *ngIf="isThisBeingEdited(version); then editSummary else showSummary"></ng-container>
|
<ng-container *ngIf="isThisBeingEdited(versionDTO.version); then editSummary else showSummary"></ng-container>
|
||||||
<ng-template #showSummary>{{version?.summary}}</ng-template>
|
<ng-template #showSummary>{{versionDTO.version.summary}}</ng-template>
|
||||||
<ng-template #editSummary>
|
<ng-template #editSummary>
|
||||||
<input [attr.aria-label]="'item.version.history.table.action.editSummary' | translate"
|
<input [attr.aria-label]="'item.version.history.table.action.editSummary' | translate"
|
||||||
[(ngModel)]="versionBeingEditedSummary" (keyup.enter)="onSummarySubmit()"
|
[(ngModel)]="versionBeingEditedSummary" (keyup.enter)="onSummarySubmit()"
|
||||||
@@ -51,25 +51,25 @@
|
|||||||
|
|
||||||
<div class="float-right btn-group edit-field space-children-mr" *ngIf="displayActions">
|
<div class="float-right btn-group edit-field space-children-mr" *ngIf="displayActions">
|
||||||
<!--DISCARD EDIT -->
|
<!--DISCARD EDIT -->
|
||||||
<ng-container *ngIf="(canEditVersion$(version) | async) && isThisBeingEdited(version)">
|
<ng-container *ngIf="versionDTO.canEditVersion && isThisBeingEdited(versionDTO.version)">
|
||||||
<button class="btn btn-sm"
|
<button class="btn btn-sm"
|
||||||
[ngClass]="isThisBeingEdited(version) ? 'btn-outline-warning' : 'btn-outline-primary'"
|
[ngClass]="isThisBeingEdited(versionDTO.version) ? 'btn-outline-warning' : 'btn-outline-primary'"
|
||||||
(click)="disableVersionEditing()"
|
(click)="disableVersionEditing()"
|
||||||
title="{{'item.version.history.table.action.discardSummary' | translate}}">
|
title="{{'item.version.history.table.action.discardSummary' | translate}}">
|
||||||
<i class="fas fa-undo-alt fa-fw"></i>
|
<i class="fas fa-undo-alt fa-fw"></i>
|
||||||
</button>
|
</button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<!--EDIT / SAVE-->
|
<!--EDIT / SAVE-->
|
||||||
<ng-container *ngIf="canEditVersion$(version) | async">
|
<ng-container *ngIf="versionDTO.canEditVersion">
|
||||||
<button class="btn btn-outline-primary btn-sm version-row-element-edit"
|
<button class="btn btn-outline-primary btn-sm version-row-element-edit"
|
||||||
*ngIf="!isThisBeingEdited(version)"
|
*ngIf="!isThisBeingEdited(versionDTO.version)"
|
||||||
[disabled]="isAnyBeingEdited()"
|
[disabled]="isAnyBeingEdited()"
|
||||||
(click)="enableVersionEditing(version)"
|
(click)="enableVersionEditing(versionDTO.version)"
|
||||||
title="{{'item.version.history.table.action.editSummary' | translate}}">
|
title="{{'item.version.history.table.action.editSummary' | translate}}">
|
||||||
<i class="fas fa-edit fa-fw"></i>
|
<i class="fas fa-edit fa-fw"></i>
|
||||||
</button>
|
</button>
|
||||||
<button class="btn btn-outline-success btn-sm"
|
<button class="btn btn-outline-success btn-sm"
|
||||||
*ngIf="isThisBeingEdited(version)"
|
*ngIf="isThisBeingEdited(versionDTO.version)"
|
||||||
(click)="onSummarySubmit()"
|
(click)="onSummarySubmit()"
|
||||||
title="{{'item.version.history.table.action.saveSummary' | translate}}">
|
title="{{'item.version.history.table.action.saveSummary' | translate}}">
|
||||||
<i class="fas fa-check fa-fw"></i>
|
<i class="fas fa-check fa-fw"></i>
|
||||||
@@ -84,8 +84,13 @@
|
|||||||
</table>
|
</table>
|
||||||
<div>* {{"item.version.history.selected" | translate}}</div>
|
<div>* {{"item.version.history.selected" | translate}}</div>
|
||||||
</ds-pagination>
|
</ds-pagination>
|
||||||
<ds-alert *ngIf="!itemVersion || versions?.page?.length === 0" [content]="'item.version.history.empty'"
|
|
||||||
[type]="AlertTypeEnum.Info"></ds-alert>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ng-template #noItemVersion>
|
||||||
|
<ds-alert *ngIf="displayWhenEmpty"
|
||||||
|
[content]="'item.version.history.empty'"
|
||||||
|
[type]="AlertTypeEnum.Info">
|
||||||
|
</ds-alert>
|
||||||
|
</ng-template>
|
||||||
|
@@ -12,13 +12,11 @@ import {
|
|||||||
OnInit,
|
OnInit,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { RouterLink } from '@angular/router';
|
|
||||||
import {
|
import {
|
||||||
TranslateModule,
|
TranslateModule,
|
||||||
TranslateService,
|
TranslateService,
|
||||||
} from '@ngx-translate/core';
|
} from '@ngx-translate/core';
|
||||||
import {
|
import {
|
||||||
BehaviorSubject,
|
|
||||||
combineLatest,
|
combineLatest,
|
||||||
Observable,
|
Observable,
|
||||||
Subscription,
|
Subscription,
|
||||||
@@ -41,7 +39,6 @@ import { PaginationService } from '../../core/pagination/pagination.service';
|
|||||||
import { Item } from '../../core/shared/item.model';
|
import { Item } from '../../core/shared/item.model';
|
||||||
import {
|
import {
|
||||||
getAllSucceededRemoteData,
|
getAllSucceededRemoteData,
|
||||||
getAllSucceededRemoteDataPayload,
|
|
||||||
getFirstCompletedRemoteData,
|
getFirstCompletedRemoteData,
|
||||||
getFirstSucceededRemoteData,
|
getFirstSucceededRemoteData,
|
||||||
getFirstSucceededRemoteDataPayload,
|
getFirstSucceededRemoteDataPayload,
|
||||||
@@ -60,16 +57,35 @@ import { PaginationComponent } from '../../shared/pagination/pagination.componen
|
|||||||
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model';
|
||||||
import { PaginatedSearchOptions } from '../../shared/search/models/paginated-search-options.model';
|
import { PaginatedSearchOptions } from '../../shared/search/models/paginated-search-options.model';
|
||||||
import { followLink } from '../../shared/utils/follow-link-config.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';
|
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<boolean>;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-item-versions',
|
selector: 'ds-item-versions',
|
||||||
templateUrl: './item-versions.component.html',
|
templateUrl: './item-versions.component.html',
|
||||||
styleUrls: ['./item-versions.component.scss'],
|
styleUrls: ['./item-versions.component.scss'],
|
||||||
standalone: true,
|
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
|
* The version history's list of versions
|
||||||
*/
|
*/
|
||||||
versionsRD$: BehaviorSubject<RemoteData<PaginatedList<Version>>> = new BehaviorSubject<RemoteData<PaginatedList<Version>>>(null);
|
versionsDTO$: Observable<VersionsDTO>;
|
||||||
|
|
||||||
/**
|
|
||||||
* 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<boolean>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify if there is an inprogress submission in the version history
|
* Verify if there is an inprogress submission in the version history
|
||||||
@@ -162,15 +172,6 @@ export class ItemVersionsComponent implements OnDestroy, OnInit {
|
|||||||
pageSize: this.pageSize,
|
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
|
* The number of the version whose summary is currently being edited
|
||||||
*/
|
*/
|
||||||
@@ -186,9 +187,6 @@ export class ItemVersionsComponent implements OnDestroy, OnInit {
|
|||||||
*/
|
*/
|
||||||
versionBeingEditedSummary: string;
|
versionBeingEditedSummary: string;
|
||||||
|
|
||||||
canCreateVersion$: Observable<boolean>;
|
|
||||||
createVersionTitle$: Observable<string>;
|
|
||||||
|
|
||||||
constructor(private versionHistoryService: VersionHistoryDataService,
|
constructor(private versionHistoryService: VersionHistoryDataService,
|
||||||
private versionService: VersionDataService,
|
private versionService: VersionDataService,
|
||||||
private paginationService: PaginationService,
|
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.notificationsService.warning(null, this.translateService.get(failureMessageKey, { 'version': this.versionBeingEditedNumber }));
|
||||||
}
|
}
|
||||||
this.disableVersionEditing();
|
this.disableVersionEditing();
|
||||||
},
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -305,16 +302,22 @@ export class ItemVersionsComponent implements OnDestroy, OnInit {
|
|||||||
*/
|
*/
|
||||||
getAllVersions(versionHistory$: Observable<VersionHistory>): void {
|
getAllVersions(versionHistory$: Observable<VersionHistory>): void {
|
||||||
const currentPagination = this.paginationService.getCurrentPagination(this.options.id, this.options);
|
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]) => {
|
switchMap(([versionHistory, options]: [VersionHistory, PaginationComponentOptions]) => {
|
||||||
return this.versionHistoryService.getVersions(versionHistory.id,
|
return this.versionHistoryService.getVersions(versionHistory.id,
|
||||||
new PaginatedSearchOptions({ pagination: Object.assign({}, options, { currentPage: options.currentPage }) }),
|
new PaginatedSearchOptions({ pagination: Object.assign({}, options, { currentPage: options.currentPage }) }),
|
||||||
false, true, followLink('item'), followLink('eperson'));
|
false, true, followLink('item'), followLink('eperson'));
|
||||||
}),
|
}),
|
||||||
getFirstCompletedRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
).subscribe((res: RemoteData<PaginatedList<Version>>) => {
|
getRemoteDataPayload(),
|
||||||
this.versionsRD$.next(res);
|
map((versions: PaginatedList<Version>) => ({
|
||||||
});
|
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.getAllVersions(this.versionHistory$);
|
||||||
this.hasEpersons$ = this.versionsRD$.pipe(
|
|
||||||
getAllSucceededRemoteData(),
|
|
||||||
getRemoteDataPayload(),
|
|
||||||
hasValueOperator(),
|
|
||||||
map((versions: PaginatedList<Version>) => 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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user