Skip to content
Snippets Groups Projects
Commit c9978a9b authored by Duc Bui Tien's avatar Duc Bui Tien
Browse files

bugfix switch value was string so first binding was always true

parent d9d59f89
No related branches found
No related tags found
2 merge requests!2UnicadoGuiBackend,!1New UnicadoGUI Branch
...@@ -108,8 +108,6 @@ ...@@ -108,8 +108,6 @@
const toggleModules = () => (modulesModalOpen = !modulesModalOpen); const toggleModules = () => (modulesModalOpen = !modulesModalOpen);
const toggleLoop =() => (loopOpen = !loopOpen); const toggleLoop =() => (loopOpen = !loopOpen);
let testbool:boolean = true;
onMount(async ()=>{ onMount(async ()=>{
const res = await fetch("http://127.0.0.1:8000/convergence"); const res = await fetch("http://127.0.0.1:8000/convergence");
const data = await res.json(); const data = await res.json();
...@@ -165,6 +163,7 @@ ...@@ -165,6 +163,7 @@
modalModule.response = JSON.parse(data); modalModule.response = JSON.parse(data);
modalModule.html = []; modalModule.html = [];
test(modalModule.response) test(modalModule.response)
modalModule = modalModule;
generateHTML(modalModule.response); generateHTML(modalModule.response);
modalModule = modalModule; modalModule = modalModule;
}catch (error){ }catch (error){
...@@ -182,6 +181,7 @@ ...@@ -182,6 +181,7 @@
} }
if(value.hasOwnProperty("value")){ if(value.hasOwnProperty("value")){
if(value["@description"]&&value["@description"].includes("Switch")){ if(value["@description"]&&value["@description"].includes("Switch")){
value.value= (value.value === 'true'||value.value==="1") //transform string input to boolean for easier binding
modalModule.html.push(new SettingsSwitch(key,value["@description"],value)) modalModule.html.push(new SettingsSwitch(key,value["@description"],value))
}else if(value["@description"]&&value["@description"].includes("Selector")){ }else if(value["@description"]&&value["@description"].includes("Selector")){
let options = []; let options = [];
...@@ -354,6 +354,7 @@ ...@@ -354,6 +354,7 @@
{#each modalModule.html as element} {#each modalModule.html as element}
{#if element.type=="switch"} {#if element.type=="switch"}
<Input id={element.label} type="switch" label="{formatLabel(element.label)}" bind:checked={element.bind.value}/> <Input id={element.label} type="switch" label="{formatLabel(element.label)}" bind:checked={element.bind.value}/>
<p>{element.bind.value}</p>
<Tooltip target={element.label} placement="left"> <Tooltip target={element.label} placement="left">
{element.description} {element.description}
</Tooltip> </Tooltip>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment