From 2ea06c4d6ed2daa6ff9973ec3f487b2407a2fd15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laure-H=C3=A9l=C3=A8ne=20Bruneton?= Date: Thu, 18 Apr 2024 16:23:32 +0200 Subject: [PATCH] feat(ui-inputs): change dropdown-selector to standalone --- .../dropdown-selector.component.spec.ts | 11 +------- .../dropdown-selector.component.stories.ts | 28 ++++++------------- .../dropdown-selector.component.ts | 13 +++++++++ libs/ui/inputs/src/lib/ui-inputs.module.ts | 2 +- 4 files changed, 23 insertions(+), 31 deletions(-) diff --git a/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.spec.ts b/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.spec.ts index d2ba6f0c19..a36a3c8f1d 100644 --- a/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.spec.ts +++ b/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.spec.ts @@ -1,9 +1,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing' import { TranslateModule } from '@ngx-translate/core' -import { ButtonComponent } from '../button/button.component' import { DropdownSelectorComponent } from './dropdown-selector.component' -import { OverlayModule } from '@angular/cdk/overlay' -import { MatIconModule } from '@angular/material/icon' describe('DropdownSelectorComponent', () => { let component: DropdownSelectorComponent @@ -11,13 +8,7 @@ describe('DropdownSelectorComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - imports: [ - ButtonComponent, - OverlayModule, - MatIconModule, - TranslateModule.forRoot(), - ], - declarations: [DropdownSelectorComponent], + imports: [DropdownSelectorComponent, TranslateModule.forRoot()], }).compileComponents() }) diff --git a/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.stories.ts b/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.stories.ts index d560441869..1ce8402e66 100644 --- a/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.stories.ts +++ b/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.stories.ts @@ -1,37 +1,25 @@ +import { HttpClientModule } from '@angular/common/http' +import { importProvidersFrom } from '@angular/core' +import { TRANSLATE_DEFAULT_CONFIG } from '@geonetwork-ui/util/i18n' +import { TranslateModule } from '@ngx-translate/core' import { applicationConfig, componentWrapperDecorator, Meta, - moduleMetadata, StoryObj, } from '@storybook/angular' import { DropdownSelectorComponent } from './dropdown-selector.component' -import { OverlayModule } from '@angular/cdk/overlay' -import { TranslateModule } from '@ngx-translate/core' -import { - TRANSLATE_DEFAULT_CONFIG, - UtilI18nModule, -} from '@geonetwork-ui/util/i18n' -import { MatIcon } from '@angular/material/icon' -import { ButtonComponent } from '../button/button.component' -import { importProvidersFrom } from '@angular/core' export default { title: 'Inputs/DropdownSelectorComponent', component: DropdownSelectorComponent, decorators: [ - moduleMetadata({ - declarations: [MatIcon], - imports: [ - ButtonComponent, - UtilI18nModule, - OverlayModule, - TranslateModule, - ], - }), applicationConfig({ providers: [ - importProvidersFrom(TranslateModule.forRoot(TRANSLATE_DEFAULT_CONFIG)), + importProvidersFrom( + HttpClientModule, + TranslateModule.forRoot(TRANSLATE_DEFAULT_CONFIG) + ), ], }), componentWrapperDecorator( diff --git a/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.ts b/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.ts index 28364f421a..296995ffd2 100644 --- a/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.ts +++ b/libs/ui/inputs/src/lib/dropdown-selector/dropdown-selector.component.ts @@ -2,6 +2,7 @@ import { CdkConnectedOverlay, CdkOverlayOrigin, ConnectedPosition, + OverlayModule, } from '@angular/cdk/overlay' import { ChangeDetectionStrategy, @@ -17,6 +18,10 @@ import { } from '@angular/core' import { firstValueFrom } from 'rxjs' import { DropdownChoice } from './dropdown-selector.model' +import { CommonModule } from '@angular/common' +import { TranslateModule } from '@ngx-translate/core' +import { MatIconModule } from '@angular/material/icon' +import { ButtonComponent } from '../button/button.component' const DEFAULT_ROW_NUMBERS = 6 @@ -25,6 +30,14 @@ const DEFAULT_ROW_NUMBERS = 6 templateUrl: './dropdown-selector.component.html', styleUrls: ['./dropdown-selector.component.css'], changeDetection: ChangeDetectionStrategy.OnPush, + standalone: true, + imports: [ + CommonModule, + ButtonComponent, + OverlayModule, + MatIconModule, + TranslateModule, + ], }) export class DropdownSelectorComponent implements OnInit { @Input() title: string diff --git a/libs/ui/inputs/src/lib/ui-inputs.module.ts b/libs/ui/inputs/src/lib/ui-inputs.module.ts index 09709ee26e..c7b3c40d4d 100644 --- a/libs/ui/inputs/src/lib/ui-inputs.module.ts +++ b/libs/ui/inputs/src/lib/ui-inputs.module.ts @@ -35,7 +35,6 @@ import { EditableLabelDirective } from './editable-label/editable-label.directiv @NgModule({ declarations: [ - DropdownSelectorComponent, AutocompleteComponent, TextInputComponent, DragAndDropFileInputComponent, @@ -71,6 +70,7 @@ import { EditableLabelDirective } from './editable-label/editable-label.directiv EditableLabelDirective, TextAreaComponent, ButtonComponent, + DropdownSelectorComponent, ], exports: [ DropdownSelectorComponent,