From 1a4f5b58a0374ad19ee4102050fb6ca2392a9de3 Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Thu, 7 Oct 2021 17:45:47 +0200 Subject: [PATCH] Improve unit types Put the possible element types explicitly. --- projects/common/unit.ts | 3 ++- projects/editor/src/app/UnitFactory.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/common/unit.ts b/projects/common/unit.ts index 6a81aaec5..219b9a270 100644 --- a/projects/common/unit.ts +++ b/projects/common/unit.ts @@ -28,7 +28,8 @@ export interface UnitPageSection { export interface UnitUIElement { [index: string]: string | number | boolean | string[] | undefined; - type: string; // TODO maybe use enum or manual enumeration, because possible values are known + type: 'text' | 'button' | 'text-field' | 'text-area' | 'checkbox' + | 'dropdown' | 'radio' | 'image' | 'audio' | 'video'; id: string; zIndex: number width: number; diff --git a/projects/editor/src/app/UnitFactory.ts b/projects/editor/src/app/UnitFactory.ts index dbd474275..9f9c3a404 100644 --- a/projects/editor/src/app/UnitFactory.ts +++ b/projects/editor/src/app/UnitFactory.ts @@ -40,7 +40,8 @@ export function createUnitPageSection(): UnitPageSection { }; } -export function createUnitUIElement(type: string): UnitUIElement { +export function createUnitUIElement(type: 'text' | 'button' | 'text-field' | 'text-area' | 'checkbox' +| 'dropdown' | 'radio' | 'image' | 'audio' | 'video'): UnitUIElement { return { type, id: 'id_placeholder', -- GitLab