From 70fe46aeed4ea174e314251e91982e150000a30e Mon Sep 17 00:00:00 2001 From: Jens Vannerum Date: Mon, 31 Oct 2022 16:34:25 +0100 Subject: [PATCH 1/2] 96062: Theme the CollectionDropdownComponent --- .../collection-selector.component.html | 4 +-- .../themed-collection-dropdown.component.ts | 33 +++++++++++++++++++ src/app/shared/shared.module.ts | 3 ++ .../submission-form-collection.component.html | 4 +-- ...-import-external-collection.component.html | 4 +-- .../collection-dropdown.component.html | 0 .../collection-dropdown.component.scss | 0 .../collection-dropdown.component.ts | 15 +++++++++ src/themes/custom/eager-theme.module.ts | 2 ++ 9 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 src/app/shared/collection-dropdown/themed-collection-dropdown.component.ts create mode 100644 src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.html create mode 100644 src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.scss create mode 100644 src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.ts diff --git a/src/app/my-dspace-page/collection-selector/collection-selector.component.html b/src/app/my-dspace-page/collection-selector/collection-selector.component.html index a87118fc4e..6e2a1925c5 100644 --- a/src/app/my-dspace-page/collection-selector/collection-selector.component.html +++ b/src/app/my-dspace-page/collection-selector/collection-selector.component.html @@ -5,7 +5,7 @@ diff --git a/src/app/shared/collection-dropdown/themed-collection-dropdown.component.ts b/src/app/shared/collection-dropdown/themed-collection-dropdown.component.ts new file mode 100644 index 0000000000..27c883099d --- /dev/null +++ b/src/app/shared/collection-dropdown/themed-collection-dropdown.component.ts @@ -0,0 +1,33 @@ +import { CollectionDropdownComponent, CollectionListEntry } from './collection-dropdown.component'; +import { ThemedComponent } from '../theme-support/themed.component'; +import { Component, Input, Output, EventEmitter } from '@angular/core'; + +@Component({ + selector: 'ds-themed-collection-dropdown', + styleUrls: [], + templateUrl: '../../shared/theme-support/themed.component.html', +}) +export class ThemedCollectionDropdownComponent extends ThemedComponent { + + @Input() entityType: string; + + @Output() searchComplete = new EventEmitter(); + + @Output() theOnlySelectable = new EventEmitter(); + + @Output() selectionChange = new EventEmitter(); + + protected inAndOutputNames: (keyof CollectionDropdownComponent & keyof this)[] = ['entityType', 'searchComplete', 'theOnlySelectable', 'selectionChange']; + + protected getComponentName(): string { + return 'CollectionDropdownComponent'; + } + + protected importThemedComponent(themeName: string): Promise { + return import(`../../../themes/${themeName}/app/shared/collection-dropdown/collection-dropdown.component`); + } + + protected importUnthemedComponent(): Promise { + return import(`./collection-dropdown.component`); + } +} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index f723f081d3..02bccb2510 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -323,6 +323,7 @@ import { } from '../item-page/simple/field-components/specific-field/title/item-page-title-field.component'; import { MarkdownPipe } from './utils/markdown.pipe'; import { GoogleRecaptchaModule } from '../core/google-recaptcha/google-recaptcha.module'; +import { ThemedCollectionDropdownComponent } from './collection-dropdown/themed-collection-dropdown.component'; const MODULES = [ CommonModule, @@ -480,6 +481,7 @@ const COMPONENTS = [ BitstreamDownloadPageComponent, BitstreamRequestACopyPageComponent, CollectionDropdownComponent, + ThemedCollectionDropdownComponent, EntityDropdownComponent, ExportMetadataSelectorComponent, ImportBatchSelectorComponent, @@ -558,6 +560,7 @@ const ENTRY_COMPONENTS = [ ClaimedTaskActionsReturnToPoolComponent, ClaimedTaskActionsEditMetadataComponent, CollectionDropdownComponent, + ThemedCollectionDropdownComponent, FileDownloadLinkComponent, BitstreamDownloadPageComponent, BitstreamRequestACopyPageComponent, diff --git a/src/app/submission/form/collection/submission-form-collection.component.html b/src/app/submission/form/collection/submission-form-collection.component.html index d897cc31fd..15b6ff280e 100644 --- a/src/app/submission/form/collection/submission-form-collection.component.html +++ b/src/app/submission/form/collection/submission-form-collection.component.html @@ -35,9 +35,9 @@ class="dropdown-menu" id="collectionControlsDropdownMenu" aria-labelledby="collectionControlsMenuButton"> - - + diff --git a/src/app/submission/import-external/import-external-collection/submission-import-external-collection.component.html b/src/app/submission/import-external/import-external-collection/submission-import-external-collection.component.html index 29c99732c3..475f2a3b67 100644 --- a/src/app/submission/import-external/import-external-collection/submission-import-external-collection.component.html +++ b/src/app/submission/import-external/import-external-collection/submission-import-external-collection.component.html @@ -6,11 +6,11 @@ diff --git a/src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.html b/src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.scss b/src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.ts b/src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.ts new file mode 100644 index 0000000000..4fdbd9125b --- /dev/null +++ b/src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.ts @@ -0,0 +1,15 @@ +import { + CollectionDropdownComponent as BaseComponent +} from '../../../../../app/shared/collection-dropdown/collection-dropdown.component'; +import { Component } from '@angular/core'; + +@Component({ + selector: 'ds-collection-dropdown', + templateUrl: '../../../../../app/shared/collection-dropdown/collection-dropdown.component.html', + // templateUrl: './collection-dropdown.component.html', + styleUrls: ['../../../../../app/shared/collection-dropdown/collection-dropdown.component.scss'] + // styleUrls: ['./collection-dropdown.component.scss'] +}) +export class CollectionDropdownComponent extends BaseComponent { + +} diff --git a/src/themes/custom/eager-theme.module.ts b/src/themes/custom/eager-theme.module.ts index 4e3c6f8b46..6bca518092 100644 --- a/src/themes/custom/eager-theme.module.ts +++ b/src/themes/custom/eager-theme.module.ts @@ -43,6 +43,7 @@ import { import { CommunityListElementComponent } from './app/shared/object-list/community-list-element/community-list-element.component'; import { CollectionListElementComponent} from './app/shared/object-list/collection-list-element/collection-list-element.component'; +import { CollectionDropdownComponent } from './app/shared/collection-dropdown/collection-dropdown.component'; /** @@ -58,6 +59,7 @@ const ENTRY_COMPONENTS = [ CommunityListElementComponent, CollectionListElementComponent, + CollectionDropdownComponent, ]; const DECLARATIONS = [ From c6fd55baf49878f1e7deb9466505ec86542cf2c8 Mon Sep 17 00:00:00 2001 From: Jens Vannerum Date: Wed, 2 Nov 2022 12:55:21 +0100 Subject: [PATCH 2/2] 96062: Alter test to match themed component --- .../collection-selector.component.spec.ts | 7 +++++-- ...submission-import-external-collection.component.spec.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/my-dspace-page/collection-selector/collection-selector.component.spec.ts b/src/app/my-dspace-page/collection-selector/collection-selector.component.spec.ts index ce54d326fc..af043b447b 100644 --- a/src/app/my-dspace-page/collection-selector/collection-selector.component.spec.ts +++ b/src/app/my-dspace-page/collection-selector/collection-selector.component.spec.ts @@ -128,10 +128,13 @@ describe('CollectionSelectorComponent', () => { beforeEach(() => { scheduler = getTestScheduler(); - fixture = TestBed.createComponent(CollectionSelectorComponent); + fixture = TestBed.overrideComponent(CollectionSelectorComponent, { + set: { + template: '' + } + }).createComponent(CollectionSelectorComponent); component = fixture.componentInstance; fixture.detectChanges(); - }); it('should create', () => { diff --git a/src/app/submission/import-external/import-external-collection/submission-import-external-collection.component.spec.ts b/src/app/submission/import-external/import-external-collection/submission-import-external-collection.component.spec.ts index 4f3c54b642..9edab06c6f 100644 --- a/src/app/submission/import-external/import-external-collection/submission-import-external-collection.component.spec.ts +++ b/src/app/submission/import-external/import-external-collection/submission-import-external-collection.component.spec.ts @@ -122,7 +122,7 @@ describe('SubmissionImportExternalCollectionComponent test suite', () => { fixture.detectChanges(); fixture.whenStable().then(() => { - const dropdownMenu = fixture.debugElement.query(By.css('ds-collection-dropdown')).nativeElement; + const dropdownMenu = fixture.debugElement.query(By.css('ds-themed-collection-dropdown')).nativeElement; expect(dropdownMenu.classList).toContain('d-none'); }); }));