From 9e6cf2f2f15b3fef1f99a2fcf980eb96945dc936 Mon Sep 17 00:00:00 2001 From: Joris Guyonvarch Date: Sat, 21 Mar 2015 12:33:58 +0100 Subject: Cannot delete a timer if it is the last one --- src/View/Timer.elm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/View/Timer.elm') diff --git a/src/View/Timer.elm b/src/View/Timer.elm index 2325d3a..9c302a4 100644 --- a/src/View/Timer.elm +++ b/src/View/Timer.elm @@ -37,7 +37,7 @@ timerView model (id, timer) = , restartBlock (id, timer) , playPauseBlock (id, timer) , stopBlock (id, timer) - , removeBlock (id, timer) + , removeBlock model (id, timer) ] nameBlock : (Id, Timer) -> Html @@ -105,13 +105,17 @@ stopBlock (id, timer) = ] [ i [ class "fa fa-fw fa-stop" ] [] ] -removeBlock : (Id, Timer) -> Html -removeBlock (id, timer) = - button - [ class <| "remove block" - , onClick (Signal.send updates (RemoveTimer id)) - ] - [ i [ class "fa fa-fw fa-remove" ] [] ] +removeBlock : Model -> (Id, Timer) -> Html +removeBlock model (id, timer) = + let removeClass = + if numberOfTimers model > 1 + then "remove" + else "singleRemove" + in button + [ class <| "block " ++ removeClass + , onClick (Signal.send updates (RemoveTimer id)) + ] + [ i [ class "fa fa-fw fa-remove" ] [] ] stopIfRinging : (Id, Timer) -> Signal.Message -> Signal.Message stopIfRinging (id, timer) message = -- cgit v1.2.3