Verified Commit 25920302 authored by Camil Staps's avatar Camil Staps 🙂

Update iTasks.Extensions.Dashboard to new JS interface

parent 35727c1d
......@@ -2,7 +2,7 @@ implementation module iTasks.Extensions.Dashboard
import iTasks
import iTasks.UI.Editor, iTasks.UI.Definition, iTasks.UI.JS.Interface
import qualified Data.Map as DM, Data.Error
import Text.HTML, StdMisc, Data.Func
import Text.HTML, StdMisc, StdArray, Data.Func
derive JSONEncode ControlLight
derive JSONDecode ControlLight
......@@ -34,15 +34,15 @@ where
valueFromState s = Just s
onAttributeChange me args world
| jsArgToString (args !! 0) == "diff"
# (color, world) = fromJSArray (toJSVal (args !! 1)) id world
# (svgEl,world) = .? (me .# "domEl" .# "children" .# 0) world
# (lightEl,world) = .? (svgEl .# "children" .# 1) world
onAttributeChange me {[0]=name,[1]=value} world = case jsValToString name of
Just "diff"
# (color, world) = jsValToList` value id world
# (svgEl,world) = me .# "domEl" .# "children" .# 0 .? world
# (lightEl,world) = svgEl .# "children" .# 1 .? world
# (_,world) = (lightEl .# "setAttribute" .$ ("fill",color)) world //Just update the color
= (jsNull,world)
| otherwise
= (jsNull,jsTrace "Unknown attribute change" world)
= world
_
= jsTrace "Unknown attribute change" world
color LightOnGreen = "green"
color LightOnRed = "red"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment