aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Model/IdGenerator.elm2
-rw-r--r--src/Model/Model.elm5
-rw-r--r--src/Model/Timer.elm2
-rw-r--r--src/Update/Update.elm7
-rw-r--r--src/View/Timer.elm2
-rw-r--r--src/View/View.elm27
6 files changed, 16 insertions, 29 deletions
diff --git a/src/Model/IdGenerator.elm b/src/Model/IdGenerator.elm
index 8bce44f..ba760d8 100644
--- a/src/Model/IdGenerator.elm
+++ b/src/Model/IdGenerator.elm
@@ -11,7 +11,7 @@ type alias IdGenerator =
}
initialIdGenerator =
- { counter = 0
+ { counter = 1
}
getId : IdGenerator -> (Id, IdGenerator)
diff --git a/src/Model/Model.elm b/src/Model/Model.elm
index a3b4780..9a20219 100644
--- a/src/Model/Model.elm
+++ b/src/Model/Model.elm
@@ -14,7 +14,6 @@ import Model.IdGenerator (..)
type alias Model =
{ currentTime : Time
- , newTimerName : String
, timers : Dict Id Timer
, timerIdGenerator : IdGenerator
}
@@ -22,9 +21,9 @@ type alias Model =
initialModel : Time -> Model
initialModel initialTime =
let (id, idGenerator) = getId initialIdGenerator
+ timerName = "Timer " ++ (toString id)
in { currentTime = initialTime
- , newTimerName = ""
- , timers = Dict.insert id (initialTimer initialTime "Timer") Dict.empty
+ , timers = Dict.insert id (initialTimer initialTime timerName) Dict.empty
, timerIdGenerator = idGenerator
}
diff --git a/src/Model/Timer.elm b/src/Model/Timer.elm
index bfb734d..754a62a 100644
--- a/src/Model/Timer.elm
+++ b/src/Model/Timer.elm
@@ -23,7 +23,7 @@ initialTimer creationTime name =
, name = name
, initialTime = initialTime
, currentTime = initTime initialTime
- , isRunning = True
+ , isRunning = False
}
substractTimerTime : Time -> Timer -> Timer
diff --git a/src/Update/Update.elm b/src/Update/Update.elm
index 635e29d..aa31a84 100644
--- a/src/Update/Update.elm
+++ b/src/Update/Update.elm
@@ -18,7 +18,6 @@ import Update.UpdateTimer (..)
type Action =
NoOp
- | RenameNewTimer String
| AddNewTimer
| DeltaTime Time
| UpdateTimer Id TimerAction
@@ -31,14 +30,12 @@ update : Action -> Model -> Model
update action model =
case action of
NoOp -> model
- RenameNewTimer name ->
- { model | newTimerName <- name }
AddNewTimer ->
let (id, newTimerIdGenerator) = getId model.timerIdGenerator
+ timerName = "Timer " ++ (toString id)
in { model
- | timers <- Dict.insert id (initialTimer model.currentTime model.newTimerName) model.timers
+ | timers <- Dict.insert id (initialTimer model.currentTime timerName) model.timers
, timerIdGenerator <- newTimerIdGenerator
- , newTimerName <- ""
}
DeltaTime delta ->
{ model
diff --git a/src/View/Timer.elm b/src/View/Timer.elm
index 271de5c..5d34c7e 100644
--- a/src/View/Timer.elm
+++ b/src/View/Timer.elm
@@ -49,4 +49,4 @@ timeView time =
let totalSeconds = truncate (time / 1000)
totalMinutes = totalSeconds // 60
restSeconds = totalSeconds `rem` 60
- in (toString totalMinutes) ++ ":" ++ (String.padLeft 2 '0' (toString restSeconds))
+ in (toString totalMinutes) ++ " : " ++ (String.padLeft 2 '0' (toString restSeconds))
diff --git a/src/View/View.elm b/src/View/View.elm
index ae60807..2f12902 100644
--- a/src/View/View.elm
+++ b/src/View/View.elm
@@ -24,7 +24,7 @@ view model =
div
[]
[ h1 [] [ text "Timer" ]
- , addTimer model.newTimerName
+ , addTimer
, model.timers
|> Dict.toList
|> List.sortBy (.creationTime << snd)
@@ -32,24 +32,15 @@ view model =
|> timers
]
-addTimer : String -> Html
-addTimer name =
- div
- [ class "addTimer" ]
- [ input
- [ placeholder "Name"
- , value name
- , on "input" targetValue (Signal.send updates << RenameNewTimer)
- , onEnter (Signal.send updates AddNewTimer)
- , autofocus True
- ]
+addTimer : Html
+addTimer =
+ button
+ [ class "addTimer"
+ , onClick (Signal.send updates AddNewTimer)
+ ]
+ [ i
+ [ class "fa fa-fw fa-plus" ]
[]
- , button
- [ onClick (Signal.send updates AddNewTimer) ]
- [ i
- [ class "fa fa-fw fa-plus" ]
- []
- ]
]
onEnter : Signal.Message -> Attribute