diff options
author | Joris Guyonvarch | 2015-03-18 00:32:17 +0100 |
---|---|---|
committer | Joris Guyonvarch | 2015-03-18 00:32:17 +0100 |
commit | 2613aeeae0f4de44842ff0e796603d0316a61a14 (patch) | |
tree | 722a21c69597e6d2547ad9f991e7c73afae78058 /src/View | |
parent | 0075abf51db5d1b54117525d7a7f9b06e31c9484 (diff) |
Can edit the time, unfortunately the enter key is overriden so the '+' key of the numpad is used instead
Diffstat (limited to 'src/View')
-rw-r--r-- | src/View/Timer.elm | 37 | ||||
-rw-r--r-- | src/View/View.elm | 1 |
2 files changed, 20 insertions, 18 deletions
diff --git a/src/View/Timer.elm b/src/View/Timer.elm index 5ec5d02..5d98fd1 100644 --- a/src/View/Timer.elm +++ b/src/View/Timer.elm @@ -12,6 +12,7 @@ import Maybe import Model.Model (..) import Model.Timer (..) +import Model.TimerEdition (..) import Model.Id (..) import Update.Update (..) @@ -19,6 +20,8 @@ import Update.UpdateTimer (..) import View.ActivatedClasses (..) +import Utils.Maybe (..) + timerView : Model -> (Id, Timer) -> Html timerView model (id, timer) = div @@ -26,23 +29,18 @@ timerView model (id, timer) = [ button [ class "name block" ] [ text timer.name ] - , let inEdition = - model.timerEdition - |> Maybe.map (\te -> te.id == id) - |> Maybe.withDefault False - in button - ( [ [ (True, "time block") - , (inEdition, "edition") - ] - |> activatedClasses - ] - ++ if inEdition - then - [] - else - [ onClick (Signal.send updates (EditTimer id)) ] - ) - [ text (timeView timer.currentTime) ] + , let maybeEdition = filterMaybe (\te -> te.id == id) model.timerEdition + in case maybeEdition of + Just edition -> + button + [ class "time block edition" ] + [ text (editionView edition.numbers) ] + Nothing -> + button + [ class "time block" + , onClick (Signal.send updates (EditTimer id)) + ] + [ text (timeView timer.currentTime) ] , button [ class <| "restart block" , onClick (Signal.send updates (UpdateTimer id Restart)) @@ -69,6 +67,11 @@ timerView model (id, timer) = [ i [ class "fa fa-fw fa-remove" ] [] ] ] +editionView : Numbers -> String +editionView numbers = + let (minutes, seconds) = toMinutesAndSeconds numbers + in minutes ++ " : " ++ seconds + timeView : Time -> String timeView time = let totalSeconds = truncate (time / 1000) diff --git a/src/View/View.elm b/src/View/View.elm index 8da1316..d7a9b99 100644 --- a/src/View/View.elm +++ b/src/View/View.elm @@ -9,7 +9,6 @@ import Signal import List import Dict import Json.Decode as Json -import Debug import Model.Model (..) import Model.Timer (..) |