mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-4499] Version history (WIP) - Minor fixes and code cleanup
This commit is contained in:
@@ -1,19 +1,16 @@
|
|||||||
import { Component, Input, OnInit } from '@angular/core';
|
import { Component, Input, OnInit } from '@angular/core';
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../../core/shared/item.model';
|
||||||
import { PaginationComponentOptions } from '../../../pagination/pagination-component-options.model';
|
|
||||||
import { PaginatedSearchOptions } from '../../../search/paginated-search-options.model';
|
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { RemoteData } from '../../../../core/data/remote-data';
|
import { RemoteData } from '../../../../core/data/remote-data';
|
||||||
import { VersionHistory } from '../../../../core/shared/version-history.model';
|
import { VersionHistory } from '../../../../core/shared/version-history.model';
|
||||||
import { Version } from '../../../../core/shared/version.model';
|
import { Version } from '../../../../core/shared/version.model';
|
||||||
import { hasValue, hasValueOperator } from '../../../empty.util';
|
import { hasValue, hasValueOperator } from '../../../empty.util';
|
||||||
import {
|
import {
|
||||||
getAllSucceededRemoteData, getFirstSucceededRemoteData,
|
getAllSucceededRemoteData,
|
||||||
getFirstSucceededRemoteDataPayload,
|
getFirstSucceededRemoteDataPayload,
|
||||||
getRemoteDataPayload
|
getRemoteDataPayload
|
||||||
} from '../../../../core/shared/operators';
|
} from '../../../../core/shared/operators';
|
||||||
import { filter, map, switchMap, take } from 'rxjs/operators';
|
import { startWith, switchMap } from 'rxjs/operators';
|
||||||
import { followLink } from '../../../utils/follow-link-config.model';
|
|
||||||
import { VersionHistoryDataService } from '../../../../core/data/version-history-data.service';
|
import { VersionHistoryDataService } from '../../../../core/data/version-history-data.service';
|
||||||
import { AlertType } from '../../../alert/aletr-type';
|
import { AlertType } from '../../../alert/aletr-type';
|
||||||
import { getItemPageRoute } from '../../../../item-page/item-page-routing-paths';
|
import { getItemPageRoute } from '../../../../item-page/item-page-routing-paths';
|
||||||
@@ -56,11 +53,6 @@ export class ItemVersionsNoticeComponent implements OnInit {
|
|||||||
/**
|
/**
|
||||||
* Pagination options to fetch a single version on the first page (this is the latest version in the history)
|
* Pagination options to fetch a single version on the first page (this is the latest version in the history)
|
||||||
*/
|
*/
|
||||||
// latestVersionOptions = Object.assign(new PaginationComponentOptions(),{
|
|
||||||
// id: 'item-newest-version-options',
|
|
||||||
// currentPage: 1,
|
|
||||||
// pageSize: 1
|
|
||||||
// });
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The AlertType enumeration
|
* The AlertType enumeration
|
||||||
@@ -75,7 +67,6 @@ export class ItemVersionsNoticeComponent implements OnInit {
|
|||||||
* Initialize the component's observables
|
* Initialize the component's observables
|
||||||
*/
|
*/
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
// const latestVersionSearch = new PaginatedSearchOptions({pagination: this.latestVersionOptions});
|
|
||||||
if (hasValue(this.item.version)) {
|
if (hasValue(this.item.version)) {
|
||||||
this.versionRD$ = this.item.version;
|
this.versionRD$ = this.item.version;
|
||||||
this.versionHistoryRD$ = this.versionRD$.pipe(
|
this.versionHistoryRD$ = this.versionRD$.pipe(
|
||||||
@@ -85,36 +76,15 @@ export class ItemVersionsNoticeComponent implements OnInit {
|
|||||||
switchMap((version: Version) => version.versionhistory)
|
switchMap((version: Version) => version.versionhistory)
|
||||||
);
|
);
|
||||||
|
|
||||||
/*const versionHistory$ = this.versionHistoryRD$.pipe(
|
|
||||||
getAllSucceededRemoteData(),
|
|
||||||
getRemoteDataPayload(),
|
|
||||||
);
|
|
||||||
|
|
||||||
this.latestVersion$ = versionHistory$.pipe(
|
|
||||||
switchMap((versionHistory: VersionHistory) =>
|
|
||||||
this.versionHistoryService.getVersions(versionHistory.id, latestVersionSearch, true, true, followLink('item'))),
|
|
||||||
getAllSucceededRemoteData(),
|
|
||||||
getRemoteDataPayload(),
|
|
||||||
hasValueOperator(),
|
|
||||||
filter((versions) => versions.page.length > 0),
|
|
||||||
map((versions) => versions.page[0])
|
|
||||||
);*/
|
|
||||||
|
|
||||||
this.latestVersion$ = this.versionHistoryRD$.pipe(
|
this.latestVersion$ = this.versionHistoryRD$.pipe(
|
||||||
getFirstSucceededRemoteDataPayload(),
|
getFirstSucceededRemoteDataPayload(),
|
||||||
switchMap((vh) => this.versionHistoryService.getLatestVersionFromHistory$(vh))
|
switchMap((vh) => this.versionHistoryService.getLatestVersionFromHistory$(vh))
|
||||||
);
|
);
|
||||||
|
|
||||||
/*this.isLatestVersion$ = observableCombineLatest(
|
|
||||||
this.versionRD$.pipe(getAllSucceededRemoteData(), getRemoteDataPayload()), this.latestVersion$
|
|
||||||
).pipe(
|
|
||||||
map(([itemVersion, latestVersion]: [Version, Version]) => itemVersion.id === latestVersion.id),
|
|
||||||
startWith(true)
|
|
||||||
);*/
|
|
||||||
|
|
||||||
this.isLatestVersion$ = this.versionRD$.pipe(
|
this.isLatestVersion$ = this.versionRD$.pipe(
|
||||||
getFirstSucceededRemoteDataPayload(),
|
getFirstSucceededRemoteDataPayload(),
|
||||||
switchMap((version) => this.versionHistoryService.isLatest$(version))
|
switchMap((version) => this.versionHistoryService.isLatest$(version)),
|
||||||
|
startWith(true),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,5 +99,3 @@ export class ItemVersionsNoticeComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO code cleanup
|
|
||||||
|
Reference in New Issue
Block a user