Commit 4242d0de authored by Bas Lijnse's avatar Bas Lijnse

Fixed bug in extractDownstreamChange that ignored unwrapped hidden nodes

parent f00df407
......@@ -1007,6 +1007,7 @@ where
existsDownstream_ (LUIMoveSource _) (LUINode _ _ _ _ {LUIEffects|moved=ESApplied _}) = False
existsDownstream_ (LUIMoveSource _) (LUINode _ _ _ _ {LUIEffects|moved=ESToBeUpdated _ _}) = False
existsDownstream_ (LUIMoveSource _) (LUINode _ _ _ _ {LUIEffects|moved=ESPartiallyUpdated _ _}) = False
existsDownstream_ ref (LUINode _ _ [i:_] _ {LUIEffects|unwrapped=ESApplied _}) = existsDownstream_ ref i
existsDownstream_ _ _ = True
determineInsert_ node current moves = case extractUIWithEffects (current,moves) of
......@@ -1167,34 +1168,6 @@ where
check [(hiddenKey,ESToBeUpdated _ _):_] | hiddenKey == key = True
check [_:xs] = check xs
/*
extractChildChanges :: [LUI] LUIMoves Bool -> ([(Int,UIChildChange)],[LUI],LUIMoves)
extractChildChanges [] moves unwrapped = ([],[],moves)
extractChildChanges items moves unwrapped
# (shifts,items) = extractChildShifts items
| unwrapped
| differentFirstChild items
# ([ui:_],items,moves) = extractChildUIsWithEffects items moves
= ([(0,ChangeChild (ReplaceUI ui))],items,moves)
| otherwise
# [i:is] = items
//Extract the changes of the first item, and just update the rest
# (change,(i,moves)) = extractDownstreamChange (i,moves)
# (_,is,moves) = extractChildUIsWithEffects is moves
= ([(0,ChangeChild change)],[i:is],moves)
| otherwise
# (shifts,items) = extractChildShifts items
# (insertsAndRemoves,items,moves) = extractChildInsertsAndRemoves items moves
= (shifts ++ insertsAndRemoves, items, moves)
where
//When the parent is unwrapped, we may need to update the ui if another child ends up at position 0
differentFirstChild [LUINode _ _ _ {toBeInserted=True} _:_]= True
differentFirstChild [LUINode _ _ _ {toBeRemoved=True} _:_]= True
differentFirstChild [LUINode _ _ _ {toBeShifted=Just _} _:_]= True
differentFirstChild [LUIShiftDestination _:_]= True
differentFirstChild items = False
*/
//Important: Shifts are done before inserts and removes
// so we ignore items that are not yet inserted, but still
// count items that are to be removed
......
......@@ -243,6 +243,23 @@ applyUpstreamChangeTests =
] noChanges noEffects
,'DM'.fromList [(1,LUINode UIInteract 'DM'.newMap [] noChanges {noEffects & moved = ESApplied (LUINo [0])})])
)
,assertEqual "Set attribute after removed child"
(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUINode UIEmpty 'DM'.newMap [] noChanges {noEffects & hidden = ESApplied (LUINo [0])}
,LUINode UIStep 'DM'.newMap
[LUINode UIDebug 'DM'.newMap [] noChanges noEffects
] {noChanges & setAttributes = 'DM'.fromList [("title",JSONString "changed-title")]} noEffects
] noChanges noEffects
,'DM'.newMap)
(applyUpstreamChange (ChangeUI [] [(1,ChangeChild (ChangeUI [SetAttribute "title" (JSONString "changed-title")] []))])
(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUINode UIEmpty 'DM'.newMap [] noChanges {noEffects & hidden = ESApplied (LUINo [0])}
,LUINode UIStep 'DM'.newMap
[LUINode UIDebug 'DM'.newMap [] noChanges noEffects
] noChanges noEffects
] noChanges noEffects
,'DM'.newMap)
)
]
//Check if pending downstream changes are correctly extracted from the tree
......@@ -277,6 +294,7 @@ extractDownstreamChangeTests =
,extractDownstreamChangeTest_NewUnwrappedChild
,extractDownstreamChangeTest_NoLongerUnwrappedChild
,extractDownstreamChangeTest_ChangingAnUnwrappedAttribute
,extractDownstreamChangeTest_ChangingAfterUnwrappedHiddenAttribute
,extractDownstreamChangeTest_InsertIntoUnwrappedContainer
,extractDownstreamChangeTest_RemovingUnwrappedContainer
,extractDownstreamChangeTest_ShiftingInUnwrappedContainer
......@@ -871,6 +889,28 @@ extractDownstreamChangeTest_ChangingAnUnwrappedAttribute =
] noChanges noEffects
,initLUIMoves))
extractDownstreamChangeTest_ChangingAfterUnwrappedHiddenAttribute =
assertEqual "Changing an attribute after an unwrapped hidden child"
(ChangeUI [] [(1,ChangeChild (ChangeUI [SetAttribute "title" (JSONString "test")] []))]
,(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUINode UIInteract 'DM'.newMap [] noChanges noEffects
,LUINode UIStep 'DM'.newMap
[ LUINode UIDebug 'DM'.newMap [] noChanges {noEffects & hidden = ESApplied (LUINo [1])}
] noChanges {noEffects & unwrapped = ESApplied (LUINo [0])}
,LUINode UIParallel ('DM'.fromList [("title",JSONString "test")]) [] noChanges noEffects
] noChanges noEffects
,initLUIMoves)
)
(extractDownstreamChange (
LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUINode UIInteract 'DM'.newMap [] noChanges noEffects
,LUINode UIStep 'DM'.newMap
[ LUINode UIDebug 'DM'.newMap [] noChanges {noEffects & hidden = ESApplied (LUINo [1])}
] noChanges {noEffects & unwrapped = ESApplied (LUINo [0])}
,LUINode UIParallel 'DM'.newMap [] {noChanges & setAttributes = 'DM'.fromList [("title",JSONString "test")]} noEffects
] noChanges noEffects
,initLUIMoves))
extractDownstreamChangeTest_InsertIntoUnwrappedContainer =
assertEqual "Inserting into an unwrapped container"
(ReplaceUI (UI UIDebug 'DM'.newMap [])
......
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