aboutsummaryrefslogtreecommitdiff
path: root/src/View/Timer.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/View/Timer.elm')
-rw-r--r--src/View/Timer.elm37
1 files changed, 20 insertions, 17 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)