forked from onecx/onecx-portal-ui-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/basic-search-to-simple-search-improvements
- Loading branch information
Showing
36 changed files
with
826 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ts/create-or-edit-search-config-dialog/create-or-edit-search-config-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
14 changes: 14 additions & 0 deletions
14
...ts/create-or-edit-search-config-dialog/create-or-edit-search-config-dialog.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
147 changes: 147 additions & 0 deletions
147
...create-or-edit-search-config-dialog/create-or-edit-search-config-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) |
59 changes: 59 additions & 0 deletions
59
...ents/create-or-edit-search-config-dialog/create-or-edit-search-config-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
libs/portal-integration-angular/src/lib/core/components/diagram/diagram.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
libs/portal-integration-angular/src/lib/core/components/diagram/diagram.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.