diff --git a/src/app/item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.ts b/src/app/item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.ts index b8542f5806f..241eb797efd 100644 --- a/src/app/item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.ts +++ b/src/app/item-page/edit-item-page/item-relationships/edit-relationship-list/edit-relationship-list.component.ts @@ -25,7 +25,8 @@ import { getRemoteDataPayload, } from '../../../../core/shared/operators'; import { ItemType } from '../../../../core/shared/item-relationships/item-type.model'; -import { DsDynamicLookupRelationModalComponent } from '../../../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component'; +import { DynamicLookupRelationModalComponent } from '../../../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component'; +import { ThemedDynamicLookupRelationModalComponent } from '../../../../shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/themed-dynamic-lookup-relation-modal.component'; import { RelationshipOptions } from '../../../../shared/form/builder/models/relationship-options.model'; import { SelectableListService } from '../../../../shared/object-list/selectable-list/selectable-list.service'; import { SearchResult } from '../../../../shared/search/models/search-result.model'; @@ -210,12 +211,11 @@ export class EditRelationshipListComponent implements OnInit, OnDestroy { /** * Open the dynamic lookup modal to search for items to add as relationships */ - openLookup() { - - this.modalRef = this.modalService.open(DsDynamicLookupRelationModalComponent, { + openLookup(): void { + this.modalRef = this.modalService.open(ThemedDynamicLookupRelationModalComponent, { size: 'lg' }); - const modalComp: DsDynamicLookupRelationModalComponent = this.modalRef.componentInstance; + const modalComp: DynamicLookupRelationModalComponent = this.modalRef.componentInstance.compRef; modalComp.repeatable = true; modalComp.isEditRelationship = true; modalComp.listId = this.listId; diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts index ff5a119b6fc..277fafa1e2b 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component.ts @@ -89,7 +89,7 @@ import { RelationshipDataService } from '../../../../core/data/relationship-data import { SelectableListService } from '../../../object-list/selectable-list/selectable-list.service'; import { DsDynamicDisabledComponent } from './models/disabled/dynamic-disabled.component'; import { DYNAMIC_FORM_CONTROL_TYPE_DISABLED } from './models/disabled/dynamic-disabled.model'; -import { DsDynamicLookupRelationModalComponent } from './relation-lookup-modal/dynamic-lookup-relation-modal.component'; +import { ThemedDynamicLookupRelationModalComponent } from './relation-lookup-modal/themed-dynamic-lookup-relation-modal.component'; import { getAllSucceededRemoteData, getFirstSucceededRemoteData, @@ -424,7 +424,7 @@ export class DsDynamicFormControlContainerComponent extends DynamicFormControlCo * Open a modal where the user can select relationships to be added to item being submitted */ openLookup() { - this.modalRef = this.modalService.open(DsDynamicLookupRelationModalComponent, { + this.modalRef = this.modalService.open(ThemedDynamicLookupRelationModalComponent, { size: 'lg' }); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts index 9d57296f826..aff70bbc976 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.spec.ts @@ -3,11 +3,10 @@ import { TranslateModule } from '@ngx-translate/core'; import { RouterTestingModule } from '@angular/router/testing'; import { DebugElement, NgZone, NO_ERRORS_SCHEMA } from '@angular/core'; import { of as observableOf, Subscription } from 'rxjs'; -import { DsDynamicLookupRelationModalComponent } from './dynamic-lookup-relation-modal.component'; +import { DynamicLookupRelationModalComponent } from './dynamic-lookup-relation-modal.component'; import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { SelectableListService } from '../../../../object-list/selectable-list/selectable-list.service'; import { RelationshipDataService } from '../../../../../core/data/relationship-data.service'; -import { RelationshipTypeDataService } from '../../../../../core/data/relationship-type-data.service'; import { Store } from '@ngrx/store'; import { Item } from '../../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; @@ -26,8 +25,8 @@ import { Collection } from '../../../../../core/shared/collection.model'; import { By } from '@angular/platform-browser'; describe('DsDynamicLookupRelationModalComponent', () => { - let component: DsDynamicLookupRelationModalComponent; - let fixture: ComponentFixture; + let component: DynamicLookupRelationModalComponent; + let fixture: ComponentFixture; let debugElement: DebugElement; let item; let item1; @@ -103,7 +102,7 @@ describe('DsDynamicLookupRelationModalComponent', () => { beforeEach(waitForAsync(() => { init(); TestBed.configureTestingModule({ - declarations: [DsDynamicLookupRelationModalComponent], + declarations: [DynamicLookupRelationModalComponent], imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([]), NgbModule], providers: [ { @@ -119,7 +118,6 @@ describe('DsDynamicLookupRelationModalComponent', () => { { provide: RelationshipDataService, useValue: { getNameVariant: () => observableOf(nameVariant) } }, - { provide: RelationshipTypeDataService, useValue: {} }, { provide: RemoteDataBuildService, useValue: rdbService }, { provide: Store, useValue: { @@ -137,7 +135,7 @@ describe('DsDynamicLookupRelationModalComponent', () => { })); beforeEach(() => { - fixture = TestBed.createComponent(DsDynamicLookupRelationModalComponent); + fixture = TestBed.createComponent(DynamicLookupRelationModalComponent); debugElement = fixture.debugElement; component = fixture.componentInstance; component.listId = listID; diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.ts index 446497a74fc..5a319f3e95e 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, NgZone, OnDestroy, OnInit, Output } from '@angular/core'; +import { Component, NgZone, OnDestroy, OnInit } from '@angular/core'; import { combineLatest as observableCombineLatest, Observable, Subscription, BehaviorSubject } from 'rxjs'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; import { hasValue, isNotEmpty } from '../../../../empty.util'; @@ -17,7 +17,6 @@ import { UpdateRelationshipNameVariantAction, } from './relationship.actions'; import { RelationshipDataService } from '../../../../../core/data/relationship-data.service'; -import { RelationshipTypeDataService } from '../../../../../core/data/relationship-type-data.service'; import { Store } from '@ngrx/store'; import { AppState } from '../../../../../app.reducer'; import { Context } from '../../../../../core/shared/context.model'; @@ -45,8 +44,7 @@ import { RelationshipType } from '../../../../../core/shared/item-relationships/ /** * Represents a modal where the submitter can select items to be added as a certain relationship type to the object being submitted */ -export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy { - @Output() selectEvent: EventEmitter = new EventEmitter(); +export class DynamicLookupRelationModalComponent implements OnInit, OnDestroy { /** * The label to use to display i18n messages (describing the type of relationship) @@ -155,16 +153,15 @@ export class DsDynamicLookupRelationModalComponent implements OnInit, OnDestroy constructor( public modal: NgbActiveModal, - private selectableListService: SelectableListService, - private relationshipService: RelationshipDataService, - private relationshipTypeService: RelationshipTypeDataService, - private externalSourceService: ExternalSourceDataService, - private lookupRelationService: LookupRelationService, - private searchConfigService: SearchConfigurationService, - private rdbService: RemoteDataBuildService, - private zone: NgZone, - private store: Store, - private router: Router, + protected selectableListService: SelectableListService, + protected relationshipService: RelationshipDataService, + protected externalSourceService: ExternalSourceDataService, + protected lookupRelationService: LookupRelationService, + protected searchConfigService: SearchConfigurationService, + protected rdbService: RemoteDataBuildService, + protected zone: NgZone, + protected store: Store, + protected router: Router, ) { } diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/themed-dynamic-lookup-relation-modal.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/themed-dynamic-lookup-relation-modal.component.ts new file mode 100644 index 00000000000..fb7babcd2da --- /dev/null +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/themed-dynamic-lookup-relation-modal.component.ts @@ -0,0 +1,26 @@ +import { ThemedComponent } from '../../../../theme-support/themed.component'; +import { DynamicLookupRelationModalComponent } from './dynamic-lookup-relation-modal.component'; +import { Component } from '@angular/core'; + +/** + * Themed wrapper for {@link DynamicLookupRelationModalComponent} + */ +@Component({ + selector: 'ds-themed-dynamic-lookup-relation-modal', + templateUrl: '../../../../theme-support/themed.component.html', +}) +export class ThemedDynamicLookupRelationModalComponent extends ThemedComponent { + + protected getComponentName(): string { + return 'DynamicLookupRelationModalComponent'; + } + + protected importThemedComponent(themeName: string): Promise { + return import(`../../../../../../themes/${themeName}/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component`); + } + + protected importUnthemedComponent(): Promise { + return import('./dynamic-lookup-relation-modal.component'); + } + +} diff --git a/src/app/shared/form/form.module.ts b/src/app/shared/form/form.module.ts index 792de6f2518..0ab38a57c49 100644 --- a/src/app/shared/form/form.module.ts +++ b/src/app/shared/form/form.module.ts @@ -6,7 +6,7 @@ import { DsDynamicFormControlContainerComponent, dsDynamicFormControlMapFn } fro import { DsDynamicListComponent } from './builder/ds-dynamic-form-ui/models/list/dynamic-list.component'; import { DsDynamicLookupComponent } from './builder/ds-dynamic-form-ui/models/lookup/dynamic-lookup.component'; import { DsDynamicDisabledComponent } from './builder/ds-dynamic-form-ui/models/disabled/dynamic-disabled.component'; -import { DsDynamicLookupRelationModalComponent } from './builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component'; +import { DynamicLookupRelationModalComponent } from './builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component'; import { DsDynamicScrollableDropdownComponent } from './builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component'; import { DsDynamicTagComponent } from './builder/ds-dynamic-form-ui/models/tag/dynamic-tag.component'; import { DsDynamicOneboxComponent } from './builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component'; @@ -42,6 +42,7 @@ import { NgbDatepickerModule, NgbTimepickerModule } from '@ng-bootstrap/ng-boots import { CdkTreeModule } from '@angular/cdk/tree'; import { ThemedDynamicLookupRelationSearchTabComponent } from './builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/themed-dynamic-lookup-relation-search-tab.component'; import { ThemedDynamicLookupRelationExternalSourceTabComponent } from './builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/themed-dynamic-lookup-relation-external-source-tab.component'; +import { ThemedDynamicLookupRelationModalComponent } from './builder/ds-dynamic-form-ui/relation-lookup-modal/themed-dynamic-lookup-relation-modal.component'; const COMPONENTS = [ CustomSwitchComponent, @@ -55,7 +56,8 @@ const COMPONENTS = [ DsDynamicLookupRelationExternalSourceTabComponent, ThemedDynamicLookupRelationExternalSourceTabComponent, DsDynamicDisabledComponent, - DsDynamicLookupRelationModalComponent, + DynamicLookupRelationModalComponent, + ThemedDynamicLookupRelationModalComponent, DsDynamicScrollableDropdownComponent, DsDynamicTagComponent, DsDynamicOneboxComponent,