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 ebc8096fb5..ded3ea054b 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 @@ -112,7 +112,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); }); @@ -125,7 +125,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 be36ec9621..32d11f8d36 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -200,6 +200,7 @@ import { ClaimedTaskActionsDirective } from './mydspace-actions/claimed-task/swi 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 { CurationFormComponent } from '../curation-form/curation-form.component'; @@ -413,6 +414,7 @@ const ENTRY_COMPONENTS = [ CollectionDropdownComponent, ThemedCollectionDropdownComponent, FileDownloadLinkComponent, + ThemedFileDownloadLinkComponent, CurationFormComponent, ExportMetadataSelectorComponent, ImportBatchSelectorComponent, diff --git a/src/app/shared/theme-support/themed.component.html b/src/app/shared/theme-support/themed.component.html index 4256518a10..a39b288f0e 100644 --- a/src/app/shared/theme-support/themed.component.html +++ b/src/app/shared/theme-support/themed.component.html @@ -1 +1,5 @@ - + + +
+ +
diff --git a/src/app/shared/theme-support/themed.component.ts b/src/app/shared/theme-support/themed.component.ts index 995122d284..07e868c512 100644 --- a/src/app/shared/theme-support/themed.component.ts +++ b/src/app/shared/theme-support/themed.component.ts @@ -9,7 +9,8 @@ import { ComponentFactoryResolver, ChangeDetectorRef, OnChanges, - HostBinding + HostBinding, + ElementRef, } from '@angular/core'; import { hasValue, isNotEmpty } from '../empty.util'; import { from as fromPromise, Observable, of as observableOf, Subscription, BehaviorSubject } from 'rxjs'; @@ -25,6 +26,7 @@ import { BASE_THEME_NAME } from './theme.constants'; }) export abstract class ThemedComponent implements OnInit, OnDestroy, OnChanges { @ViewChild('vcr', { read: ViewContainerRef }) vcr: ViewContainerRef; + @ViewChild('content') themedElementContent: ElementRef; protected compRef: ComponentRef; /** @@ -46,7 +48,7 @@ export abstract class ThemedComponent implements OnInit, OnDestroy, OnChanges constructor( protected resolver: ComponentFactoryResolver, protected cdr: ChangeDetectorRef, - protected themeService: ThemeService + protected themeService: ThemeService, ) { } @@ -102,10 +104,11 @@ export abstract class ThemedComponent implements OnInit, OnDestroy, OnChanges }), ).subscribe((constructor: GenericConstructor) => { const factory = this.resolver.resolveComponentFactory(constructor); - this.compRef = this.vcr.createComponent(factory); + this.compRef = this.vcr.createComponent(factory, undefined, undefined, [this.themedElementContent.nativeElement.childNodes]); this.connectInputsAndOutputs(); this.compRef$.next(this.compRef); this.cdr.markForCheck(); + this.themedElementContent.nativeElement.remove(); }); } @@ -121,7 +124,7 @@ export abstract class ThemedComponent implements OnInit, OnDestroy, OnChanges protected connectInputsAndOutputs(): void { if (isNotEmpty(this.inAndOutputNames) && hasValue(this.compRef) && hasValue(this.compRef.instance)) { - this.inAndOutputNames.forEach((name: any) => { + this.inAndOutputNames.filter((name: any) => this[name] !== undefined).forEach((name: any) => { this.compRef.instance[name] = this[name]; }); } 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 @@
- + - +