Commit 505da5b3 authored by Bas Lijnse's avatar Bas Lijnse

Updated API of core interaction task to re-enable edit handling

parent e204a6c4
......@@ -86,17 +86,15 @@ instance toString OSException
/**
* Core interaction task. All other interaction tasks are derived from this one.
*/
:: 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
//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
:: ViewInteractionHandlers l r w v =
{ onInitView :: !(r -> (!l, !EditMode v))
, onRefreshView :: !(r l (Maybe v) -> (!l, !v, !Maybe (r -> w)))
}
//Version which writes 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
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
......@@ -58,11 +58,11 @@ instance toString OSException
where
toString (OSException (_,err)) = "Error performing OS operation: " +++ err
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
interact prompt shared handlers editor
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
interactRW prompt shared handlers editor
= Task (eval prompt shared handlers editor)
where
eval :: !d (sds () r w) (EditInteractionHandlers l r w v) (Editor v) Event TaskEvalOpts TaskTree *IWorld -> *(TaskResult (l,v), *IWorld) | toPrompt d & iTask l & iTask r & iTask v & TC r & TC w & RWShared sds
eval :: !d (sds () r w) (InteractionHandlers l r w v) (Editor v) Event TaskEvalOpts TaskTree *IWorld -> *(TaskResult (l,v), *IWorld) | toPrompt d & iTask l & iTask r & iTask v & TC r & TC w & RWShared sds
eval _ _ _ _ event evalOpts tt=:(TCDestroy _) iworld
# iworld = 'SDS'.clearTaskSDSRegistrations ('DS'.singleton $ fromOk $ taskIdFromTaskTree tt) iworld
= (DestroyedResult, iworld)
......@@ -139,7 +139,7 @@ where
# (Left (taskId,ts,l,v,st,viewMode)) = fromOk mbd
# (mbRes, iworld) = case event of
EditEvent eTaskId name edit | eTaskId == taskId =
applyEditEvent_ name edit taskId editor taskTime shared handlers.EditInteractionHandlers.onEdit l v st iworld
applyEditEvent_ name edit taskId editor taskTime shared handlers.InteractionHandlers.onEdit l v st iworld
ResetEvent
# resetMode = case (viewMode, v) of
(True, Just v) = View v
......@@ -153,7 +153,7 @@ where
)
iworld
RefreshEvent taskIds _ | 'DS'.member taskId taskIds
= refreshView_ taskId editor shared handlers.EditInteractionHandlers.onRefresh l v st taskTime iworld
= refreshView_ taskId editor shared handlers.InteractionHandlers.onRefresh l v st taskTime iworld
FocusEvent fTaskId | fTaskId == taskId = (Ok (Left (l,editor.Editor.valueFromState st,NoChange,st,taskTime)),iworld)
_ = (Ok (Left (l,editor.Editor.valueFromState st,NoChange,st,ts)),iworld)
= case mbRes of
......@@ -173,11 +173,11 @@ where
# info = {TaskEvalInfo|lastEvent=ts,attributes='DM'.newMap,removedTasks=[]}
= (ValueResult value info change (TCInteract taskId ts (DeferredJSON l) (DeferredJSON v) st viewMode), iworld)
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
interactView prompt shared handlers editor
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
interactR prompt shared handlers editor
= Task (eval prompt shared handlers editor)
where
eval :: !d (sds () r w) (ViewInteractionHandlers l r w v) (Editor v) Event TaskEvalOpts TaskTree *IWorld -> *(TaskResult (l,v), *IWorld) | toPrompt d & iTask l & iTask r & iTask v & TC r & TC w & Registrable sds
eval :: !d (sds () r w) (InteractionHandlers l r w v) (Editor v) Event TaskEvalOpts TaskTree *IWorld -> *(TaskResult (l,v), *IWorld) | toPrompt d & iTask l & iTask r & iTask v & TC r & TC w & Registrable sds
eval _ _ _ _ event evalOpts tt=:(TCDestroy _) iworld
# iworld = 'SDS'.clearTaskSDSRegistrations ('DS'.singleton $ fromOk $ taskIdFromTaskTree tt) iworld
= (DestroyedResult, iworld)
......@@ -191,7 +191,7 @@ where
(Error e, iworld) = (ExceptionResult e, iworld)
(Ok (res :: AsyncRead r^ w^), iworld) = case res of
ReadingDone r
# (l, mode) = handlers.onInitView r
# (l, mode) = handlers.onInit r
# mbV = case mode of
Enter = Nothing
Update x = Just x
......@@ -214,7 +214,7 @@ where
(TCInit taskId ts)
= case 'SDS'.readRegister taskId shared iworld of
(Ok ('SDS'.ReadingDone r),iworld)
# (l, mode) = handlers.onInitView r
# (l, mode) = handlers.onInit r
# v = case mode of
Enter = Nothing
Update x = Just x
......@@ -248,7 +248,7 @@ where
)
iworld
RefreshEvent taskIds _ | 'DS'.member taskId taskIds
= refresh taskId editor shared handlers.ViewInteractionHandlers.onRefreshView l v st taskTime iworld
= refresh taskId editor shared handlers.InteractionHandlers.onRefresh l v st taskTime iworld
_ = (Ok (Left (l,editor.Editor.valueFromState st,NoChange,st,ts)),iworld)
= case mbRes of
Error e = (ExceptionResult e, iworld)
......
......@@ -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)
......
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