aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoris Guyonvarch2015-03-18 09:17:40 +0100
committerJoris Guyonvarch2015-03-18 09:17:40 +0100
commit7ca7887ae82c09270869ed6737f94a99e210665c (patch)
tree421a775e115a7ea61d01e8165aee925ab44c9c42
parent2613aeeae0f4de44842ff0e796603d0316a61a14 (diff)
Finally use unter to update timer edition
-rw-r--r--src/Update/Update.elm23
-rw-r--r--src/View/Timer.elm4
2 files changed, 14 insertions, 13 deletions
diff --git a/src/Update/Update.elm b/src/Update/Update.elm
index 4725970..8285760 100644
--- a/src/Update/Update.elm
+++ b/src/Update/Update.elm
@@ -27,6 +27,7 @@ type Action =
| UpdateTimer Id TimerAction
| RemoveTimer Id
| EditTimer Id
+ | ValidTimerEdition
| ReadOnly
| KeyPressed KeyCode
@@ -66,21 +67,19 @@ update action model =
| timerEdition <- Just (newTimerEdition id)
, timers <- Dict.update id (Maybe.map (updateTimer Pause)) model.timers
}
+ ValidTimerEdition ->
+ case model.timerEdition of
+ Just timerEdition ->
+ { model
+ | timers <- Dict.update timerEdition.id (Maybe.map (updateTimer (SetTime (toTime timerEdition.numbers)))) model.timers
+ , timerEdition <- Nothing
+ }
+ Nothing ->
+ { model | timerEdition <- Nothing }
ReadOnly ->
{ model | timerEdition <- Nothing }
KeyPressed keyCode ->
- if isEnter keyCode
- then
- case model.timerEdition of
- Just timerEdition ->
- { model
- | timers <- Dict.update timerEdition.id (Maybe.map (updateTimer (SetTime (toTime timerEdition.numbers)))) model.timers
- , timerEdition <- Nothing
- }
- Nothing ->
- { model | timerEdition <- Nothing }
- else
- { model | timerEdition <- Maybe.map (updateTimerEdition (keyCodeToChar keyCode)) model.timerEdition }
+ { model | timerEdition <- Maybe.map (updateTimerEdition (keyCodeToChar keyCode)) model.timerEdition }
isEnter : KeyCode -> Bool
isEnter = (==) 107
diff --git a/src/View/Timer.elm b/src/View/Timer.elm
index 5d98fd1..b508dd6 100644
--- a/src/View/Timer.elm
+++ b/src/View/Timer.elm
@@ -33,7 +33,9 @@ timerView model (id, timer) =
in case maybeEdition of
Just edition ->
button
- [ class "time block edition" ]
+ [ class "time block edition"
+ , onClick (Signal.send updates ValidTimerEdition)
+ ]
[ text (editionView edition.numbers) ]
Nothing ->
button