Skip to content

Commit 7b1a8f8

Browse files
authored
Merge pull request DSpace#1939 from atmire/w2p-96062_theme-collection-dropdown-component
Make the CollectionDropdownComponent themeable
2 parents ffc5ecb + f2972d7 commit 7b1a8f8

11 files changed

Lines changed: 64 additions & 9 deletions

src/app/my-dspace-page/collection-selector/collection-selector.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</button>
66
</div>
77
<div class="modal-body">
8-
<ds-collection-dropdown (selectionChange)="selectObject($event)">
9-
</ds-collection-dropdown>
8+
<ds-themed-collection-dropdown (selectionChange)="selectObject($event)">
9+
</ds-themed-collection-dropdown>
1010
</div>
1111
</div>

src/app/my-dspace-page/collection-selector/collection-selector.component.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,13 @@ describe('CollectionSelectorComponent', () => {
128128

129129
beforeEach(() => {
130130
scheduler = getTestScheduler();
131-
fixture = TestBed.createComponent(CollectionSelectorComponent);
131+
fixture = TestBed.overrideComponent(CollectionSelectorComponent, {
132+
set: {
133+
template: '<ds-collection-dropdown (selectionChange)="selectObject($event)"></ds-collection-dropdown>'
134+
}
135+
}).createComponent(CollectionSelectorComponent);
132136
component = fixture.componentInstance;
133137
fixture.detectChanges();
134-
135138
});
136139

137140
it('should create', () => {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { CollectionDropdownComponent, CollectionListEntry } from './collection-dropdown.component';
2+
import { ThemedComponent } from '../theme-support/themed.component';
3+
import { Component, Input, Output, EventEmitter } from '@angular/core';
4+
5+
@Component({
6+
selector: 'ds-themed-collection-dropdown',
7+
styleUrls: [],
8+
templateUrl: '../../shared/theme-support/themed.component.html',
9+
})
10+
export class ThemedCollectionDropdownComponent extends ThemedComponent<CollectionDropdownComponent> {
11+
12+
@Input() entityType: string;
13+
14+
@Output() searchComplete = new EventEmitter<any>();
15+
16+
@Output() theOnlySelectable = new EventEmitter<CollectionListEntry>();
17+
18+
@Output() selectionChange = new EventEmitter<CollectionListEntry>();
19+
20+
protected inAndOutputNames: (keyof CollectionDropdownComponent & keyof this)[] = ['entityType', 'searchComplete', 'theOnlySelectable', 'selectionChange'];
21+
22+
protected getComponentName(): string {
23+
return 'CollectionDropdownComponent';
24+
}
25+
26+
protected importThemedComponent(themeName: string): Promise<any> {
27+
return import(`../../../themes/${themeName}/app/shared/collection-dropdown/collection-dropdown.component`);
28+
}
29+
30+
protected importUnthemedComponent(): Promise<any> {
31+
return import(`./collection-dropdown.component`);
32+
}
33+
}

src/app/shared/shared.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ import { MenuModule } from './menu/menu.module';
315315
import {
316316
ListableNotificationObjectComponent
317317
} from './object-list/listable-notification-object/listable-notification-object.component';
318+
import { ThemedCollectionDropdownComponent } from './collection-dropdown/themed-collection-dropdown.component';
318319

319320
const MODULES = [
320321
CommonModule,
@@ -484,6 +485,7 @@ const ENTRY_COMPONENTS = [
484485
ClaimedTaskActionsReturnToPoolComponent,
485486
ClaimedTaskActionsEditMetadataComponent,
486487
CollectionDropdownComponent,
488+
ThemedCollectionDropdownComponent,
487489
FileDownloadLinkComponent,
488490
BitstreamDownloadPageComponent,
489491
BitstreamRequestACopyPageComponent,

src/app/submission/form/collection/submission-form-collection.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
class="dropdown-menu"
3636
id="collectionControlsDropdownMenu"
3737
aria-labelledby="collectionControlsMenuButton">
38-
<ds-collection-dropdown
38+
<ds-themed-collection-dropdown
3939
(selectionChange)="onSelect($event)">
40-
</ds-collection-dropdown>
40+
</ds-themed-collection-dropdown>
4141
</div>
4242
</div>
4343
</div>

src/app/submission/import-external/import-external-collection/submission-import-external-collection.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
</div>
77
<div class="modal-body">
88
<ds-themed-loading *ngIf="isLoading()"></ds-themed-loading>
9-
<ds-collection-dropdown [ngClass]="{'d-none': isLoading()}"
9+
<ds-themed-collection-dropdown [ngClass]="{'d-none': isLoading()}"
1010
(selectionChange)="selectObject($event)"
1111
(searchComplete)="searchComplete()"
1212
(theOnlySelectable)="theOnlySelectable($event)"
1313
[entityType]="entityType">
14-
</ds-collection-dropdown>
14+
</ds-themed-collection-dropdown>
1515
</div>
1616
</div>

src/app/submission/import-external/import-external-collection/submission-import-external-collection.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ describe('SubmissionImportExternalCollectionComponent test suite', () => {
122122
fixture.detectChanges();
123123

124124
fixture.whenStable().then(() => {
125-
const dropdownMenu = fixture.debugElement.query(By.css('ds-collection-dropdown')).nativeElement;
125+
const dropdownMenu = fixture.debugElement.query(By.css('ds-themed-collection-dropdown')).nativeElement;
126126
expect(dropdownMenu.classList).toContain('d-none');
127127
});
128128
}));

src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.html

Whitespace-only changes.

src/themes/custom/app/shared/collection-dropdown/collection-dropdown.component.scss

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import {
2+
CollectionDropdownComponent as BaseComponent
3+
} from '../../../../../app/shared/collection-dropdown/collection-dropdown.component';
4+
import { Component } from '@angular/core';
5+
6+
@Component({
7+
selector: 'ds-collection-dropdown',
8+
templateUrl: '../../../../../app/shared/collection-dropdown/collection-dropdown.component.html',
9+
// templateUrl: './collection-dropdown.component.html',
10+
styleUrls: ['../../../../../app/shared/collection-dropdown/collection-dropdown.component.scss']
11+
// styleUrls: ['./collection-dropdown.component.scss']
12+
})
13+
export class CollectionDropdownComponent extends BaseComponent {
14+
15+
}

0 commit comments

Comments
 (0)