Skip to content

Commit

Permalink
Update boolean-input.component.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
heinerwalter authored Oct 29, 2024
1 parent 77776cf commit da693d1
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { Component, Input } from '@angular/core';
import { InputBaseWithValue } from '../input-base';

type RadioInputDataSourceOption = { value: boolean | undefined, name: string };


@Component({
selector: 'pe-boolean-input',
templateUrl: './boolean-input.component.html',
Expand All @@ -22,6 +25,37 @@ export class BooleanInputComponent extends InputBaseWithValue<boolean> {
*/
@Input() public allowIndeterminate: boolean = false;

// region Radio Input

/**
* Only if `type == 'radio'`:
* Optional yes label used by the radio input. If undefined, the default label is used instead.
*/
@Input() public yesLabel: string | undefined = undefined;
/**
* Only if `type == 'radio'`:
* Optional no label used by the radio input. If undefined, the default label is used instead.
*/
@Input() public noLabel: string | undefined = undefined;
/**
* Only if `type == 'radio'`:
* Optional indeterminate label used by the radio input. If undefined, the default label is used instead.
*/
@Input() public indeterminateLabel: string | undefined = undefined;

/** Returns a data source for the radio input component based on the input properties of this component. */
protected get radioInputDataSource(): RadioInputDataSourceOption[] {
const yesOption: RadioInputDataSourceOption = { value: true, name: this.yesLabel || 'Ja' };
const noOption: RadioInputDataSourceOption = { value: false, name: this.noLabel || 'Nein' };
if (!allowIndeterminate)

Check failure on line 50 in projects/ngx-property-editor/src/lib/components/input/boolean-input/boolean-input.component.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Cannot find name 'allowIndeterminate'. Did you mean the instance member 'this.allowIndeterminate'?

Check failure on line 50 in projects/ngx-property-editor/src/lib/components/input/boolean-input/boolean-input.component.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Cannot find name 'allowIndeterminate'. Did you mean the instance member 'this.allowIndeterminate'?

Check failure on line 50 in projects/ngx-property-editor/src/lib/components/input/boolean-input/boolean-input.component.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find name 'allowIndeterminate'. Did you mean the instance member 'this.allowIndeterminate'?

Check failure on line 50 in projects/ngx-property-editor/src/lib/components/input/boolean-input/boolean-input.component.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find name 'allowIndeterminate'. Did you mean the instance member 'this.allowIndeterminate'?
return [yesOption, noOption];

const indeterminateOption: RadioInputDataSourceOption = { value: undefined, name: this.indeterminateLabel || 'Keine Angabe' };
return [yesOption, noOption, indeterminateOption];
}

// endregion

public constructor() {
super();
}
Expand Down

0 comments on commit da693d1

Please sign in to comment.