Skip to content

Commit

Permalink
119941: Made DynamicLookupRelationModalComponent themable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrevryghem committed Dec 19, 2024
1 parent 404ccd9 commit 4193482
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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<DsDynamicLookupRelationModalComponent>;
let component: DynamicLookupRelationModalComponent;
let fixture: ComponentFixture<DynamicLookupRelationModalComponent>;
let debugElement: DebugElement;
let item;
let item1;
Expand Down Expand Up @@ -103,7 +102,7 @@ describe('DsDynamicLookupRelationModalComponent', () => {
beforeEach(waitForAsync(() => {
init();
TestBed.configureTestingModule({
declarations: [DsDynamicLookupRelationModalComponent],
declarations: [DynamicLookupRelationModalComponent],
imports: [TranslateModule.forRoot(), RouterTestingModule.withRoutes([]), NgbModule],
providers: [
{
Expand All @@ -119,7 +118,6 @@ describe('DsDynamicLookupRelationModalComponent', () => {
{
provide: RelationshipDataService, useValue: { getNameVariant: () => observableOf(nameVariant) }
},
{ provide: RelationshipTypeDataService, useValue: {} },
{ provide: RemoteDataBuildService, useValue: rdbService },
{
provide: Store, useValue: {
Expand All @@ -137,7 +135,7 @@ describe('DsDynamicLookupRelationModalComponent', () => {
}));

beforeEach(() => {
fixture = TestBed.createComponent(DsDynamicLookupRelationModalComponent);
fixture = TestBed.createComponent(DynamicLookupRelationModalComponent);
debugElement = fixture.debugElement;
component = fixture.componentInstance;
component.listId = listID;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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<ListableObject[]> = new EventEmitter<ListableObject[]>();
export class DynamicLookupRelationModalComponent implements OnInit, OnDestroy {

/**
* The label to use to display i18n messages (describing the type of relationship)
Expand Down Expand Up @@ -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<AppState>,
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<AppState>,
protected router: Router,
) {

}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<DynamicLookupRelationModalComponent> {

protected getComponentName(): string {
return 'DynamicLookupRelationModalComponent';
}

protected importThemedComponent(themeName: string): Promise<any> {
return import(`../../../../../../themes/${themeName}/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/dynamic-lookup-relation-modal.component`);
}

protected importUnthemedComponent(): Promise<any> {
return import('./dynamic-lookup-relation-modal.component');
}

}
6 changes: 4 additions & 2 deletions src/app/shared/form/form.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand All @@ -55,7 +56,8 @@ const COMPONENTS = [
DsDynamicLookupRelationExternalSourceTabComponent,
ThemedDynamicLookupRelationExternalSourceTabComponent,
DsDynamicDisabledComponent,
DsDynamicLookupRelationModalComponent,
DynamicLookupRelationModalComponent,
ThemedDynamicLookupRelationModalComponent,
DsDynamicScrollableDropdownComponent,
DsDynamicTagComponent,
DsDynamicOneboxComponent,
Expand Down

0 comments on commit 4193482

Please sign in to comment.