Skip to content

Commit

Permalink
Merge branch 'main' into feat/search-header-subheader-definition
Browse files Browse the repository at this point in the history
  • Loading branch information
markuczy committed Feb 26, 2024
2 parents f780d6b + b8cff92 commit 0439b24
Show file tree
Hide file tree
Showing 36 changed files with 826 additions and 31 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [4.8.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.7.0...v4.8.0) (2024-02-26)


### Features

* allow dynamically switching diagram type ([#144](https://github.com/onecx/onecx-portal-ui-libs/issues/144)) ([ac0e2e0](https://github.com/onecx/onecx-portal-ui-libs/commit/ac0e2e051f7dee12e45561bfda1cebf642d0504c))
* save and edit search config component ([#139](https://github.com/onecx/onecx-portal-ui-libs/issues/139)) ([635339a](https://github.com/onecx/onecx-portal-ui-libs/commit/635339aae8dedfa96d6a77798de591ef4ae49829))


### Bug Fixes

* check length of occurences and ([#141](https://github.com/onecx/onecx-portal-ui-libs/issues/141)) ([782cb27](https://github.com/onecx/onecx-portal-ui-libs/commit/782cb27643a32c7fcf5f9e14a3a4876cae4972e5))
* current page should persist between layout changes ([#142](https://github.com/onecx/onecx-portal-ui-libs/issues/142)) ([e023add](https://github.com/onecx/onecx-portal-ui-libs/commit/e023adda69ae2a90cb4a5b82ba87fdb60eba0670))
* empty message allignment to amount of columns ([#140](https://github.com/onecx/onecx-portal-ui-libs/issues/140)) ([3459c67](https://github.com/onecx/onecx-portal-ui-libs/commit/3459c676903225d1356ee7116951f3e25c60feb1))
* removed conflicting style ([#137](https://github.com/onecx/onecx-portal-ui-libs/issues/137)) ([7ddcd17](https://github.com/onecx/onecx-portal-ui-libs/commit/7ddcd17c0e025708353d8a525bb07ac13500cb6d))

## [4.7.0](https://github.com/onecx/onecx-portal-ui-libs/compare/v4.6.0...v4.7.0) (2024-02-21)


Expand Down
2 changes: 1 addition & 1 deletion libs/accelerator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/accelerator",
"version": "4.7.0",
"version": "4.8.0",
"peerDependencies": {
"tslib": "^2.3.0",
"rxjs": "7.8.1"
Expand Down
2 changes: 1 addition & 1 deletion libs/integration-interface/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/integration-interface",
"version": "4.7.0",
"version": "4.8.0",
"peerDependencies": {
"tslib": "^2.3.0",
"rxjs": "7.8.1",
Expand Down
2 changes: 1 addition & 1 deletion libs/keycloak-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/keycloak-auth",
"version": "4.7.0",
"version": "4.8.0",
"peerDependencies": {
"@angular/common": ">=15.2.7",
"@angular/core": ">=15.2.7",
Expand Down
12 changes: 11 additions & 1 deletion libs/portal-integration-angular/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"RIGHT": "Rechts"
}
},
"OCX_SEARCH_CONFIG": {
"PLACEHOLDER": "Bitte geben Sie den Namen der Suchkonfiguration an.",
"SAVE_COLUMNS_OPTION": "Möchten Sie die angezeigten Spalten speichern?",
"SAVE_INPUT_FIELDS_OPTION": "Möchten Sie die Werte aus den Suchfeldern speichern?"
},
"OCX_LIST_GRID_SORT": {
"DROPDOWN": {
"PLACEHOLDER": "Sortierung auswählen",
Expand Down Expand Up @@ -83,7 +88,12 @@
},
"OCX_DIAGRAM": {
"SUM": "Gesamtanzahl",
"NO_DATA": "Es sind keine Daten vorhanden"
"NO_DATA": "Es sind keine Daten vorhanden",
"SWITCH_DIAGRAM_TYPE": {
"PIE": "Zu Tortendiagramm wechseln",
"HORIZONTAL_BAR": "Zu horizontalem Balkendiagramm wechseln",
"VERTICAL_BAR": "Zu vertikalem Balkendiagramm wechseln"
}
},
"OCX_PORTAL_VIEWPORT": {
"SUCCESS": "Erfolg!",
Expand Down
12 changes: 11 additions & 1 deletion libs/portal-integration-angular/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
"RIGHT": "Right"
}
},
"OCX_SEARCH_CONFIG": {
"PLACEHOLDER": "Please enter the name of the search configuration",
"SAVE_COLUMNS_OPTION": "Do you want to save the shown columns?",
"SAVE_INPUT_FIELDS_OPTION": "Do you want to save the input values from the input fields?"
},
"OCX_LIST_GRID_SORT": {
"DROPDOWN": {
"PLACEHOLDER": "Select sorting",
Expand Down Expand Up @@ -83,7 +88,12 @@
},
"OCX_DIAGRAM": {
"SUM": "Total",
"NO_DATA": "There is no data available"
"NO_DATA": "There is no data available",
"SWITCH_DIAGRAM_TYPE": {
"PIE": "Switch to pie chart",
"HORIZONTAL_BAR": "Switch to horizontal bar chart",
"VERTICAL_BAR": "Switch to vertical bar chart"
}
},
"OCX_PORTAL_VIEWPORT": {
"SUCCESS": "Success!",
Expand Down
2 changes: 1 addition & 1 deletion libs/portal-integration-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@onecx/portal-integration-angular",
"version": "4.7.0",
"version": "4.8.0",
"peerDependencies": {
"@angular-architects/module-federation": "15.0.0",
"@angular/common": "^15.2.7",
Expand Down
1 change: 1 addition & 0 deletions libs/portal-integration-angular/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export * from './lib/core/components/search-config/search-config.component'
export * from './lib/core/components/loading-indicator/loading-indicator.component'
export * from './lib/core/components/content-container/content-container.component'
export * from './lib/core/components/content/content.component'
export * from './lib/core/components/create-or-edit-search-config-dialog/create-or-edit-search-config-dialog.component'

// services
export * from './lib/services/app.menu.service'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<form [formGroup]="searchConfigFormGroup" [class]="'searchConfigDialog'">
<div>
<input
type="text"
pInputText
formControlName="searchConfigName"
id="searchConfigName"
[placeholder]="placeHolderKey | translate"
/>
</div>

<div>
<p-checkbox formControlName="saveInputValues" [value]="saveInputValues" [binary]="true" inputId="saveInputValuesId">
</p-checkbox>
<label for="saveInputValuesId">{{ ("OCX_SEARCH_CONFIG.SAVE_INPUT_FIELDS_OPTION" | translate) }}</label>
</div>

<div>
<p-checkbox
formControlName="saveColumns"
[value]="saveColumns"
[binary]="true"
inputId="saveColumnsId"
></p-checkbox>
<label for="saveColumnsId">{{ ("OCX_SEARCH_CONFIG.SAVE_COLUMNS_OPTION" | translate) }}</label>
</div>
</form>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.searchConfigDialog {
display: flex;
flex-direction: column;
gap: 1em;
margin-bottom: 1em;
}

:host ::ng-deep .p-inputtext {
width: 100%;
}

:host ::ng-deep .p-checkbox {
margin-right: 1em;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import { ComponentFixture, TestBed } from '@angular/core/testing'
import { CreateOrEditSearchConfigDialogComponent } from './create-or-edit-search-config-dialog.component'
import { CheckboxModule } from 'primeng/checkbox'
import { MockAuthModule } from '../../../mock-auth/mock-auth.module'
import { TranslateTestingModule } from 'ngx-translate-testing'
import { HttpClientTestingModule } from '@angular/common/http/testing'
import { TranslateService } from '@ngx-translate/core'
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'
import { PCheckboxHarness, CreateOrEditSearchConfigDialogHarness } from '../../../../../testing'
import { DialogState } from '../../../services/portal-dialog.service'
import { ReactiveFormsModule } from '@angular/forms'
import { InputTextModule } from 'primeng/inputtext'

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

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [CreateOrEditSearchConfigDialogComponent],
imports: [
CheckboxModule,
MockAuthModule,
TranslateTestingModule.withTranslations({
en: require('./../../../../../assets/i18n/en.json'),
de: require('./../../../../../assets/i18n/de.json'),
}),
HttpClientTestingModule,
ReactiveFormsModule,
InputTextModule,
],
}).compileComponents()

fixture = TestBed.createComponent(CreateOrEditSearchConfigDialogComponent)
component = fixture.componentInstance

translateService = TestBed.inject(TranslateService)
translateService.setDefaultLang('en')
translateService.use('en')

fixture.detectChanges()
dialogHarness = await TestbedHarnessEnvironment.harnessForFixture(fixture, CreateOrEditSearchConfigDialogHarness)
})

it('should create the component', () => {
expect(component).toBeTruthy()
})

it('should load the CreateOrEditSearchConfigDialogHarness', async () => {
expect(dialogHarness).toBeTruthy()
})

it('should set the DialogResult of the saveInputValuesId checkbox to true when the saveInputValuesId checkbox is checked', async () => {
const saveInputValuesCheckbox = await dialogHarness.getHarness(
PCheckboxHarness.with({ inputid: 'saveInputValuesId' })
)
await saveInputValuesCheckbox.click()
const _state: DialogState<CreateOrEditSearchConfigDialogComponent> = { button: 'primary', result: undefined }
component.ocxDialogButtonClicked(_state)
const dialogResult = {
searchConfigName: '',
saveInputValues: true,
saveColumns: false,
}
expect(component.dialogResult).toEqual(dialogResult)
})

it('should set the DialogResult of the saveColumnsId checkbox initially false', async () => {
const _state: DialogState<CreateOrEditSearchConfigDialogComponent> = { button: 'primary', result: undefined }
await component.ocxDialogButtonClicked(_state)
const dialogResult = {
searchConfigName: '',
saveInputValues: false,
saveColumns: false,
}
expect(component.dialogResult).toEqual(dialogResult)
})

it('should set the DialogResult of the searchConfig input Field to the entered value', async () => {
await (await dialogHarness.getSearchConfigInputHarness()).setValue('search Config')
const _state: DialogState<CreateOrEditSearchConfigDialogComponent> = { button: 'primary', result: undefined }
await component.ocxDialogButtonClicked(_state)
const dialogResult = {
searchConfigName: 'search Config',
saveInputValues: false,
saveColumns: false,
}
expect(component.dialogResult).toEqual(dialogResult)
})

it('should set the saveColumnsId checkbox initially to unchecked', async () => {
const saveInputValuesCheckbox = await dialogHarness.getSaveColumnsCheckboxHarness()
const checked = await saveInputValuesCheckbox.isChecked()
expect(checked).toBeFalsy()
})

it('should set the saveInputValues checkbox initially to unchecked', async () => {
const saveInputValuesCheckbox = await dialogHarness.getSaveInputValuesCheckboxHarness()
const checked = await saveInputValuesCheckbox.isChecked()
expect(checked).toBeFalsy()
})

it('should set the saveInputValues checkbox to true when it is clicked', async () => {
const saveInputValuesCheckbox = await dialogHarness.getSaveInputValuesCheckboxHarness()
await saveInputValuesCheckbox.click()
const checked = await saveInputValuesCheckbox.isChecked()
expect(checked).toBeTruthy()
})

it('should emit true when the searchConfig name is not an empty string and the saveColumnsCheckBox is clicked', async () => {
let done: () => void
const finished = new Promise<void>((resolve) => (done = resolve))
let enabled = false
component.primaryButtonEnabled.subscribe((v) => {
enabled = v
done()
})

const searchConfigInputHarness = await dialogHarness.getSearchConfigInputHarness()
searchConfigInputHarness.setValue('test')
const saveInputValuesCheckbox = await dialogHarness.getSaveColumnsCheckboxHarness()
await saveInputValuesCheckbox.click()

await finished
expect(enabled).toEqual(true)
})

it('emit true when the searchConfig Name is not an empty string and the saveInputValuesCheckbox is clicked', async () => {
let done: () => void
const finished = new Promise<void>((resolve) => (done = resolve))
let enabled = false
component.primaryButtonEnabled.subscribe((v) => {
enabled = v
done()
})

const searchConfigInputHarness = await dialogHarness.getSearchConfigInputHarness()
searchConfigInputHarness.setValue('test')
const saveInputValuesCheckbox = await dialogHarness.getSaveInputValuesCheckboxHarness()
await saveInputValuesCheckbox.click()

await finished
expect(enabled).toEqual(true)
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Component, EventEmitter, Input, Output } from '@angular/core'
import { FormControl, FormGroup } from '@angular/forms'
import {
DialogButtonClicked,
DialogPrimaryButtonDisabled,
DialogResult,
DialogState,
} from '../../../services/portal-dialog.service'
import { Observable, map } from 'rxjs'

export type CreateOrEditSearchDialogContent = {
searchConfigName: string
saveInputValues: boolean
saveColumns: boolean
}
@Component({
selector: 'ocx-create-or-edit-search-config-dialog',
templateUrl: './create-or-edit-search-config-dialog.component.html',
styleUrls: ['./create-or-edit-search-config-dialog.component.scss'],
})
export class CreateOrEditSearchConfigDialogComponent
implements
DialogPrimaryButtonDisabled,
DialogResult<CreateOrEditSearchDialogContent>,
DialogButtonClicked<CreateOrEditSearchConfigDialogComponent>
{
@Input() searchConfigName: string | undefined
@Input() saveInputValues: boolean | undefined
@Input() saveColumns: boolean | undefined
placeHolderKey = 'OCX_SEARCH_CONFIG.PLACEHOLDER'
@Output() primaryButtonEnabled: EventEmitter<boolean> = new EventEmitter()
searchConfigFormGroup: FormGroup = new FormGroup({
searchConfigName: new FormControl<string>(''),
saveInputValues: new FormControl<boolean>(false),
saveColumns: new FormControl<boolean>(false),
})
dialogResult: CreateOrEditSearchDialogContent = { searchConfigName: '', saveInputValues: false, saveColumns: false }
constructor() {
this.searchConfigFormGroup.valueChanges
.pipe(
map(
(dialogFormValues: CreateOrEditSearchDialogContent) =>
!!dialogFormValues.searchConfigName && (dialogFormValues.saveInputValues || dialogFormValues.saveColumns)
)
)
.subscribe(this.primaryButtonEnabled)
}

ocxDialogButtonClicked(
_state: DialogState<CreateOrEditSearchConfigDialogComponent>
): boolean | Observable<boolean> | Promise<boolean> | undefined {
this.dialogResult = {
searchConfigName: this.searchConfigFormGroup?.get('searchConfigName')?.value,
saveInputValues: this.searchConfigFormGroup?.get('saveInputValues')?.value,
saveColumns: this.searchConfigFormGroup?.get('saveColumns')?.value,
}
return true
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<ng-container *ngIf="this.data">
<div class="flex justify-content-center pb-2" *ngIf="shownDiagramTypes.length > 1">
<p-selectButton
[options]="shownDiagramTypes"
[(ngModel)]="selectedDiagramType"
optionLabel="icon"
(onChange)="onDiagramTypeChanged($event)"
name="diagram-type-select-button"
>
<ng-template let-item pTemplate>
<i [class]="item.icon" [title]="item.title || (item.titleKey | translate)"></i>
</ng-template>
</p-selectButton>
</div>
<div class="w-full flex justify-content-center">
<p-chart
id="diagram"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
::ng-deep {
.p-buttonset .p-button {
min-width: auto;
}

.p-buttonset {
display: flex;
}
}
Loading

0 comments on commit 0439b24

Please sign in to comment.