From 2613aeeae0f4de44842ff0e796603d0316a61a14 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Wed, 18 Mar 2015 00:32:17 +0100 Subject: Can edit the time, unfortunately the enter key is overriden so the '+' key of the numpad is used instead --- src/View/Timer.elm | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'src/View/Timer.elm') 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) -- cgit v1.2.3