From 524b91ecb9095c4bebea0a3d7b6469cf5ec3d428 Mon Sep 17 00:00:00 2001 From: Alexandre Vryghem Date: Thu, 5 Sep 2024 14:09:02 +0200 Subject: [PATCH] 117274: Themed DSOSelectorComponent --- ...uthorized-collection-selector.component.ts | 4 +- .../dso-selector/dso-selector.component.ts | 4 +- .../themed-dso-selector.component.ts | 44 +++++++++++++++++++ ...e-community-parent-selector.component.html | 2 +- .../dso-selector-modal-wrapper.component.html | 2 +- ...o-selector-modal-wrapper.component.spec.ts | 6 +-- .../edit-item-selector.component.html | 2 +- .../scope-selector-modal.component.html | 2 +- src/app/shared/shared.module.ts | 2 + .../dso-selector/dso-selector.component.html | 0 .../dso-selector/dso-selector.component.scss | 0 .../dso-selector/dso-selector.component.ts | 12 +++++ ...-collection-parent-selector.component.html | 2 +- ...e-community-parent-selector.component.html | 2 +- .../edit-collection-selector.component.html | 2 +- .../edit-community-selector.component.html | 2 +- .../edit-item-selector.component.html | 2 +- src/themes/custom/lazy-theme.module.ts | 2 + 18 files changed, 76 insertions(+), 16 deletions(-) create mode 100644 src/app/shared/dso-selector/dso-selector/themed-dso-selector.component.ts create mode 100644 src/themes/custom/app/shared/dso-selector/dso-selector/dso-selector.component.html create mode 100644 src/themes/custom/app/shared/dso-selector/dso-selector/dso-selector.component.scss create mode 100644 src/themes/custom/app/shared/dso-selector/dso-selector/dso-selector.component.ts diff --git a/src/app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component.ts b/src/app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component.ts index cc1f9822d67..386fca94761 100644 --- a/src/app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component.ts @@ -35,11 +35,11 @@ export class AuthorizedCollectionSelectorComponent extends DSOSelectorComponent constructor( protected searchService: SearchService, protected collectionDataService: CollectionDataService, - protected notifcationsService: NotificationsService, + protected notificationService: NotificationsService, protected translate: TranslateService, protected dsoNameService: DSONameService, ) { - super(searchService, notifcationsService, translate, dsoNameService); + super(searchService, notificationService, translate, dsoNameService); } /** diff --git a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts index 503e4c44129..b2b53010dc8 100644 --- a/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts +++ b/src/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -138,7 +138,7 @@ export class DSOSelectorComponent implements OnInit, OnDestroy { constructor( protected searchService: SearchService, - protected notifcationsService: NotificationsService, + protected notificationService: NotificationsService, protected translate: TranslateService, protected dsoNameService: DSONameService, ) { @@ -185,7 +185,7 @@ export class DSOSelectorComponent implements OnInit, OnDestroy { ...rd.payload.page.filter((result) => isNotEmpty(query) || result.indexableObject.id !== this.currentDSOId) ]; } else if (rd.hasFailed) { - this.notifcationsService.error(this.translate.instant('dso-selector.error.title', { type: this.typesString }), rd.errorMessage); + this.notificationService.error(this.translate.instant('dso-selector.error.title', { type: this.typesString }), rd.errorMessage); } return rd; }) diff --git a/src/app/shared/dso-selector/dso-selector/themed-dso-selector.component.ts b/src/app/shared/dso-selector/dso-selector/themed-dso-selector.component.ts new file mode 100644 index 00000000000..7fe5c44624f --- /dev/null +++ b/src/app/shared/dso-selector/dso-selector/themed-dso-selector.component.ts @@ -0,0 +1,44 @@ +import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { ThemedComponent } from '../../theme-support/themed.component'; +import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model'; +import { SortOptions } from '../../../core/cache/models/sort-options.model'; +import { DSpaceObject } from '../../../core/shared/dspace-object.model'; +import { DSOSelectorComponent } from './dso-selector.component'; + +/** + * Themed wrapper for {@link DSOSelectorComponent} + */ +@Component({ + selector: 'ds-themed-dso-selector', + templateUrl: '../../theme-support/themed.component.html', +}) +export class ThemedDSOSelectorComponent extends ThemedComponent { + + @Input() currentDSOId: string; + + @Input() types: DSpaceObjectType[]; + + @Input() sort: SortOptions; + + @Output() onSelect: EventEmitter = new EventEmitter(); + + protected inAndOutputNames: (keyof DSOSelectorComponent & keyof this)[] = [ + 'currentDSOId', + 'types', + 'sort', + 'onSelect', + ]; + + protected getComponentName(): string { + return 'DSOSelectorComponent'; + } + + protected importThemedComponent(themeName: string): Promise { + return import(`../../../../themes/${themeName}/app/shared/dso-selector/dso-selector/dso-selector.component`); + } + + protected importUnthemedComponent(): Promise { + return import('./dso-selector.component'); + } + +} diff --git a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html index a13be638803..6281f0056a3 100644 --- a/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html +++ b/src/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html @@ -14,6 +14,6 @@

{{'dso-selector.create.community.sub-level' | translate}}
- + diff --git a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html index 54044f5d796..5e84228eb60 100644 --- a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html +++ b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.html @@ -6,6 +6,6 @@ diff --git a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.spec.ts index e2dbaaa0fff..3f301d2133e 100644 --- a/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.spec.ts +++ b/src/app/shared/dso-selector/modal-wrappers/dso-selector-modal-wrapper.component.spec.ts @@ -8,7 +8,7 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { ActivatedRoute } from '@angular/router'; import { DSpaceObject } from '../../../core/shared/dspace-object.model'; import { By } from '@angular/platform-browser'; -import { DSOSelectorComponent } from '../dso-selector/dso-selector.component'; +import { ThemedDSOSelectorComponent } from '../dso-selector/themed-dso-selector.component'; import { MockComponent } from 'ng-mocks'; import { MetadataValue } from '../../../core/shared/metadata.models'; import { createSuccessfulRemoteDataObject } from '../../remote-data.utils'; @@ -33,7 +33,7 @@ describe('DSOSelectorModalWrapperComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ imports: [TranslateModule.forRoot()], - declarations: [TestComponent, MockComponent(DSOSelectorComponent)], + declarations: [TestComponent, MockComponent(ThemedDSOSelectorComponent)], providers: [ { provide: NgbActiveModal, useValue: modalStub }, { @@ -95,7 +95,7 @@ describe('DSOSelectorModalWrapperComponent', () => { describe('when the onSelect method emits on the child component', () => { beforeEach(() => { spyOn(component, 'selectObject'); - debugElement.query(By.css('ds-dso-selector')).componentInstance.onSelect.emit(item); + debugElement.query(By.css('ds-themed-dso-selector')).componentInstance.onSelect.emit(item); fixture.detectChanges(); }); it('should call the selectObject method on the component with the correct object', () => { diff --git a/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html b/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html index 85d8797e660..4a617d9545e 100644 --- a/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html +++ b/src/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html @@ -6,6 +6,6 @@ diff --git a/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.html b/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.html index 013274320b2..e191292c56d 100644 --- a/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.html +++ b/src/app/shared/search-form/scope-selector-modal/scope-selector-modal.component.html @@ -14,6 +14,6 @@

{{'dso-selector.' + action + '.' + objectType.toString().toLowerCase() + '.input-header' | translate}}
- + diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index e9fa707b508..2a5eb04a2c5 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -101,6 +101,7 @@ import { AutoFocusDirective } from './utils/auto-focus.directive'; import { StartsWithDateComponent } from './starts-with/date/starts-with-date.component'; import { StartsWithTextComponent } from './starts-with/text/starts-with-text.component'; import { DSOSelectorComponent } from './dso-selector/dso-selector/dso-selector.component'; +import { ThemedDSOSelectorComponent } from './dso-selector/dso-selector/themed-dso-selector.component'; import { CreateCommunityParentSelectorComponent } from './dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component'; @@ -366,6 +367,7 @@ const COMPONENTS = [ ValidationSuggestionsComponent, DsoInputSuggestionsComponent, DSOSelectorComponent, + ThemedDSOSelectorComponent, SearchExportCsvComponent, PageSizeSelectorComponent, ListableObjectComponentLoaderComponent, diff --git a/src/themes/custom/app/shared/dso-selector/dso-selector/dso-selector.component.html b/src/themes/custom/app/shared/dso-selector/dso-selector/dso-selector.component.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/themes/custom/app/shared/dso-selector/dso-selector/dso-selector.component.scss b/src/themes/custom/app/shared/dso-selector/dso-selector/dso-selector.component.scss new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/themes/custom/app/shared/dso-selector/dso-selector/dso-selector.component.ts b/src/themes/custom/app/shared/dso-selector/dso-selector/dso-selector.component.ts new file mode 100644 index 00000000000..91a02a1d8fb --- /dev/null +++ b/src/themes/custom/app/shared/dso-selector/dso-selector/dso-selector.component.ts @@ -0,0 +1,12 @@ +import { Component } from '@angular/core'; +import { DSOSelectorComponent as BaseComponent } from '../../../../../../app/shared/dso-selector/dso-selector/dso-selector.component'; + +@Component({ + selector: 'ds-dso-selector', + // styleUrls: ['./dso-selector.component.scss'], + styleUrls: ['../../../../../../app/shared/dso-selector/dso-selector/dso-selector.component.scss'], + // templateUrl: './dso-selector.component.html', + templateUrl: '../../../../../../app/shared/dso-selector/dso-selector/dso-selector.component.html', +}) +export class DSOSelectorComponent extends BaseComponent { +} diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html index 54044f5d796..5e84228eb60 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-collection-parent-selector/create-collection-parent-selector.component.html @@ -6,6 +6,6 @@ diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html index a13be638803..6281f0056a3 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/create-community-parent-selector/create-community-parent-selector.component.html @@ -14,6 +14,6 @@

{{'dso-selector.create.community.sub-level' | translate}}
- + diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.html index 54044f5d796..5e84228eb60 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-collection-selector/edit-collection-selector.component.html @@ -6,6 +6,6 @@ diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.html index 54044f5d796..5e84228eb60 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-community-selector/edit-community-selector.component.html @@ -6,6 +6,6 @@ diff --git a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html index 85d8797e660..4a617d9545e 100644 --- a/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html +++ b/src/themes/custom/app/shared/dso-selector/modal-wrappers/edit-item-selector/edit-item-selector.component.html @@ -6,6 +6,6 @@ diff --git a/src/themes/custom/lazy-theme.module.ts b/src/themes/custom/lazy-theme.module.ts index af4a6c78270..0c9824d8338 100644 --- a/src/themes/custom/lazy-theme.module.ts +++ b/src/themes/custom/lazy-theme.module.ts @@ -159,6 +159,7 @@ import { RequestCopyModule } from 'src/app/request-copy/request-copy.module'; import { AuthorizedCollectionSelectorComponent } from './app/shared/dso-selector/dso-selector/authorized-collection-selector/authorized-collection-selector.component'; +import { DSOSelectorComponent } from './app/shared/dso-selector/dso-selector/dso-selector.component'; const DECLARATIONS = [ FileSectionComponent, @@ -243,6 +244,7 @@ const DECLARATIONS = [ ItemStatusComponent, EditBitstreamPageComponent, AuthorizedCollectionSelectorComponent, + DSOSelectorComponent, ]; @NgModule({