Implement reading from input.
This commit is contained in:
parent
844888b28c
commit
d3f34ac13c
|
@ -7,6 +7,7 @@ type alias Model =
|
||||||
{ rawHierarchy : RawCacheModelHierarchy
|
{ rawHierarchy : RawCacheModelHierarchy
|
||||||
, hierarchy : Maybe CacheHierarchy
|
, hierarchy : Maybe CacheHierarchy
|
||||||
, accessView : Maybe AccessView
|
, accessView : Maybe AccessView
|
||||||
|
, accessInput : String
|
||||||
}
|
}
|
||||||
type alias Flags = ()
|
type alias Flags = ()
|
||||||
type Msg
|
type Msg
|
||||||
|
@ -15,5 +16,6 @@ type Msg
|
||||||
| DeleteRawModel Int
|
| DeleteRawModel Int
|
||||||
| UseHierarchy (Maybe CacheModelHierarchy)
|
| UseHierarchy (Maybe CacheModelHierarchy)
|
||||||
| Access Int
|
| Access Int
|
||||||
|
| ChangeAccessInput String
|
||||||
| AccessViewForward
|
| AccessViewForward
|
||||||
| AccessViewBack
|
| AccessViewBack
|
||||||
|
|
|
@ -140,8 +140,18 @@ viewAccessView m av =
|
||||||
, viewCacheHierarchy <| effectiveCacheHierarchy currentCache av
|
, viewCacheHierarchy <| effectiveCacheHierarchy currentCache av
|
||||||
]
|
]
|
||||||
|
|
||||||
viewAccessInput : Html Msg
|
viewAccessInput : Model -> Html Msg
|
||||||
viewAccessInput = input [ type_ "button", onClick (Access 128), value "Access me" ] []
|
viewAccessInput m =
|
||||||
|
let
|
||||||
|
accessButton =
|
||||||
|
case String.toInt m.accessInput of
|
||||||
|
Just i -> optionalButton True "Access address" (Access i)
|
||||||
|
Nothing -> optionalButton False "Access address" (Access -1)
|
||||||
|
in
|
||||||
|
div []
|
||||||
|
[ labeledInput "Access address" m.accessInput ChangeAccessInput
|
||||||
|
, accessButton
|
||||||
|
]
|
||||||
|
|
||||||
viewError : Bool -> String -> Html Msg
|
viewError : Bool -> String -> Html Msg
|
||||||
viewError hide e = span [ classList [ ("hidden", hide) ] ] [ text e ]
|
viewError hide e = span [ classList [ ("hidden", hide) ] ] [ text e ]
|
||||||
|
@ -153,4 +163,4 @@ viewBase m =
|
||||||
cacheView = Maybe.withDefault [] <| Maybe.map (List.singleton << viewCacheHierarchy) <| m.hierarchy
|
cacheView = Maybe.withDefault [] <| Maybe.map (List.singleton << viewCacheHierarchy) <| m.hierarchy
|
||||||
accessView = Maybe.withDefault [] <| Maybe.map (List.singleton << viewAccessView m) <| m.accessView
|
accessView = Maybe.withDefault [] <| Maybe.map (List.singleton << viewAccessView m) <| m.accessView
|
||||||
in
|
in
|
||||||
div [] <| [ rawView, viewAccessInput] ++ cacheView ++ accessView
|
div [] <| [ rawView, viewAccessInput m] ++ cacheView ++ accessView
|
||||||
|
|
|
@ -19,6 +19,7 @@ init f =
|
||||||
{ rawHierarchy = testCacheModelHierarchy
|
{ rawHierarchy = testCacheModelHierarchy
|
||||||
, hierarchy = Nothing
|
, hierarchy = Nothing
|
||||||
, accessView = Nothing
|
, accessView = Nothing
|
||||||
|
, accessInput = ""
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
(initialModel, Cmd.none)
|
(initialModel, Cmd.none)
|
||||||
|
@ -37,6 +38,7 @@ update msg m =
|
||||||
DeleteRawModel i -> updateDeleteRawModel i m
|
DeleteRawModel i -> updateDeleteRawModel i m
|
||||||
UseHierarchy cmh -> updateUseHierarchy cmh m
|
UseHierarchy cmh -> updateUseHierarchy cmh m
|
||||||
Access i -> updateAccess i m
|
Access i -> updateAccess i m
|
||||||
|
ChangeAccessInput s -> ({ m | accessInput = s }, Cmd.none)
|
||||||
AccessViewForward -> updateAccessViewForward m
|
AccessViewForward -> updateAccessViewForward m
|
||||||
AccessViewBack -> updateAccessViewBack m
|
AccessViewBack -> updateAccessViewBack m
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user