Commit f3ddd5ee authored by Mart Lubbers's avatar Mart Lubbers

Merge branch '275-interactview-does-not-handle-edit-events' into 'master'

Resolve "interactView does not handle edit events"

Closes #275

See merge request !241
parents e68cf17f 499a0e7b
Pipeline #20766 passed with stage
in 5 minutes and 37 seconds
......@@ -84,7 +84,7 @@ filterTestsByName pattern tests = filter (\{UnitTest|name} -> indexOf pattern na
//UTILITY TASKS
testEditor :: (Editor a) (EditMode a) -> Task a | iTask a
testEditor editor mode
= (interact "Editor test" unitShare {onInit = const ((),mode), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \_ l (Just v) -> (l,v,Nothing)} editor @ snd
= (interactR "Editor test" unitShare {onInit = const ((),mode), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \_ l (Just v) -> (l,v,Nothing)} editor @ snd
>&> viewSharedInformation "Editor value" [ViewAs (toString o toJSON)] @? tvFromMaybe
) <<@ ApplyLayout (setUIAttributes (directionAttr Horizontal) )
......@@ -93,7 +93,7 @@ testEditorWithShare editor model viewMode = (withShared model
\smodel ->
updateSharedInformation "Edit the shared source" [] smodel
||-
interact "Editor under test" smodel {onInit = \r -> ((),if viewMode View Update $ r)
interactR "Editor under test" smodel {onInit = \r -> ((),if viewMode View Update $ r)
,onEdit = \v l _ -> (l,v,Just (\_ -> v))
,onRefresh = \r l v -> (l,r,Nothing)} editor @ snd
) <<@ ApplyLayout (setUIAttributes (directionAttr Horizontal))
......
......@@ -85,18 +85,17 @@ instance toString OSException
/**
* Core interaction task. All other interaction tasks are derived from this one.
* There are two almost identical versions:
* The `interactRW` version can update the given sds.
* The `interactR` version only reads, which means it can also be used for sds's that are not writable.
*/
:: EditInteractionHandlers l r w v =
:: InteractionHandlers l r w v =
{ onInit :: !(r -> (!l, !EditMode v))
, onEdit :: !(v l (Maybe v) -> (!l, !v, !Maybe (r -> w)))
, onRefresh :: !(r l (Maybe v) -> (!l, !v, !Maybe (r -> w)))
}
interact :: !d !(sds () r w) (EditInteractionHandlers l r w v) (Editor v) -> Task (l,v) | toPrompt d & iTask l & iTask r & iTask v & TC r & TC w & RWShared sds
:: ViewInteractionHandlers l r w v =
{ onInitView :: !(r -> (!l, !EditMode v))
, onRefreshView :: !(r l (Maybe v) -> (!l, !v, !Maybe (r -> w)))
}
interactView :: !d (sds () r w) (ViewInteractionHandlers l r w v) (Editor v) -> Task (l,v) | toPrompt d & iTask l & iTask r & iTask v & TC r & TC w & Registrable sds
//Version which can write shared data
interactRW :: !d !(sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task (l,v) | toPrompt d & iTask l & iTask r & iTask v & TC r & TC w & RWShared sds
//Version which does not write shared data
interactR :: !d (sds () r w) (InteractionHandlers l r w v) (Editor v) -> Task (l,v) | toPrompt d & iTask l & iTask r & iTask v & TC r & TC w & Registrable sds
This diff is collapsed.
......@@ -23,38 +23,38 @@ derive class iTask ChoiceText, ChoiceGrid, ChoiceRow, ChoiceNode
enterInformation :: !d ![EnterOption m] -> Task m | toPrompt d & iTask m
enterInformation d [EnterAs fromf:_]
= interact d unitShare {onInit = const ((), Enter), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l _ -> (l,undef,Nothing)} gEditor{|*|} @ (\((),v) -> fromf v)
= interactRW d unitShare {onInit = const ((), Enter), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l _ -> (l,undef,Nothing)} gEditor{|*|} @ (\((),v) -> fromf v)
enterInformation d opts=:[EnterUsing fromf editor:_]
= interact d unitShare {onInit = const ((), Enter), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l _ -> (l,undef,Nothing)} editor @ (\((),v) -> fromf v)
= interactRW d unitShare {onInit = const ((), Enter), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l _ -> (l,undef,Nothing)} editor @ (\((),v) -> fromf v)
enterInformation d _ = enterInformation d [EnterAs id]
updateInformation :: !d ![UpdateOption m m] m -> Task m | toPrompt d & iTask m
updateInformation d [UpdateAs tof fromf:_] m
= interact d unitShare {onInit = const ((), Update $ tof m), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l (Just v) -> (l,v,Nothing)}
= interactRW d unitShare {onInit = const ((), Update $ tof m), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l (Just v) -> (l,v,Nothing)}
gEditor{|*|} @ (\((),v) -> fromf m v)
updateInformation d [UpdateUsing tof fromf editor:_] m
= interact d unitShare {onInit = const ((), Update $ tof m), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l (Just v) -> (l,v,Nothing)}
= interactRW d unitShare {onInit = const ((), Update $ tof m), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l (Just v) -> (l,v,Nothing)}
editor @ (\((),v) -> fromf m v)
updateInformation d _ m = updateInformation d [UpdateAs (\l -> l) (\_ v -> v)] m
viewInformation :: !d ![ViewOption m] !m -> Task m | toPrompt d & iTask m
viewInformation d [ViewAs tof:_] m
= interact d unitShare {onInit = const ((),View $ tof m), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l (Just v) -> (l,v,Nothing)} gEditor{|*|} @! m
= interactRW d unitShare {onInit = const ((),View $ tof m), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l (Just v) -> (l,v,Nothing)} gEditor{|*|} @! m
viewInformation d [ViewUsing tof editor:_] m
= interact d unitShare {onInit = const ((), View $ tof m), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l (Just v) -> (l,v,Nothing)} editor @! m
= interactRW d unitShare {onInit = const ((), View $ tof m), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r l (Just v) -> (l,v,Nothing)} editor @! m
viewInformation d _ m = viewInformation d [ViewAs id] m
updateSharedInformation :: !d ![UpdateOption r w] !(sds () r w) -> Task r | toPrompt d & iTask r & iTask w & RWShared sds
updateSharedInformation d [UpdateAs tof fromf:_] shared
= interact d shared {onInit = \r -> (r, Update $ tof r), onEdit = \v l _ -> (l,v,Just (\r -> fromf r v)), onRefresh = \r _ _ -> (r,tof r,Nothing)}
= interactRW d shared {onInit = \r -> (r, Update $ tof r), onEdit = \v l _ -> (l,v,Just (\r -> fromf r v)), onRefresh = \r _ _ -> (r,tof r,Nothing)}
gEditor{|*|} @ fst
updateSharedInformation d [UpdateUsing tof fromf editor:_] shared
= interact d shared {onInit = \r -> (r, Update $ tof r), onEdit = \v l _ -> (l,v,Just (\r -> fromf r v)), onRefresh = \r _ _ -> (r,tof r,Nothing)}
= interactRW d shared {onInit = \r -> (r, Update $ tof r), onEdit = \v l _ -> (l,v,Just (\r -> fromf r v)), onRefresh = \r _ _ -> (r,tof r,Nothing)}
editor @ fst
updateSharedInformation d [UpdateSharedAs tof fromf conflictf:_] shared
= interact d shared {onInit = \r -> (r, Update $ tof r), onEdit = \v l _ -> (l,v,Just (\r -> fromf r v)), onRefresh = \r _ (Just v) -> (r,conflictf (tof r) v, Nothing)}
= interactRW d shared {onInit = \r -> (r, Update $ tof r), onEdit = \v l _ -> (l,v,Just (\r -> fromf r v)), onRefresh = \r _ (Just v) -> (r,conflictf (tof r) v, Nothing)}
gEditor{|*|} @ fst
updateSharedInformation d _ shared
......@@ -66,22 +66,22 @@ updateSharedInformation d _ shared
viewSharedInformation :: !d ![ViewOption r] !(sds () r w) -> Task r | toPrompt d & iTask r & TC w & Registrable sds
viewSharedInformation d [ViewAs tof:_] shared
= interactView d shared {onInitView = \r -> (r, View $ tof r), onRefreshView = \r _ _ -> (r,tof r,Nothing)} gEditor{|*|} @ fst
= interactR d shared {onInit = \r -> (r, View $ tof r), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r _ _ -> (r,tof r,Nothing)} gEditor{|*|} @ fst
viewSharedInformation d [ViewUsing tof editor:_] shared
= interactView d shared {onInitView = \r -> (r, View $ tof r), onRefreshView = \r _ _ -> (r,tof r,Nothing)} editor @ fst
= interactR d shared {onInit = \r -> (r, View $ tof r), onEdit = \v l _ -> (l,v,Nothing), onRefresh = \r _ _ -> (r,tof r,Nothing)} editor @ fst
viewSharedInformation d _ shared = viewSharedInformation d [ViewAs id] shared
updateInformationWithShared :: !d ![UpdateOption (r,m) m] !(sds () r w) m -> Task m | toPrompt d & iTask r & iTask m & TC w & RWShared sds
updateInformationWithShared d [UpdateAs tof fromf:_] shared m
= interact d shared
= interactRW d shared
{onInit = \r -> ((r,m), Update $ tof (r,m))
,onEdit = \v (r,m) _ -> let nm = fromf (r,m) v in ((r,nm),v,Nothing)
,onRefresh = \r (_,m) _ -> ((r,m),tof (r,m),Nothing)
} gEditor{|*|} @ (snd o fst)
updateInformationWithShared d [UpdateUsing tof fromf editor:_] shared m
= interact d shared
= interactRW d shared
{onInit = \r -> ((r,m),Update $ tof (r,m))
,onEdit = \v (r,m) _ -> let nm = fromf (r,m) v in ((r,nm),v,Nothing)
,onRefresh = \r (_,m) _ -> ((r,m),tof (r,m),Nothing)
......@@ -97,7 +97,7 @@ editSelection d multi (SelectInList toView fromView) container sel = editSelecti
editSelection d multi (SelectInGrid toView fromView) container sel = editSelection` d (grid <<@ multipleAttr multi) toView fromView container sel
editSelection d multi (SelectInTree toView fromView) container sel = editSelection` d (tree <<@ multipleAttr multi) toView fromView container sel
editSelection` d editor toView fromView container sel
= interact d unitShare
= interactRW d unitShare
{onInit = \r -> ((), Update (toView container,sel))
,onEdit = \v l _ -> (l,v,Nothing)
,onRefresh = \_ l (Just v) -> (l,v,Nothing)
......@@ -110,7 +110,7 @@ editSelectionWithShared d multi (SelectInList toView fromView) sharedContainer i
editSelectionWithShared d multi (SelectInGrid toView fromView) sharedContainer initSel = editSelectionWithShared` d (grid <<@ multipleAttr multi) toView fromView sharedContainer initSel
editSelectionWithShared d multi (SelectInTree toView fromView) sharedContainer initSel = editSelectionWithShared` d (tree <<@ multipleAttr multi) toView fromView sharedContainer initSel
editSelectionWithShared` d editor toView fromView sharedContainer initSel
= interact d sharedContainer
= interactRW d sharedContainer
{onInit = \r -> (r, Update(toView r, initSel r))
,onEdit = \v l _ -> (l,v,Nothing)
,onRefresh = \r l (Just (v,sel)) -> (r,(toView r,sel),Nothing)
......@@ -123,7 +123,7 @@ editSharedSelection d multi (SelectInList toView fromView) container sharedSel =
editSharedSelection d multi (SelectInGrid toView fromView) container sharedSel = editSharedSelection` d (grid <<@ multipleAttr multi) toView fromView container sharedSel
editSharedSelection d multi (SelectInTree toView fromView) container sharedSel = editSharedSelection` d (tree <<@ multipleAttr multi) toView fromView container sharedSel
editSharedSelection` d editor toView fromView container sharedSel
= interact d sharedSel
= interactRW d sharedSel
{onInit = \r -> ((), Update (toView container,r))
,onEdit = \(vt,vs) l _ -> (l,(vt,vs),Just (const vs))
,onRefresh = \r l (Just (vt,vs)) -> (l,(vt,r),Nothing)
......@@ -141,7 +141,7 @@ editSharedSelectionWithShared d multi (SelectInGrid toView fromView) sharedConta
editSharedSelectionWithShared d multi (SelectInTree toView fromView) sharedContainer sharedSel
= editSharedSelectionWithShared` d (tree <<@ multipleAttr multi) toView fromView sharedContainer sharedSel
editSharedSelectionWithShared` d editor toView fromView sharedContainer sharedSel
= interact d (sharedContainer |*< sharedSel)
= interactRW d (sharedContainer |*< sharedSel)
{onInit = \(rc, rs) -> (rc, Update (toView rc,rs))
,onEdit = \v=:(_, vs) l _ -> (l, v, Just (const vs))
,onRefresh = \(rc, rs) _ _ -> (rc, (toView rc, rs), Nothing)
......
......@@ -17,7 +17,7 @@ expPromptUI msg
minimalInteractUI = skip (testTaskOutput "Initial UI of minimal interaction task" task events exp checkEqual)
where
task :: Task ((),String)
task = interact "TEST" unitShare handlers gEditor{|*|}
task = interactR "TEST" unitShare handlers gEditor{|*|}
handlers = {onInit = \() -> ((),Update "Hello world"), onEdit = \_ l v -> (l,fromJust v,Nothing), onRefresh = \_ l v -> (l,fromJust v,Nothing)}
events = [Left ResetEvent]
......
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