From a1b476cd9b9236c4386dc17b948988fe608482f3 Mon Sep 17 00:00:00 2001 From: milanmajchrak <90026355+milanmajchrak@users.noreply.github.com> Date: Thu, 2 Nov 2023 09:03:45 +0100 Subject: [PATCH] ufal/fe-history-table-is-still-seen (#392) * The version table is hidden if the item doesn't have any versions and the name is of the version is properly loaded. * Undo unwanted changes. --- .../file-description.component.ts | 12 +------ .../versions/item-versions.component.html | 34 +++++++++++-------- .../versions/item-versions.component.ts | 18 ++++++++++ 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts index e8ea710098b..c3c3a826063 100644 --- a/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts +++ b/src/app/item-page/simple/field-components/preview-section/file-description/file-description.component.ts @@ -16,17 +16,7 @@ export class FileDescriptionComponent { constructor(protected halService: HALEndpointService, private router: Router) { } public downloadFiles() { - console.log('${this.fileInput.href}', `${this.fileInput.href}`); - console.log('gile', this.fileInput); - // console.log('this.halService.getRootHref()', ); - // const href$ = this.halService.getEndpoint('bitstreams'); - this.router.navigateByUrl('bitstreams/' + this.fileInput.id + '/download'); - // href$.pipe( - // find((href: string) => hasValue(href)), - // ).subscribe((endpoint: string) => { - // console.log('endpoint', endpoint + '/' + this.fileInput.id + '/download'); - // }); - // window.location.href = this.halService.getRootHref() + void this.router.navigateByUrl('bitstreams/' + this.fileInput.id + '/download'); } public isTxt() { diff --git a/src/app/item-page/versions/item-versions.component.html b/src/app/item-page/versions/item-versions.component.html index a71f42fc5a9..b03900a694a 100644 --- a/src/app/item-page/versions/item-versions.component.html +++ b/src/app/item-page/versions/item-versions.component.html @@ -2,21 +2,25 @@ -

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

- - - - - - - - - - - - - -
{{'item.version.history.table.name' | translate}}{{'item.version.history.table.handle' | translate}}
{{versionFromMetadata.name}}{{versionFromMetadata.handle}}
+
+
+

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

+ + + + + + + + + + + + + +
{{'item.version.history.table.name' | translate}}{{'item.version.history.table.handle' | translate}}
{{versionFromMetadata.name}}{{versionFromMetadata.handle}}
+
+
diff --git a/src/app/item-page/versions/item-versions.component.ts b/src/app/item-page/versions/item-versions.component.ts index afb74b0ecca..fbba2ca541f 100644 --- a/src/app/item-page/versions/item-versions.component.ts +++ b/src/app/item-page/versions/item-versions.component.ts @@ -719,11 +719,29 @@ export class ItemVersionsComponent implements OnInit { getFirstSucceededRemoteListPayload()) .subscribe((itemList: Item[]) => { this.nameCache[handle] = this.dsoNameService.getName(itemList?.[0]); + this.updateVersionsFromMetadata(handle, this.nameCache[handle]); }); } return this.nameCache[handle]; } + /** + * Update the name in the `versionsFromMetadata` for the current record with matching handle. + * + * @param handle of the record which will be updated + * @param name of the version record + */ + updateVersionsFromMetadata(handle: string, name: string) { + const versionsCopy = this.versionsFromMetadata.value; + versionsCopy.forEach((versionFromMetadata: RelationNameHandle) => { + if (!isEqual(versionFromMetadata.handle, handle)) { + return; + } + versionFromMetadata.name = name; + }); + this.versionsFromMetadata.next(versionsCopy); + } + ngOnDestroy(): void { this.cleanupSubscribes(); this.paginationService.clearPagination(this.options.id);