Commit 28023ea7 authored by Steffen Michels's avatar Steffen Michels

make it possible to not update the view at all after onRefresh/confict...

make it possible to not update the view at all after onRefresh/confict resolution of interaction tasks
parent 7199cfcd
Pipeline #29897 passed with stage
in 4 minutes and 36 seconds
......@@ -670,7 +670,7 @@ updateActionStatus current = withShared current
-|| (Hint "Incidents:" @>> updateSharedIncidentRefList True (incidents updating))
) <<@ (Title "Update action")
where
updateMeta status = updateSharedInformation [UpdateSharedAs toPrj fromPrj const] status
updateMeta status = updateSharedInformation [UpdateSharedAs toPrj fromPrj (const o Just)] status
where
toPrj {ActionStatus|title,description} = {ItemMeta|title=title,description=description}
fromPrj status {ItemMeta|title,description} = {ActionStatus|status & title=title,description=description}
......
......@@ -30,7 +30,7 @@ where
= get (standardMapLayers |*| standardPerspective)
>>- \(baseLayers,perspective) ->
withShared perspective
\p -> Title title @>> updateSharedInformation [UpdateSharedAs (toMap baseLayers) fromMap const] (p >*| mapContacts) @ fst
\p -> Title title @>> updateSharedInformation [UpdateSharedAs (toMap baseLayers) fromMap (const o Just)] (p >*| mapContacts) @ fst
//<<@ AfterLayout (tweakUI fill) //FIXME
@ WallOverview
where
......
......@@ -55,7 +55,7 @@ where
refs = sdsFocus contactNo crewAliasListsStore
manageCurrentItems
= Hint "Manage crew list" @>> updateSharedInformation [UpdateSharedAs toPrj fromPrj const] items
= Hint "Manage crew list" @>> updateSharedInformation [UpdateSharedAs toPrj fromPrj (const o Just)] items
where
items = sdsDeref refs snd contactsByNosShort derefAliasList
toPrj l = [(contactIdentity c, aNo, contactTitle c)\\(aNo,c) <-l]
......
......@@ -397,9 +397,9 @@ updateContactPosition contactNo
>>- \({Contact|name,type,position},baseLayers) ->
withShared (position,initPerspective position)
\tmpInfo ->
(Title "Position update" @>> Hint ("Update position of contact "<+++ name) @>> updateSharedInformation [UpdateSharedAs fst (\(_,y) x -> (x,y)) const] tmpInfo
(Title "Position update" @>> Hint ("Update position of contact "<+++ name) @>> updateSharedInformation [UpdateSharedAs fst (\(_,y) x -> (x,y)) (const o Just)] tmpInfo
-||-
updateSharedInformation [UpdateSharedAs (toMap baseLayers) (fromMap baseLayers) const] tmpInfo
updateSharedInformation [UpdateSharedAs (toMap baseLayers) (fromMap baseLayers) (const o Just)] tmpInfo
-||-
(Hint "Search the web" @>> viewSharedInformation [ViewAs (toSearchURLs o fst)] tmpInfo)
) @ fst
......@@ -446,7 +446,7 @@ updateSharedContactRefList refs
>^* [OnAction (Action "Add") (always (addItem <<@ InWindow))]
where
manageCurrentItems
= updateSharedInformation [UpdateSharedAs toPrj fromPrj const] items @ map contactIdentity
= updateSharedInformation [UpdateSharedAs toPrj fromPrj (const o Just)] items @ map contactIdentity
where
items = sdsDeref refs id contactsByNosShort (\_ cs -> cs)
toPrj l = [(contactIdentity c,contactTitle c) \\ c <-l]
......@@ -564,9 +564,9 @@ viewContactsOnMap sharedContacts sel
>>- \(baseLayers,perspective) ->
withShared (False,perspective)
\localState ->
Hint "Show AIS contacts:" @>> updateSharedInformation [UpdateSharedAs fst (\(_,y) x -> (x,y)) const] localState
Hint "Show AIS contacts:" @>> updateSharedInformation [UpdateSharedAs fst (\(_,y) x -> (x,y)) (const o Just)] localState
||-
(updateSharedInformation [UpdateSharedAs (toPrj baseLayers) fromPrj const] (mapState localState sharedContacts sel)) @ (\(a,b,c) -> (b,c))
(updateSharedInformation [UpdateSharedAs (toPrj baseLayers) fromPrj (const o Just)] (mapState localState sharedContacts sel)) @ (\(a,b,c) -> (b,c))
>^* [OnAction (Action "/Share map to wall") (hasValue sharePerspective)
]
@? selection
......
......@@ -172,7 +172,7 @@ updateSharedIncidentRefList compact refs
>^* [OnAction (Action "Add") (always (addItem <<@ InWindow))]
where
manageCurrentItems
= updateSharedInformation [UpdateSharedAs toPrj fromPrj const] items @ map incidentIdentity
= updateSharedInformation [UpdateSharedAs toPrj fromPrj (const o Just)] items @ map incidentIdentity
where
items = sdsDeref refs id incidentsByNosShort (\_ is -> is)
toPrj l = [(incidentIdentity i,incidentTitle i) \\i <-l]
......
......@@ -229,7 +229,7 @@ configureMaps
where
previewMapLayers :: Task ContactMapPerspective
previewMapLayers = withShared defaultValue
\perspective -> (Title "Preview" @>> updateSharedInformation [UpdateSharedAs toPrj fromPrj const] (perspective >*| standardMapLayers)) <<@ ApplyLayout flexMap @ fst
\perspective -> (Title "Preview" @>> updateSharedInformation [UpdateSharedAs toPrj fromPrj (const o Just)] (perspective >*| standardMapLayers)) <<@ ApplyLayout flexMap @ fst
where
toPrj (perspective,layers) = toLeafletMap {ContactMap|defaultValue & perspective=perspective,layers=layers}
fromPrj _ {LeafletMap|perspective} = fromLeafletPerspective perspective
......
......@@ -62,7 +62,7 @@ actorWithInstructions user
pickStartRoom :: Task Coord3D
pickStartRoom
= Hint "Which room do you want to start in?" @>> updateInformationWithShared
[UpdateSharedUsing id (const snd) const editor]
[UpdateSharedUsing id (const snd) (const o Just) editor]
(maps2DShare |*| myNetwork) NoAction
>>* [OnValue (\v -> case v of
Value (FocusOnSection c3d) _ = Just (return c3d)
......@@ -387,7 +387,7 @@ mkSection :: MyDrawMapForActor
mkSection
= \user shStatusMap shUserActor shSectionInventoryMap ->
Title "Section Status" @>> updateSharedInformation
[UpdateSharedUsing id (\_ _ -> ()) const editor]
[UpdateSharedUsing id (\_ _ -> ()) (const o Just) editor]
(sectionForUserShare user |*| myNetwork |*| myDevices |*| shStatusMap |*| sectionUsersShare |*| myUserActorMap |*| shSectionInventoryMap |*| lockedExitsShare |*| lockedHopsShare |*| maps2DShare)
@! ()
where
......
......@@ -184,7 +184,7 @@ intMapCrudWith descr cos eos vos uos mkId share = Title descr @>> crudWith cos e
graphicalMapEditor :: Task ()
graphicalMapEditor
= Title "Graphical map editor" @>> updateSharedInformation
[UpdateSharedUsing id (const fst) const imageEditor]
[UpdateSharedUsing id (const fst) (const o Just) imageEditor]
(sharedEditShip >*| (myInventoryMap |*| myNetwork |*| myDevices)) @! ()
@! ()
where
......@@ -199,8 +199,8 @@ where
editLayout :: Task ()
editLayout
= allTasks [ graphicalMapEditor
, Title "Edit map dimensions" @>> updateSharedInformation [UpdateSharedAs toMapsForm fromMapsForm const] maps2DShare @! ()
, Title "Edit map" @>> updateSharedInformation [UpdateSharedAs toMapActionForm fromMapActionForm const] sharedEditShip @! ()
, Title "Edit map dimensions" @>> updateSharedInformation [UpdateSharedAs toMapsForm fromMapsForm (const o Just)] maps2DShare @! ()
, Title "Edit map" @>> updateSharedInformation [UpdateSharedAs toMapActionForm fromMapActionForm (const o Just)] sharedEditShip @! ()
, (watch maps2DShare
-&&- (Title "Quick borders" @>> enterChoiceWithShared [] (mapRead (\ship -> [mapId \\ {Map2D | mapId} <- ship]) maps2DShare))
>>* [ OnAction (Action "Add outer borders" ) (hasValue (uncurry (editOuterBorders Wall)))
......@@ -249,7 +249,7 @@ editSectionContents :: Task ()
editSectionContents
= allTasks [ graphicalMapEditor
, withSelectedSection (
\mid c2d -> (Title (mkDesc mid c2d "Inventory")) @>> updateSharedInformation [UpdateSharedAs fromInv toInv const] (sdsFocus (mid, c2d) inventoryInSectionShare)
\mid c2d -> (Title (mkDesc mid c2d "Inventory")) @>> updateSharedInformation [UpdateSharedAs fromInv toInv (const o Just)] (sdsFocus (mid, c2d) inventoryInSectionShare)
)
, withSelectedSection (
\mid c2d -> let focusedShare = sdsFocus (mid, c2d) devicesInSectionShare
......
......@@ -420,7 +420,7 @@ updateMapStatus mode
Value x _ -> Just x
_ -> Nothing) sharedMapAction */
(Title "Map Status" @>> updateInformationWithShared
[UpdateSharedUsing id (const snd) const editor]
[UpdateSharedUsing id (const snd) (const o Just) editor]
(disabledSections |*| maps2DShare |*| lockedExitsShare |*| lockedHopsShare |*| myInventoryMap |*| myStatusMap |*| sectionUsersShare |*| myUserActorMap |*| myNetwork |*| myDevices)
NoAction)
where
......@@ -437,7 +437,7 @@ disabledSections = sharedStore "disabledSections" 'DS'.newSet
updateSectionStatus :: !Coord3D -> Task (MapAction SectionStatus)
updateSectionStatus c3d=:(floorIdx, _)
= Title "Section Status" @>> updateInformationWithShared
[UpdateSharedUsing id (const snd) const editor]
[UpdateSharedUsing id (const snd) (const o Just) editor]
(maps2DShare |*| lockedExitsShare |*| lockedHopsShare |*| sdsFocus c3d inventoryInSectionShare |*| sdsFocus c3d statusInSectionShare |*| sdsFocus c3d (actorsInSectionShare myUserActorMap) |*| myNetwork |*| myDevices)
NoAction
where
......
......@@ -80,7 +80,7 @@ periodicallyUpdateEntity :: !Int -> Task ()
periodicallyUpdateEntity n = updateEntity n moveEntity // TODO FIXME PERFORMANCE doTaskPeriodically 1 (updateEntity n moveEntity) <<@ NoUserInterface
mapView` :: User [Entity] -> Task ()
mapView` currentUser es = (updateSharedInformation [UpdateSharedAs toMap fromMap const] (userMapState currentUser >*< entityMap) @! ())
mapView` currentUser es = (updateSharedInformation [UpdateSharedAs toMap fromMap (const o Just)] (userMapState currentUser >*< entityMap) @! ())
where
toMap :: (MapState, EntityMap) -> LeafletMap
toMap ({MapState | perspective}, markers)
......@@ -106,7 +106,7 @@ mapView` currentUser es = (updateSharedInformation [UpdateSharedAs toMap fromMap
mapView :: (sds () r w) (r -> Bool) User [Entity] -> Task () | iTask r & iTask w & RWShared sds
mapView sh radarWorks currentUser es = (updateSharedInformation [UpdateSharedAs toMap fromMap const] (mapState >*| sh) @! ())
mapView sh radarWorks currentUser es = (updateSharedInformation [UpdateSharedAs toMap fromMap (const o Just)] (mapState >*| sh) @! ())
where
toMap ({perspective, entities = markers}, shval)
= toLeafletMap { ContactMap
......
......@@ -23,5 +23,5 @@ where
>>= \result -> Hint "Result:" @>> viewInformation [] result
>>= return
noteEditor = UpdateSharedUsing id (const id) const textArea
listEditor = UpdateSharedAs (split "\n") (\_ l -> join "\n" l) const
noteEditor = UpdateSharedUsing id (const id) (const o Just) textArea
listEditor = UpdateSharedAs (split "\n") (\_ l -> join "\n" l) (const o Just)
......@@ -20,11 +20,10 @@ sharedNotes
(Hint "View on note" @>> viewSharedInformation [ViewUsing id textArea] note)
-||-
// an editor to update the shared string
((Hint "Update shared note 1" @>> updateSharedInformation [UpdateSharedUsing id (const id) const textArea] note)
((Hint "Update shared note 1" @>> updateSharedInformation [UpdateSharedUsing id (const id) (const o Just) textArea] note)
-||-
// and an other updating editor
(Hint "Update shared note 2" @>> updateSharedInformation [UpdateSharedUsing id (const id) const textArea] note)
(Hint "Update shared note 2" @>> updateSharedInformation [UpdateSharedUsing id (const id) (const o Just) textArea] note)
) <<@ ArrangeHorizontal
)
>>= \result -> Hint "Resulting string is:" @>> viewInformation [ViewUsing id textArea] result
......
......@@ -34,7 +34,7 @@ editWithStatistics
editFile :: String (Shared sds String) -> Task () | RWShared sds
editFile fileName sharedFile
= Hint ("edit " +++ fileName) @>> updateSharedInformation [UpdateSharedUsing id (const id) const textArea] sharedFile @! ()
= Hint ("edit " +++ fileName) @>> updateSharedInformation [UpdateSharedUsing id (const id) (const o Just) textArea] sharedFile @! ()
showStatistics :: (Shared sds String) -> Task () | RWShared sds
showStatistics sharedFile = Hint "Statistics:" @>> viewSharedInformation [ViewAs stat] sharedFile @! ()
......
......@@ -20,6 +20,6 @@ calculateSumInRecord
= withShared (0,0)
(\sum -> Title "Sum of 2 numbers, with view" @>> updateSharedInformation
[UpdateSharedAs (\(i,j) -> {firstNumber = i, secondNumber = j, sum = (i+j)})
(\_ res -> (res.firstNumber,res.secondNumber)) const] sum
(\_ res -> (res.firstNumber,res.secondNumber)) (const o Just)] sum
)
>>= \(i,j) -> return (i+j)
......@@ -14,7 +14,7 @@ playWithMaps = withShared ({defaultValue & icons = shipIcons},defaultValue) (\m
derive gDefault LeafletSimpleState, LeafletObjectID
manipulateMap :: (Shared sds (LeafletMap,LeafletSimpleState)) -> Task () | RWShared sds
manipulateMap m = updateSharedInformation [UpdateSharedUsing id (flip const) const (customLeafletEditor eventHandlers defaultValue)] m
manipulateMap m = updateSharedInformation [UpdateSharedUsing id (flip const) (const o Just) (customLeafletEditor eventHandlers defaultValue)] m
<<@ ApplyLayout (setUIAttributes (sizeAttr FlexSize FlexSize)) @! ()
where
eventHandlers = {simpleStateEventHandlers & onHtmlEvent = onHtmlEvent}
......
implementation module Ligretto.UI
import StdBool, StdEnum, StdList
from StdFunc import id, const
from StdFunc import id, const, o
import Data.GenEq
import iTasks.WF.Tasks.Interaction
import Graphics.Scalable.Extensions
......@@ -9,14 +9,14 @@ import iTasks.Extensions.SVG.SVGEditor
import Ligretto.UoD
ligrettoEditor :: !Color -> UpdateSharedOption GameSt GameSt
ligrettoEditor me = UpdateSharedUsing id (const id) const (fromSVGEditor
ligrettoEditor me = UpdateSharedUsing id (const id) (const o Just) (fromSVGEditor
{ initView = id
, renderImage = const (player_perspective me)
, updModel = const id
})
accoladesEditor :: !Color -> UpdateSharedOption GameSt GameSt
accoladesEditor me = UpdateSharedUsing id (const id) const (fromSVGEditor
accoladesEditor me = UpdateSharedUsing id (const id) (const o Just) (fromSVGEditor
{ initView = id
, renderImage = const (player_perspective me)
, updModel = const id
......
implementation module Trax.UI
import StdBool, StdList
from StdFunc import const, flip, id
from StdFunc import const, flip, id, o
from Data.List import lookup
import iTasks.WF.Tasks.Interaction
import iTasks.Extensions.SVG.SVGEditor
......@@ -10,7 +10,7 @@ import Trax.UoD
:: RenderMode = ViewMode | PlayMode
updateTraxEditor :: Bool -> UpdateSharedOption TraxSt TraxSt
updateTraxEditor turn = UpdateSharedUsing id (const id) const (fromSVGEditor
updateTraxEditor turn = UpdateSharedUsing id (const id) (const o Just) (fromSVGEditor
{ initView = id
, renderImage = \_ -> toImage PlayMode turn
, updModel = flip const
......
......@@ -83,7 +83,7 @@ filterTestsByName pattern tests = filter (\{UnitTest|name} -> indexOf pattern na
//UTILITY TASKS
testEditor :: (Editor a) (EditMode a) -> Task a | iTask a
testEditor editor mode
= (interactR unitShare {onInit = const ((),mode), onEdit = \v l -> (l,Nothing), onRefresh = \_ l (Just v) -> (l,v,Nothing)} editor @ snd
= (interactR unitShare {onInit = const ((),mode), onEdit = \v l -> (l,Nothing), onRefresh = \_ l v -> (l,v,Nothing)} editor @ snd
>&> \s -> Title "Editor value" @>> viewSharedInformation [ViewAs (toString o toJSON)] s @? tvFromMaybe
) <<@ ArrangeHorizontal
......@@ -94,7 +94,7 @@ testEditorWithShare editor model viewMode = (withShared model
||-
(Title "Editor under test" @>> interactR smodel {onInit = \r -> ((),if viewMode View Update $ r)
,onEdit = \v l -> (l,Just (\_ -> v))
,onRefresh = \r l v -> (l,r,Nothing)} editor @ snd)
,onRefresh = \r l _ -> (l,Just r,Nothing)} editor @ snd)
) <<@ ArrangeHorizontal
testCommonInteractions :: String -> Task a | iTask, gDefault{|*|} a
......
......@@ -76,7 +76,7 @@ instance toString OSException
:: InteractionHandlers l r w v =
{ onInit :: !(r -> (l, EditMode v))
, onEdit :: !(v l -> (l, Maybe (r -> w)))
, onRefresh :: !(r l (Maybe v) -> (l, v, Maybe (r -> w)))
, onRefresh :: !(r l (Maybe v) -> (l, Maybe v, Maybe (r -> w)))
}
//Version which can write shared data
......
......@@ -154,8 +154,12 @@ evalInteract l v mst mode sds handlers editor writefun event=:(RefreshEvent task
| 'DS'.member taskId taskIds
= readRegisterCompletely sds (maybe NoValue (\v->Value (l, v) False) v) (\e->mkUIIfReset e (asyncSDSLoaderUI Read))
(\r event evalOpts iworld
# (l, v, mbf) = handlers.InteractionHandlers.onRefresh r l v
= case withVSt taskId (editor.Editor.onRefresh [] v (fromJust mst)) iworld of
# (l, mbV, mbf) = handlers.InteractionHandlers.onRefresh r l v
# st = fromJust mst
# mbChange = case mbV of
Just v = withVSt taskId (editor.Editor.onRefresh [] v (fromJust mst)) iworld
Nothing = (Ok (NoChange, st), iworld)
= case mbChange of
(Error e, iworld) = (ExceptionResult (exception e), iworld)
(Ok (change, st), iworld)
# v = editor.Editor.valueFromState st
......
......@@ -25,11 +25,12 @@ from Data.Functor import class Functor
//When both the view has been edited, and the sds has changed, this
//function determines what the new view should be.
//The first argument is the new view as computed from the changed sds,
//and the second argument is the edited view by the user.
//and the second argument is the edited view by the user, if the current view represents a valid value.
//If the result is `Nothing` the view is not updated.
:: UpdateSharedOption a b
= E.v: UpdateSharedAs (a -> v) (a v -> b) (v (Maybe v) -> v) & iTask v
| E.v: UpdateSharedUsing (a -> v) (a v -> b) (v (Maybe v) -> v) (Editor v) & iTask v
| E.v: UpdateSharedUsingAuto (a -> Maybe v) (a v -> b) (v (Maybe v) -> v) (Editor v) & iTask v
= E.v: UpdateSharedAs (a -> v) (a v -> b) (v (Maybe v) -> Maybe v) & iTask v
| E.v: UpdateSharedUsing (a -> v) (a v -> b) (v (Maybe v) -> Maybe v) (Editor v) & iTask v
| E.v: UpdateSharedUsingAuto (a -> Maybe v) (a v -> b) (v (Maybe v) -> Maybe v) (Editor v) & iTask v
//Selection in arbitrary containers (explicit identification is needed)
:: SelectOption c s
......
......@@ -52,7 +52,7 @@ updateSharedEditor :: [UpdateSharedOption r w] -> UpdateSharedOption r w | iTask
updateSharedEditor [UpdateSharedUsing tof fromf conflictf editor:_] = UpdateSharedUsing tof fromf conflictf editor
updateSharedEditor [UpdateSharedAs tof fromf conflictf:_] = UpdateSharedUsing tof fromf conflictf gEditor{|*|}
updateSharedEditor [_:es] = updateSharedEditor es
updateSharedEditor [] = UpdateSharedUsingAuto dynid (flip const) const gEditor{|*|}
updateSharedEditor [] = UpdateSharedUsingAuto dynid (flip const) (const o Just) gEditor{|*|}
where
//If r == w then this is just the identity, otherwise the editor will use a default value
dynid x = case dynamic id :: A.a: (a -> a) of
......@@ -102,12 +102,12 @@ where
viewInformation :: ![ViewOption m] !m -> Task m | iTask m
viewInformation options m = viewInformation` (viewEditor options) m
viewInformation` (ViewUsing tof editor) m
= interactR unitShare {onInit = const ((),View $ tof m), onEdit = \_ l -> (l, Nothing), onRefresh = \r l (Just v) -> (l,v,Nothing)} editor @! m
= interactR unitShare {onInit = const ((),View $ tof m), onEdit = \_ l -> (l, Nothing), onRefresh = \r l v -> (l,v,Nothing)} editor @! m
updateInformation :: ![UpdateOption m] m -> Task m | iTask m
updateInformation options m = updateInformation` (updateEditor options) m
updateInformation` (UpdateUsing tof fromf editor) m
= interactRW unitShare {onInit = const ((), Update $ tof m), onEdit = \_ l -> (l, Nothing), onRefresh = \r l (Just v) -> (l,v,Nothing)}
= interactRW unitShare {onInit = const ((), Update $ tof m), onEdit = \_ l -> (l, Nothing), onRefresh = \r l v -> (l,v,Nothing)}
editor @ (\((),v) -> fromf m v)
updateSharedInformation :: ![UpdateSharedOption r w] !(sds () r w) -> Task r | iTask r & iTask w & RWShared sds
......@@ -117,13 +117,13 @@ updateSharedInformation` (UpdateSharedUsing tof fromf conflictf editor) sds
editor @ fst
updateSharedInformation` (UpdateSharedUsingAuto tof fromf conflictf editor) sds
= interactRW sds {onInit = \r -> (r, maybe Enter Update (tof r)), onEdit = \v l -> (l, Just (\r -> fromf r v))
, onRefresh = \r _ v -> (r, maybe undef (\r` -> conflictf r` v) (tof r), Nothing)}
, onRefresh = \r _ v -> (r, maybe Nothing (\r` -> conflictf r` v) (tof r), Nothing)}
editor @ fst
viewSharedInformation :: ![ViewOption r] !(sds () r w) -> Task r | iTask r & TC w & Registrable sds
viewSharedInformation options sds = viewSharedInformation` (viewEditor options) sds
viewSharedInformation` (ViewUsing tof editor) sds
= interactR sds {onInit = \r -> (r, View $ tof r), onEdit = \_ l -> (l, Nothing), onRefresh = \r _ _ -> (r,tof r,Nothing)} editor @ fst
= interactR sds {onInit = \r -> (r, View $ tof r), onEdit = \_ l -> (l, Nothing), onRefresh = \r _ _ -> (r,Just $ tof r,Nothing)} editor @ fst
updateInformationWithShared :: ![UpdateSharedOption (r,m) m] !(sds () r w) m -> Task m | iTask r & iTask m & TC w & RWShared sds
updateInformationWithShared options sds m = updateInformationWithShared` (updateSharedEditor options) sds m
......@@ -131,7 +131,7 @@ updateInformationWithShared` (UpdateSharedUsing tof fromf conflictf editor) sds
= interactRW sds
{onInit = \r -> ((r,m), Update $ tof (r,m))
,onEdit = \v (r,m) -> let nm = fromf (r,m) v in ((r,nm),Nothing)
,onRefresh = \r (_,m) _ -> ((r,m),tof (r,m),Nothing)
,onRefresh = \r (_,m) _ -> ((r,m),Just $ tof (r,m),Nothing)
} gEditor{|*|} @ (snd o fst)
editSelection :: ![SelectOption c a] c [Int] -> Task [a] | iTask a
......@@ -140,7 +140,7 @@ editSelection` attributes (SelectUsing toView fromView editor) container sel
= interactRW unitShare
{onInit = \r -> ((), Update (toView container,sel))
,onEdit = \_ l -> (l, Nothing)
,onRefresh = \_ l (Just v) -> (l,v,Nothing)
,onRefresh = \_ l v -> (l,v,Nothing)
} (attributes @>> editor) @ (\(_,(_,sel)) -> fromView container sel)
editSelectionWithShared :: ![SelectOption c a] (sds () c w) (c -> [Int]) -> Task [a] | iTask c & iTask a & TC w & RWShared sds
......@@ -149,7 +149,7 @@ editSelectionWithShared` attributes (SelectUsing toView fromView editor) sharedC
= interactRW sharedContainer
{onInit = \r -> (r, Update(toView r, initSel r))
,onEdit = \_ l -> (l, Nothing)
,onRefresh = \r l (Just (v,sel)) -> (r,(toView r,sel),Nothing)
,onRefresh = \r l v -> (r,(\(_, sel) -> (toView r,sel)) <$> v,Nothing)
} (attributes @>> editor) @ (\(container,(_,sel)) -> fromView container sel)
editSharedSelection :: ![SelectOption c a] c (Shared sds [Int]) -> Task [a] | iTask c & iTask a & RWShared sds
......@@ -158,7 +158,7 @@ editSharedSelection` attributes (SelectUsing toView fromView editor) container s
= interactRW sharedSel
{onInit = \r -> ((), Update (toView container,r))
,onEdit = \(_,vs) l -> (l, Just (const vs))
,onRefresh = \r l (Just (vt,vs)) -> (l,(vt,r),Nothing)
,onRefresh = \r l v -> (l,(\(vt, _) -> (vt, r)) <$> v,Nothing)
} (attributes @>> editor) @ (\(_,(_,sel)) -> fromView container sel)
editSharedSelectionWithShared :: ![SelectOption c a] (sds1 () c w) (Shared sds2 [Int]) -> Task [a] | iTask c & iTask a & TC w & RWShared sds1 & RWShared sds2
......@@ -168,7 +168,7 @@ editSharedSelectionWithShared` attributes (SelectUsing toView fromView editor) s
= interactRW (sharedContainer |*< sharedSel)
{onInit = \(rc, rs) -> (rc, Update (toView rc,rs))
,onEdit = \(_, vs) l -> (l, Just (const vs))
,onRefresh = \(rc, rs) _ _ -> (rc, (toView rc, rs), Nothing)
,onRefresh = \(rc, rs) _ _ -> (rc, Just (toView rc, rs), Nothing)
} (attributes @>> editor) @ (\(container, (_, sel)) -> fromView container sel)
//Core choice tasks
......
......@@ -18,8 +18,8 @@ editInTextArea model
editAsListOfLines model
= Title "Lines" @>> Hint "Edit lines" @>> updateSharedInformation [listEditor] model
noteEditor = UpdateSharedUsing id (const id) const textArea
listEditor = UpdateSharedAs (split "\n") (\_ l -> join "\n" l) const
noteEditor = UpdateSharedUsing id (const id) (const o Just) textArea
listEditor = UpdateSharedAs (split "\n") (\_ l -> join "\n" l) (const o Just)
toMaybe (Value v _) = (Just v)
toMaybe _ = Nothing
......
......@@ -11,7 +11,7 @@ minimalInteractUI = skip (testTaskOutput "Initial UI of minimal interaction task
where
task :: Task ((),String)
task = interactR unitShare handlers gEditor{|*|}
handlers = {onInit = \() -> ((),Update "Hello world"), onEdit = \_ l -> (l,Nothing), onRefresh = \_ l v -> (l,fromJust v,Nothing)}
handlers = {onInit = \() -> ((),Update "Hello world"), onEdit = \_ l -> (l,Nothing), onRefresh = \_ l v -> (l,v,Nothing)}
events = [Left ResetEvent]
exp = [TOUIChange (ReplaceUI expMinimalEditorUI)]
......
......@@ -209,7 +209,7 @@ where
= Title "Edit code" @>> updateSharedInformation
[UpdateSharedUsing (\{InspectState|lines} -> join OS_NEWLINE lines)
(\s c -> {InspectState|s & lines = split OS_NEWLINE c})
const
(const o Just)
aceTextArea] state
buildExecutable :: FilePath (Shared sds InspectState) -> Task () | RWShared sds
......
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