Skip to content
Snippets Groups Projects
Commit b62b6a9a authored by rhenck's avatar rhenck
Browse files

Remove undefined value from checkbox

Can only be true/false.
parent 3a457001
No related branches found
No related tags found
No related merge requests found
......@@ -94,7 +94,7 @@ export interface TextAreaElement extends InputUIElement, TextUIElement, SurfaceU
}
export interface CheckboxElement extends InputUIElement, TextUIElement, SurfaceUIElement {
value: boolean | undefined;
value: boolean;
}
export interface DropdownElement extends InputUIElement, TextUIElement, SurfaceUIElement {
......
......@@ -134,7 +134,7 @@ export function createTextareaElement(): TextAreaElement {
export function createCheckboxElement(): CheckboxElement {
return <CheckboxElement>{
...createUnitUIElement('checkbox'),
...createInputUIElement('Label Checkbox', undefined),
...createInputUIElement('Label Checkbox', false),
...createTextUIElement(),
...createSurfaceUIElement(),
backgroundColor: 'transparent'
......
......@@ -45,10 +45,10 @@ import { SelectionService } from '../../../../selection.service';
</mat-form-field>
<section *ngIf="combinedProperties.type === 'checkbox'">
Vorbelegung
<mat-button-toggle-group (change)="transformToBoolAndUpdateModel('value', $event.value)">
<mat-button-toggle value="true">wahr</mat-button-toggle>
<mat-button-toggle value="false">falsch</mat-button-toggle>
<mat-button-toggle value="undefined">undefiniert</mat-button-toggle>
<mat-button-toggle-group [value]="combinedProperties.value"
(change)="updateModel('value', $event.value)">
<mat-button-toggle [value]="true">wahr</mat-button-toggle>
<mat-button-toggle [value]="false">falsch</mat-button-toggle>
</mat-button-toggle-group>
</section>
<mat-form-field *ngIf="combinedProperties.type === 'dropdown' || combinedProperties.type === 'radio'"
......@@ -399,24 +399,6 @@ export class ElementPropertiesComponent implements OnInit, OnDestroy {
this.unitService.alignElements(this.selectionService.getSelectedElements(), direction);
}
/* button group always handles values as string and since we also want to handle undefined
we need to transform the value before passing it on. */
transformToBoolAndUpdateModel(property: string, value: string): void { // TODO weg refactorn
switch (value) {
case 'true': {
this.updateModel(property, true);
break;
}
case 'false': {
this.updateModel(property, false);
break;
}
default: {
this.updateModel(property, undefined);
}
}
}
deleteElement(): void {
this.selectionService.selectedPageSection
.pipe(take(1))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment