Commit d47b4d7a authored by Bas Lijnse's avatar Bas Lijnse

Removed debug code and a little bit of cleanup

parent 744c0ea4
......@@ -146,7 +146,7 @@ where
onEdit _ (_, mbVal) (_, attrs) vst = (Ok (ChangeUI [SetAttribute "value" valJSON] [], (mbVal`, attrs)), vst)
where
(mbVal`, valJSON) = case mbVal of
Just val | isValid attrs val = (Just val, trace_n "json" $ toJSON val)
Just val | isValid attrs val = (Just val, toJSON val)
_ = (Nothing, JSONNull)
onRefresh toJSON dp new (mbOld, attrs) vst
......@@ -157,7 +157,7 @@ where
editorWithJSONEncode :: !((a -> JSONNode) -> Editor a) -> Editor a | JSONEncode{|*|} a
editorWithJSONEncode genFunc = genFunc toJSON
import StdDebug
//Components which cannot be edited
viewComponent :: !(a -> UIAttributes) !UIType -> Editor a | JSONEncode{|*|}, JSONDecode{|*|} a
viewComponent toAttributes type = leafEditorToEditor leafEditor
......
......@@ -14,6 +14,9 @@ from Data.Set import instance Foldable Set
from Data.Tuple import appSnd
from Data.Map import instance Functor (Map k)
from Data.Foldable import maximum
from Control.Monad import class Monad(..), >>=
from Control.Applicative import class Applicative(..), class pure(pure)
from Data.Maybe import instance Monad Maybe
import Text.GenJSON
......@@ -556,15 +559,18 @@ nodeSelected_ ruleNo (SelectByDepth n) p _ moves = length p == n
nodeSelected_ ruleNo (SelectDescendents) [_:_] _ moves = True
nodeSelected_ ruleNo (SelectDescendents) _ _ moves = False
nodeSelected_ ruleNo (SelectByType t) _ lui moves = fromMaybe False
(fmap (\n -> nodeType_ ruleNo n === t) (selectNode_ ruleNo True fst (lui,moves)))
$ selectNode_ ruleNo True fst (lui,moves)
>>= \node -> return $ nodeType_ ruleNo node === t
nodeSelected_ ruleNo (SelectByHasAttribute k) _ lui moves = fromMaybe False
(fmap (\n -> isJust ('DM'.get k (nodeAttributes_ ruleNo n))) (selectNode_ ruleNo True fst (lui,moves)))
$ selectNode_ ruleNo True fst (lui,moves)
>>= \node -> 'DM'.get k (nodeAttributes_ ruleNo node)
>>= \_ -> return True
nodeSelected_ ruleNo (SelectByAttribute k p) _ lui moves = fromMaybe False
(fmap (\n -> maybe False p ('DM'.get k (nodeAttributes_ ruleNo n))) (selectNode_ ruleNo True fst (lui,moves)))
nodeSelected_ ruleNo (SelectByClass c) _ lui moves = fromMaybe False
(fmap (\n -> maybe False (hasClass c) ('DM'.get "class" (nodeAttributes_ ruleNo n))) (selectNode_ ruleNo True fst (lui,moves)))
$ selectNode_ ruleNo True fst (lui,moves)
>>= \node -> 'DM'.get k (nodeAttributes_ ruleNo node)
>>= \value -> return (p value)
nodeSelected_ ruleNo (SelectByClass c) path lui moves
= nodeSelected_ ruleNo (SelectByAttribute "class" (hasClass c)) path lui moves
where
hasClass name (JSONArray items) = isMember name [item \\ JSONString item <- items]
hasClass _ _ = False
......@@ -1108,10 +1114,9 @@ where
= Just (ChangeChild change)
| otherwise
= Nothing
import Debug.Trace
extractAttributeChanges :: !UIAttributes !LUIChanges !LUIEffects -> [UIAttributeChange]
extractAttributeChanges attr changes=:{setAttributes,delAttributes} effects=:{overwrittenAttributes,hiddenAttributes}
# attr = trace_stdout attr
//Apply changes to the attributes
# changes = foldl (applySetAttribute overwrittenAttributes hiddenAttributes) [] ('DM'.toList setAttributes)
# changes = foldl (applyDelAttribute overwrittenAttributes hiddenAttributes) changes ('DS'.toList delAttributes)
......
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