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.elm28
1 files changed, 23 insertions, 5 deletions
diff --git a/src/View/Timer.elm b/src/View/Timer.elm
index 6925e42..5ec5d02 100644
--- a/src/View/Timer.elm
+++ b/src/View/Timer.elm
@@ -8,23 +8,41 @@ import Html.Events (..)
import String
import Time (Time)
import Signal
+import Maybe
+import Model.Model (..)
import Model.Timer (..)
import Model.Id (..)
import Update.Update (..)
import Update.UpdateTimer (..)
-timerView : (Id, Timer) -> Html
-timerView (id, timer) =
+import View.ActivatedClasses (..)
+
+timerView : Model -> (Id, Timer) -> Html
+timerView model (id, timer) =
div
[ class <| "timer" ++ (if timer.isRunning then " isRunning" else "") ]
[ button
[ class "name block" ]
[ text timer.name ]
- , button
- [ class <| "time block" ]
- [ text (timeView timer.currentTime) ]
+ , 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) ]
, button
[ class <| "restart block"
, onClick (Signal.send updates (UpdateTimer id Restart))