[CST-4499] Version history - Pagination fixed

This commit is contained in:
Davide Negretti
2021-10-18 13:20:03 +02:00
parent dfeee7894a
commit 7c40c3ba68
2 changed files with 20 additions and 7 deletions

View File

@@ -6,6 +6,7 @@
{{ "item.version.history.selected.alert" | translate : {version: itemVersion.version} }}
</ds-alert>
<ds-pagination *ngIf="versions?.page?.length > 0"
(paginationChange)="onPageChange()"
[hideGear]="true"
[hidePagerWhenSinglePage]="true"
[paginationOptions]="options"

View File

@@ -99,10 +99,15 @@ export class ItemVersionsComponent implements OnInit {
versionRD$: Observable<RemoteData<Version>>;
/**
* The item's full version history
* The item's full version history (remote data)
*/
versionHistoryRD$: Observable<RemoteData<VersionHistory>>;
/**
* The item's full version history
*/
versionHistory$: Observable<VersionHistory>;
/**
* The version history's list of versions
*/
@@ -239,7 +244,7 @@ export class ItemVersionsComponent implements OnInit {
).subscribe((updatedVersionRD: RemoteData<Version>) => {
if (updatedVersionRD.hasSucceeded) {
this.notificationsService.success(null, this.translateService.get(successMessageKey, {'version': this.versionBeingEditedNumber}));
this.getAllVersions(this.versionHistoryRD$.pipe(getFirstSucceededRemoteDataPayload()));
this.getAllVersions(this.versionHistory$);
} else {
this.notificationsService.warning(null, this.translateService.get(failureMessageKey, {'version': this.versionBeingEditedNumber}));
}
@@ -396,6 +401,13 @@ export class ItemVersionsComponent implements OnInit {
});
}
/**
* Updates the page
*/
onPageChange() {
this.getAllVersions(this.versionHistory$);
}
/**
* Get the ID of the workspace item, if present, otherwise return undefined
* @param versionItem the item for which retrieve the workspace item id
@@ -446,6 +458,10 @@ export class ItemVersionsComponent implements OnInit {
hasValueOperator(),
switchMap((version: Version) => version.versionhistory),
);
this.versionHistory$ = this.versionHistoryRD$.pipe(
getFirstSucceededRemoteDataPayload(),
hasValueOperator(),
);
this.canCreateVersion$ = this.authorizationService.isAuthorized(FeatureID.CanCreateVersion, this.item.self);
@@ -460,11 +476,7 @@ export class ItemVersionsComponent implements OnInit {
switchMap((res) => of(res ? 'item.version.history.table.action.hasDraft' : 'item.version.history.table.action.newVersion'))
);
const versionHistory$ = this.versionHistoryRD$.pipe(
getFirstSucceededRemoteDataPayload(),
hasValueOperator(),
);
this.getAllVersions(versionHistory$);
this.getAllVersions(this.versionHistory$);
this.hasEpersons$ = this.versionsRD$.pipe(
getAllSucceededRemoteData(),
getRemoteDataPayload(),