From 4fb914b51cd085ce6487b251a46b0feba8e5cd2b Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Wed, 1 Feb 2023 14:52:52 +0100 Subject: [PATCH 1/6] 98855: Themed FileDownloadLinkComponent --- .../full-file-section.component.html | 8 ++-- .../file-section/file-section.component.html | 4 +- .../file-section.component.spec.ts | 4 +- .../detail/process-detail.component.html | 4 +- .../themed-file-download-link.component.ts | 38 +++++++++++++++++++ src/app/shared/shared.module.ts | 3 ++ .../file/section-upload-file.component.html | 4 +- 7 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 src/app/shared/file-download-link/themed-file-download-link.component.ts diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.html b/src/app/item-page/full/field-components/file-section/full-file-section.component.html index 33acd6650b..f474c666f2 100644 --- a/src/app/item-page/full/field-components/file-section/full-file-section.component.html +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.html @@ -33,9 +33,9 @@
- + {{"item.page.filesection.download" | translate}} - +
@@ -74,9 +74,9 @@
- + {{"item.page.filesection.download" | translate}} - +
diff --git a/src/app/item-page/simple/field-components/file-section/file-section.component.html b/src/app/item-page/simple/field-components/file-section/file-section.component.html index 9d61b0a0e0..8e9fb63eda 100644 --- a/src/app/item-page/simple/field-components/file-section/file-section.component.html +++ b/src/app/item-page/simple/field-components/file-section/file-section.component.html @@ -1,11 +1,11 @@
- + {{file?.name}} ({{(file?.sizeBytes) | dsFileSize }}) - +
{{'item.page.bitstreams.view-more' | translate}} diff --git a/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts b/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts index 2d185aef9c..adad0cc350 100644 --- a/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts +++ b/src/app/item-page/simple/field-components/file-section/file-section.component.spec.ts @@ -109,7 +109,7 @@ describe('FileSectionComponent', () => { it('one bitstream should be on the page', () => { const viewMore = fixture.debugElement.query(By.css('.bitstream-view-more')); viewMore.triggerEventHandler('click', null); - const fileDownloadLink = fixture.debugElement.queryAll(By.css('ds-file-download-link')); + const fileDownloadLink = fixture.debugElement.queryAll(By.css('ds-themed-file-download-link')); expect(fileDownloadLink.length).toEqual(1); }); @@ -122,7 +122,7 @@ describe('FileSectionComponent', () => { }); it('should contain another bitstream', () => { - const fileDownloadLink = fixture.debugElement.queryAll(By.css('ds-file-download-link')); + const fileDownloadLink = fixture.debugElement.queryAll(By.css('ds-themed-file-download-link')); expect(fileDownloadLink.length).toEqual(2); }); }); diff --git a/src/app/process-page/detail/process-detail.component.html b/src/app/process-page/detail/process-detail.component.html index ae3418eafa..29cbfc113f 100644 --- a/src/app/process-page/detail/process-detail.component.html +++ b/src/app/process-page/detail/process-detail.component.html @@ -17,10 +17,10 @@
- + {{getFileName(file)}} ({{(file?.sizeBytes) | dsFileSize }}) - +
diff --git a/src/app/shared/file-download-link/themed-file-download-link.component.ts b/src/app/shared/file-download-link/themed-file-download-link.component.ts new file mode 100644 index 0000000000..4e619b8f28 --- /dev/null +++ b/src/app/shared/file-download-link/themed-file-download-link.component.ts @@ -0,0 +1,38 @@ +import { ThemedComponent } from '../theme-support/themed.component'; +import { Component, Input } from '@angular/core'; +import { FileDownloadLinkComponent } from './file-download-link.component'; +import { Bitstream } from '../../core/shared/bitstream.model'; +import { Item } from '../../core/shared/item.model'; + +@Component({ + selector: 'ds-themed-file-download-link', + styleUrls: [], + templateUrl: '../theme-support/themed.component.html', +}) +export class ThemedFileDownloadLinkComponent extends ThemedComponent { + + @Input() bitstream: Bitstream; + + @Input() item: Item; + + @Input() cssClasses: string; + + @Input() isBlank: boolean; + + @Input() enableRequestACopy: boolean; + + protected inAndOutputNames: (keyof FileDownloadLinkComponent & keyof this)[] = ['bitstream', 'item', 'cssClasses', 'isBlank', 'enableRequestACopy']; + + protected getComponentName(): string { + return 'FileDownloadLinkComponent'; + } + + protected importThemedComponent(themeName: string): Promise { + return import(`../../../themes/${themeName}/app/shared/file-download-link/file-download-link.component`); + } + + protected importUnthemedComponent(): Promise { + return import('./file-download-link.component'); + } + +} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 45e9764151..b16814e8ce 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -256,6 +256,7 @@ import { import { ImpersonateNavbarComponent } from './impersonate-navbar/impersonate-navbar.component'; import { NgForTrackByIdDirective } from './ng-for-track-by-id.directive'; import { FileDownloadLinkComponent } from './file-download-link/file-download-link.component'; +import { ThemedFileDownloadLinkComponent } from './file-download-link/themed-file-download-link.component'; import { CollectionDropdownComponent } from './collection-dropdown/collection-dropdown.component'; import { EntityDropdownComponent } from './entity-dropdown/entity-dropdown.component'; import { VocabularyTreeviewComponent } from './vocabulary-treeview/vocabulary-treeview.component'; @@ -479,6 +480,7 @@ const COMPONENTS = [ ModifyItemOverviewComponent, ImpersonateNavbarComponent, FileDownloadLinkComponent, + ThemedFileDownloadLinkComponent, BitstreamDownloadPageComponent, BitstreamRequestACopyPageComponent, CollectionDropdownComponent, @@ -561,6 +563,7 @@ const ENTRY_COMPONENTS = [ ClaimedTaskActionsEditMetadataComponent, CollectionDropdownComponent, FileDownloadLinkComponent, + ThemedFileDownloadLinkComponent, BitstreamDownloadPageComponent, BitstreamRequestACopyPageComponent, CurationFormComponent, diff --git a/src/app/submission/sections/upload/file/section-upload-file.component.html b/src/app/submission/sections/upload/file/section-upload-file.component.html index 1bfc52529b..9bf4eb1bcb 100644 --- a/src/app/submission/sections/upload/file/section-upload-file.component.html +++ b/src/app/submission/sections/upload/file/section-upload-file.component.html @@ -10,9 +10,9 @@
- + - +