Skip to content

Commit

Permalink
fix: remove search config and add search config info (#161)
Browse files Browse the repository at this point in the history
* fix: type changed from search config to search config info

* fix: fix tests

* fix: remove unused type SearchConfig

* fix: fix linter error

* fix: fix lint2
  • Loading branch information
anninowak authored Mar 8, 2024
1 parent 1ee49dd commit d1db2ce
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 43 deletions.
2 changes: 1 addition & 1 deletion libs/portal-integration-angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export * from './lib/model/data-action'
export * from './lib/model/button-dialog'
export * from './lib/model/diagram-type'
export * from './lib/model/config-key.model'
export * from './lib/model/search-config'
export * from './lib/model/search-config-info'

// core
export * from './lib/api/iauth.service'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,29 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations'
import { TranslateService } from '@ngx-translate/core'
import { MessageModule } from 'primeng/message'
import { MockAuthModule } from '../../../mock-auth/mock-auth.module'
import { SearchConfigPrimitive, SearchConfig } from '../../../model/search-config'
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'
import { SearchConfigHarness } from '../../../../../testing'
import { PrimeNgModule } from '../../primeng.module'
import { ReactiveFormsModule } from '@angular/forms'
import { SearchConfigInfo } from '../../../model/search-config-info'

describe('SearchConfigComponent', () => {
let translateService: TranslateService
let component: SearchConfigComponent
let fixture: ComponentFixture<SearchConfigComponent>

const searchConfigurations: Record<string, SearchConfigPrimitive>[] = [
{
name: 'test',
startDate: undefined,
endDate: undefined,
},
{
name: 'example',
startDate: new Date(2023, 0, 15, 12, 30, 45),
endDate: new Date(2023, 0, 19, 12, 30, 45),
},
]

const searchConfigs: SearchConfig[] = [
const searchConfigs: SearchConfigInfo[] = [
{
id: '01',
name: 'Simple search config',
fieldListVersion: 1,
isReadonly: true,
isAdvanced: true,
values: searchConfigurations[0],
},
{
id: '02',
name: 'Adapted search config',
fieldListVersion: 1,
isReadonly: true,
isAdvanced: true,
values: searchConfigurations[1],
},
]

const emptySearchConfigEntry: SearchConfig[] = []
const emptySearchConfigEntry: SearchConfigInfo[] = []

const placeholderKey = 'OCX_SEARCH_HEADER.OCX_SEARCH_CONFIG.DROPDOWN_DEFAULT'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { SearchConfig } from '../../../model/search-config'
import { FormControl, FormGroup } from '@angular/forms'
import { SearchConfigInfo } from '../../../model/search-config-info'

@Component({
selector: 'ocx-search-config',
Expand All @@ -9,21 +9,21 @@ import { FormControl, FormGroup } from '@angular/forms'
})
export class SearchConfigComponent implements OnInit {
@Input()
searchConfigs: SearchConfig[] | [] | undefined
searchConfigs: SearchConfigInfo[] | [] | undefined

@Input() placeholderKey = 'OCX_SEARCH_HEADER.OCX_SEARCH_CONFIG.DROPDOWN_DEFAULT'

@Output()
selectedSearchConfigChanged: EventEmitter<SearchConfig> = new EventEmitter()
selectedSearchConfigChanged: EventEmitter<SearchConfigInfo> = new EventEmitter()

formGroup: FormGroup | undefined
ngOnInit(): void {
this.formGroup = new FormGroup({
searchConfigForm: new FormControl<SearchConfig | null>(null),
searchConfigForm: new FormControl<SearchConfigInfo | null>(null),
})
}

onSearchConfigChange(searchConfig: SearchConfig) {
onSearchConfigChange(searchConfig: SearchConfigInfo) {
this.selectedSearchConfigChanged?.emit(searchConfig)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
ViewChild,
} from '@angular/core'
import { Action } from '../page-header/page-header.component'
import { SearchConfig } from '../../../model/search-config'
import { SearchConfigInfo } from '../../../model/search-config-info'

/**
* To trigger the search when Enter key is pressed inside a search parameter field,
Expand All @@ -24,7 +24,7 @@ import { SearchConfig } from '../../../model/search-config'
styleUrls: ['./search-header.component.scss'],
})
export class SearchHeaderComponent implements AfterViewInit {
@Input() searchConfigs: SearchConfig[] | undefined
@Input() searchConfigs: SearchConfigInfo[] | undefined
@Input() header = ''

/**
Expand Down Expand Up @@ -52,7 +52,7 @@ export class SearchHeaderComponent implements AfterViewInit {

@Output() searched: EventEmitter<any> = new EventEmitter()
@Output() resetted: EventEmitter<any> = new EventEmitter()
@Output() selectedSearchConfigChanged: EventEmitter<SearchConfig> = new EventEmitter()
@Output() selectedSearchConfigChanged: EventEmitter<SearchConfigInfo> = new EventEmitter()
@Output() viewModeChanged: EventEmitter<string> = new EventEmitter()
@ContentChild('additionalToolbarContent')
additionalToolbarContent: TemplateRef<any> | undefined
Expand Down Expand Up @@ -121,7 +121,7 @@ export class SearchHeaderComponent implements AfterViewInit {
}
}

confirmSearchConfig(searchConfig: SearchConfig) {
confirmSearchConfig(searchConfig: SearchConfigInfo) {
this.selectedSearchConfigChanged?.emit(searchConfig)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface SearchConfigInfo {
id: string
name: string
}

This file was deleted.

0 comments on commit d1db2ce

Please sign in to comment.