Skip to content

Commit

Permalink
feat(ui-inputs): change dropdown-selector to standalone
Browse files Browse the repository at this point in the history
  • Loading branch information
LHBruneton-C2C committed Apr 18, 2024
1 parent 52d3902 commit 2ea06c4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
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
let fixture: ComponentFixture<DropdownSelectorComponent>

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [
ButtonComponent,
OverlayModule,
MatIconModule,
TranslateModule.forRoot(),
],
declarations: [DropdownSelectorComponent],
imports: [DropdownSelectorComponent, TranslateModule.forRoot()],
}).compileComponents()
})

Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
CdkConnectedOverlay,
CdkOverlayOrigin,
ConnectedPosition,
OverlayModule,
} from '@angular/cdk/overlay'
import {
ChangeDetectionStrategy,
Expand All @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/inputs/src/lib/ui-inputs.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { EditableLabelDirective } from './editable-label/editable-label.directiv

@NgModule({
declarations: [
DropdownSelectorComponent,
AutocompleteComponent,
TextInputComponent,
DragAndDropFileInputComponent,
Expand Down Expand Up @@ -71,6 +70,7 @@ import { EditableLabelDirective } from './editable-label/editable-label.directiv
EditableLabelDirective,
TextAreaComponent,
ButtonComponent,
DropdownSelectorComponent,
],
exports: [
DropdownSelectorComponent,
Expand Down

0 comments on commit 2ea06c4

Please sign in to comment.