Commit e7b12182 authored by Bas Lijnse's avatar Bas Lijnse

Improved unwrapUI rule for composite cases

parent 20e8b1ae
......@@ -191,7 +191,7 @@ applyUpstreamChange :: UIChange (LUI,LUIMoves) -> (LUI,LUIMoves)
extractDownstreamChange :: (LUI,LUIMoves) -> (!UIChange,!(LUI,LUIMoves))
extractUIWithEffects :: (LUI,LUIMoves) -> (!UI,!(LUI,LUIMoves))
extractUIWithEffects :: (LUI,LUIMoves) -> (!Maybe UI,!(LUI,LUIMoves))
//Helper functions (exported for unit testing)
scanToPosition_ :: LUINo Int [LUI] LUIMoves -> (Int,Bool,Maybe LUI)
......
This diff is collapsed.
......@@ -20,10 +20,10 @@ layoutCombinatorContainers = sequenceLayouts
]
layoutStep = sequenceLayouts
[layoutSubUIs SelectNestedStep removeDisabledActions
[layoutSubUIs (SelectAND SelectDescendents (SelectByType UIStep)) layoutStep
,layoutSubUIs SelectNestedStep removeDisabledActions
,layoutSubUIs (SelectAND NotYetTransformed HasActions) layoutWithActions
,layoutSubUIs NotYetTransformed layoutWithoutActions
,layoutSubUIs (SelectAND SelectDescendents (SelectByType UIStep)) layoutStep
]
where
SelectNestedStep =
......@@ -47,13 +47,10 @@ where
NotYetTransformed = SelectAND (SelectByPath []) (SelectByType UIStep)
HasActions = SelectByContains (SelectAND SelectChildren (SelectByType UIAction))
layoutWithoutActions = setUIType UIContainer
/* TODO: Unwrap first needs to work
layoutWithoutActions = sequenceLayouts
[copySubUIAttributes SelectAll [] [0]
,unwrapUI
]
*/
layoutWithActions = sequenceLayouts
[setUIType UIPanel
,addButtonBar
......
......@@ -7,7 +7,7 @@ import iTasks.UI.Layout
import iTasks.Internal.TaskState
import iTasks.Internal.TaskEval
import Text.GenJSON, StdString
import Data.Maybe, Text.GenJSON, StdString
import qualified Data.Map as DM
//This type records the states of layouts applied somewhere in a ui tree
......@@ -45,7 +45,8 @@ applyLayout rule task=:(Task evala) = Task eval
//On Reset events, we (re-)apply the layout
eval ResetEvent evalOpts (TCLayout _ tt) iworld = case evala ResetEvent evalOpts tt iworld of
(ValueResult value info (ReplaceUI ui) tt,iworld)
# (ui,state) = extractUIWithEffects (rule ruleNo (initLUI ui, initLUIMoves))
# (mbUI,state) = extractUIWithEffects (rule ruleNo (initLUI ui, initLUIMoves))
# ui = fromMaybe (UI UIEmpty 'DM'.newMap []) mbUI
//| not (trace_tn ("STATE AFTER RESET: \n"+++toString (toJSON state))) = undef
= (ValueResult value info (ReplaceUI ui) (TCLayout (toJSON state) tt), iworld)
(res,iworld) = (res,iworld)
......
......@@ -148,4 +148,5 @@ where
ref ui = applyLayoutRule layout2 (applyLayoutRule layout1 ui)
applyLayoutRule :: LayoutRule UI -> UI
applyLayoutRule rule ui = fst (extractUIWithEffects (rule (LUINo [0]) (initLUI ui,initLUIMoves)))
applyLayoutRule rule ui = fromMaybe (UI UIEmpty 'DM'.newMap [])
(fst (extractUIWithEffects (rule (LUINo [0]) (initLUI ui,initLUIMoves))))
......@@ -192,7 +192,7 @@ applyUpstreamChangeTests =
(applyUpstreamChange (ChangeUI [] [(0,MoveChild 2)
,(2,RemoveChild)
]) (lui00,initLUIMoves))
,assertEqual "Set attribute on wrapped child"
,assertEqual "Set attribute on a wrapped child"
(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUINode UIInteract 'DM'.newMap [] noChanges noEffects
,LUINode UIStep 'DM'.newMap
......@@ -208,6 +208,22 @@ applyUpstreamChangeTests =
] noChanges {noEffects & wrapper = ESApplied (LUINo [0])}
] noChanges noEffects, initLUIMoves)
)
,assertEqual "Set attribute on an unwrapped child"
(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUINode UIInteract 'DM'.newMap [] noChanges noEffects
,LUINode UIStep 'DM'.newMap
[LUINode UIDebug 'DM'.newMap [] noChanges noEffects
] {noChanges & setAttributes = 'DM'.fromList [("title",JSONString "changed-title")]} {noEffects & unwrapped = ESApplied (LUINo [0])}
] noChanges noEffects
,initLUIMoves)
(applyUpstreamChange (ChangeUI [] [(1,ChangeChild (ChangeUI [SetAttribute "title" (JSONString "changed-title")] []))])
(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUINode UIInteract 'DM'.newMap [] noChanges noEffects
,LUINode UIStep 'DM'.newMap
[LUINode UIDebug 'DM'.newMap [] noChanges noEffects
] noChanges {noEffects & unwrapped = ESApplied (LUINo [0])}
] noChanges noEffects, initLUIMoves)
)
,assertEqual "Set attribute in moved child"
(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUIMoveSource 1
......@@ -935,12 +951,12 @@ extractDownstreamChangeTest_MovingIntoAdditionalContainer =
extractUIWithEffectsTests =
[assertEqual "Extract UI with newly moved items"
(UI UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
(Just (UI UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[UI UIStep 'DM'.newMap
[UI UIInteract 'DM'.newMap []
,UI UIParallel 'DM'.newMap []
]
]
])
,(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUIMoveSource 1
,LUINode UIStep 'DM'.newMap [LUIMoveDestination 1 (LUINo [0]),LUIMoveDestination 2 (LUINo [0])] noChanges noEffects
......@@ -962,12 +978,12 @@ extractUIWithEffectsTests =
,(2,LUINode UIParallel 'DM'.newMap [] noChanges {LUIEffects|noEffects & moved = ESApplied (LUINo [0])})
]))
,assertEqual "Extract UI with updated moved items"
(UI UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
(Just (UI UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[UI UIParallel 'DM'.newMap []
,UI UIStep 'DM'.newMap
[UI UIInteract 'DM'.newMap []
]
]
])
,(LUINode UIPanel ('DM'.fromList [("title",JSONString "Parent panel")])
[LUIMoveSource 1
,LUIMoveDestination 2 (LUINo [1])
......@@ -991,7 +1007,7 @@ extractUIWithEffectsTests =
,(2,LUINode UIParallel 'DM'.newMap [] noChanges {LUIEffects|noEffects & moved = ESToBeUpdated (LUINo [0]) (LUINo [1])})
]))
,assertEqual "Extract UI with new wrapped"
(UI UIContainer 'DM'.newMap [UI UIStep 'DM'.newMap []]
(Just (UI UIContainer 'DM'.newMap [UI UIStep 'DM'.newMap []])
,(LUINode UIContainer 'DM'.newMap
[LUINode UIStep 'DM'.newMap [] noChanges noEffects
] noChanges {noEffects & wrapper = ESApplied (LUINo [2])}
......
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