From 4bd84bebdaa0c2d82050fbedd1fa8260eb62146d Mon Sep 17 00:00:00 2001
From: Aijana Schumann <aijana.schumann@highstreet-technologies.com>
Date: Thu, 27 Aug 2020 09:01:53 +0200
Subject: Add link calculation app

Add link calculation app to odlux

Issue-ID: CCSDK-2562
Signed-off-by: Aijana Schumann <aijana.schumann@highstreet-technologies.com>
Change-Id: Ifc0a5b2a8bb974dfd85d70a9f05990b1f11925a3
Signed-off-by: Aijana Schumann <aijana.schumann@highstreet-technologies.com>
---
 .../src/components/uiElementBoolean.tsx             | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

(limited to 'sdnr/wt/odlux/apps/configurationApp/src/components/uiElementBoolean.tsx')

diff --git a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementBoolean.tsx b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementBoolean.tsx
index cc141ee35..2fbbf956f 100644
--- a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementBoolean.tsx
+++ b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementBoolean.tsx
@@ -16,29 +16,28 @@
  * ============LICENSE_END==========================================================================
  */
 
-import { ViewElementBoolean } from "../models/uiModels";
 import * as React from "react"
 import { MenuItem, FormHelperText, Select, FormControl, InputLabel } from "@material-ui/core";
-import { baseProps } from "./baseProps";
 
-type booleanInputProps = baseProps;
+import { ViewElementBoolean } from "../models/uiModels";
+import { BaseProps } from "./baseProps";
+
+type BooleanInputProps = BaseProps<boolean>;
 
-export const UiElementBoolean = (props: booleanInputProps) => {
+export const UiElementBoolean = (props: BooleanInputProps) => {
 
     const element = props.value as ViewElementBoolean;
 
-    let error = "";
     const value = String(props.inputValue).toLowerCase();
-    if (element.mandatory && value !== "true" && value !== "false") {
-        error = "Error";
-    }
+    const mandetoryError = element.mandatory && value !== 'true' && value !== 'false';
+    
     return (!props.readOnly || element.id != null
         ? (<FormControl style={{ width: 485, marginLeft: 20, marginRight: 20 }}>
             <InputLabel htmlFor={`select-${element.id}`} >{element.label}</InputLabel>
             <Select
                 required={!!element.mandatory}
-                error={!!error}
-                onChange={(e) => { props.onChange(e.target.value as any) }}
+                error={mandetoryError}
+                onChange={(e) => { props.onChange(e.target.value === 'true') }}
                 readOnly={props.readOnly}
                 disabled={props.disabled}
                 value={value}
@@ -51,7 +50,7 @@ export const UiElementBoolean = (props: booleanInputProps) => {
                 <MenuItem value={'false'}>{element.falseValue || 'False'}</MenuItem>
 
             </Select>
-            <FormHelperText>{error}</FormHelperText>
+            <FormHelperText>{mandetoryError ? "Value is mandetory" : ""}</FormHelperText>
         </FormControl>)
         : null
     );
-- 
cgit 1.2.3-korg

