From f86f55114a77e47a163af78bfc32c7bc0aca5a04 Mon Sep 17 00:00:00 2001
From: rhenck <richard.henck@iqb.hu-berlin.de>
Date: Fri, 7 Jan 2022 12:09:15 +0100
Subject: [PATCH] Improve element defaults and add text for empty likert

---
 projects/common/models/uI-element.ts                         | 2 +-
 projects/common/ui-elements/checkbox/checkbox-element.ts     | 2 ++
 projects/common/ui-elements/dropdown/dropdown-element.ts     | 1 +
 projects/common/ui-elements/likert/likert.component.ts       | 3 +++
 projects/common/ui-elements/text-area/text-area-element.ts   | 1 +
 projects/common/ui-elements/text-field/text-field-element.ts | 1 +
 6 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/projects/common/models/uI-element.ts b/projects/common/models/uI-element.ts
index 0914e857f..83873d87d 100644
--- a/projects/common/models/uI-element.ts
+++ b/projects/common/models/uI-element.ts
@@ -15,7 +15,7 @@ export abstract class UIElement {
   type!: UIElementType;
 
   id: string = 'id_placeholder';
-  width: number = 180;
+  width: number = 190;
   height: number = 60;
 
   positionProps?: PositionProperties;
diff --git a/projects/common/ui-elements/checkbox/checkbox-element.ts b/projects/common/ui-elements/checkbox/checkbox-element.ts
index 04819a0c6..35e83bc6f 100644
--- a/projects/common/ui-elements/checkbox/checkbox-element.ts
+++ b/projects/common/ui-elements/checkbox/checkbox-element.ts
@@ -23,6 +23,8 @@ export class CheckboxElement extends InputElement implements PositionedElement,
 
     this.value = serializedElement.value as boolean || false; // booleans are always initialized false
 
+    this.width = serializedElement.width || 215;
+
     this.surfaceProps.backgroundColor =
       serializedElement.surfaceProps?.backgroundColor as string ||
       serializedElement.backgroundColor as string ||
diff --git a/projects/common/ui-elements/dropdown/dropdown-element.ts b/projects/common/ui-elements/dropdown/dropdown-element.ts
index 92dfc4d79..a23b225c3 100644
--- a/projects/common/ui-elements/dropdown/dropdown-element.ts
+++ b/projects/common/ui-elements/dropdown/dropdown-element.ts
@@ -24,6 +24,7 @@ export class DropdownElement extends InputElement implements PositionedElement,
     this.fontProps = initFontElement(serializedElement);
     this.surfaceProps = initSurfaceElement(serializedElement);
 
+    this.width = serializedElement.width || 240;
     this.height = serializedElement.height || 83;
   }
 }
diff --git a/projects/common/ui-elements/likert/likert.component.ts b/projects/common/ui-elements/likert/likert.component.ts
index 98237581c..0790dfae9 100644
--- a/projects/common/ui-elements/likert/likert.component.ts
+++ b/projects/common/ui-elements/likert/likert.component.ts
@@ -9,6 +9,9 @@ import { CompoundElementComponent } from '../../directives/compound-element.dire
 @Component({
   selector: 'app-likert',
   template: `
+    <div *ngIf="elementModel.rows.length === 0 && elementModel.columns.length === 0">
+      Keine Zeilen oder Spalten vorhanden
+    </div>
     <div [class.center-content]="elementModel.positionProps.dynamicPositioning &&
                                  elementModel.positionProps.fixedSize"
          [style.width]="elementModel.positionProps.fixedSize ? elementModel.width + 'px' : '100%'"
diff --git a/projects/common/ui-elements/text-area/text-area-element.ts b/projects/common/ui-elements/text-area/text-area-element.ts
index 58aecc2ce..c3440ae19 100644
--- a/projects/common/ui-elements/text-area/text-area-element.ts
+++ b/projects/common/ui-elements/text-area/text-area-element.ts
@@ -28,6 +28,7 @@ export class TextAreaElement extends InputElement implements PositionedElement,
     this.surfaceProps = initSurfaceElement(serializedElement);
 
     this.height = serializedElement.height || 132;
+    this.width = serializedElement.width || 230;
     this.surfaceProps.backgroundColor =
       serializedElement.surfaceProps?.backgroundColor as string ||
       serializedElement.backgroundColor as string ||
diff --git a/projects/common/ui-elements/text-field/text-field-element.ts b/projects/common/ui-elements/text-field/text-field-element.ts
index 022016508..166fbe54a 100644
--- a/projects/common/ui-elements/text-field/text-field-element.ts
+++ b/projects/common/ui-elements/text-field/text-field-element.ts
@@ -33,6 +33,7 @@ export class TextFieldElement extends InputElement implements PositionedElement,
     this.surfaceProps = initSurfaceElement(serializedElement);
 
     this.height = serializedElement.height || 100;
+    this.width = serializedElement.width || 230;
     this.surfaceProps.backgroundColor =
       serializedElement.surfaceProps?.backgroundColor as string ||
       serializedElement.backgroundColor as string ||
-- 
GitLab