From 9401b63361229afa17709078e283a339dbadb260 Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Thu, 19 Aug 2021 17:48:41 +0200 Subject: [PATCH] Add option to allow deselection of drowdown value --- projects/common/element-components/dropdown.component.ts | 1 + projects/common/unit.ts | 1 + projects/editor/src/app/UnitFactory.ts | 1 + .../page-view/properties/element-properties.component.ts | 6 ++++++ 4 files changed, 9 insertions(+) diff --git a/projects/common/element-components/dropdown.component.ts b/projects/common/element-components/dropdown.component.ts index 7774b74a0..0a7e2127e 100644 --- a/projects/common/element-components/dropdown.component.ts +++ b/projects/common/element-components/dropdown.component.ts @@ -18,6 +18,7 @@ import { FormElementComponent } from '../form-element-component.directive'; {{$any(elementModel).label}} </mat-label> <mat-select [formControl]="elementFormControl"> + <mat-option *ngIf="elementModel.allowUnset" value=""></mat-option> <mat-option *ngFor="let option of elementModel.options" [value]="option"> {{option}} </mat-option> diff --git a/projects/common/unit.ts b/projects/common/unit.ts index 6714723b4..284a53f62 100644 --- a/projects/common/unit.ts +++ b/projects/common/unit.ts @@ -100,6 +100,7 @@ export interface DropdownElement extends InputUIElement, TextUIElement, SurfaceU label: string; options: string[]; value: string | undefined; + allowUnset: boolean; } export interface RadioButtonGroupElement extends InputUIElement, TextUIElement, SurfaceUIElement { diff --git a/projects/editor/src/app/UnitFactory.ts b/projects/editor/src/app/UnitFactory.ts index 37ca23a7b..a6d0dc6ae 100644 --- a/projects/editor/src/app/UnitFactory.ts +++ b/projects/editor/src/app/UnitFactory.ts @@ -143,6 +143,7 @@ export function createCheckboxElement(): CheckboxElement { export function createDropdownElement(): DropdownElement { return <DropdownElement><unknown>{ options: [], + allowUnset: false, ...createUnitUIElement('dropdown'), ...createInputUIElement('Label Dropdown', undefined), ...createTextUIElement(), diff --git a/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.ts b/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.ts index deee93a51..61933b7bd 100644 --- a/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.ts +++ b/projects/editor/src/app/components/unit-view/page-view/properties/element-properties.component.ts @@ -65,6 +65,12 @@ import { SelectionService } from '../../../../selection.service'; </mat-select> </mat-form-field> + <mat-checkbox *ngIf="combinedProperties.hasOwnProperty('allowUnset')" + [checked]="$any(combinedProperties.allowUnset)" + (change)="updateModel('allowUnset', $event.checked)"> + Deselektion erlauben + </mat-checkbox> + <mat-divider></mat-divider> <mat-checkbox *ngIf="combinedProperties.hasOwnProperty('required')" -- GitLab