aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--design/design.css2
-rw-r--r--src/Main.elm2
-rw-r--r--src/Update/Update.elm24
-rw-r--r--src/View/Timer.elm8
4 files changed, 22 insertions, 14 deletions
diff --git a/design/design.css b/design/design.css
index 09ad82b..6909105 100644
--- a/design/design.css
+++ b/design/design.css
@@ -111,7 +111,7 @@
box-shadow: 0px 2px #AAAAAA;
}
-.timer > button.name {
+.timer > .name {
width: 300px;
cursor: text;
}
diff --git a/src/Main.elm b/src/Main.elm
index 82c3e20..b84a3ae 100644
--- a/src/Main.elm
+++ b/src/Main.elm
@@ -24,7 +24,7 @@ main : Signal Html
main = Signal.map view model
model : Signal Model
-model = Signal.foldp update (initialModel initialTime) input
+model = Signal.foldp logUpdate (initialModel initialTime) input
input : Signal Action
input =
diff --git a/src/Update/Update.elm b/src/Update/Update.elm
index 87df965..f3bb263 100644
--- a/src/Update/Update.elm
+++ b/src/Update/Update.elm
@@ -1,6 +1,7 @@
module Update.Update
( Action(..)
, updates
+ , logUpdate
, update
) where
@@ -11,8 +12,8 @@ import Time (Time)
import Maybe
import Keyboard (KeyCode)
import Char
-import Debug
import List
+import Debug
import Model.Model (..)
import Model.Timer (..)
@@ -65,7 +66,7 @@ update action model =
| currentTime <- model.currentTime + delta
, timers <- Dict.map (\id timer -> updateTimer (SubstractTime delta) timer) model.timers
}
- UpdateTimer id action ->
+ UpdateTimer id timerAction ->
let maybeEdition = filterMaybe (\edition -> edition.id == id) model.edition
newModel =
case maybeEdition of
@@ -73,7 +74,7 @@ update action model =
if edition.kind == Time then validEdition model else model
Nothing ->
model
- in { newModel | timers <- Dict.update id (Maybe.map (updateTimer action)) newModel.timers }
+ in { newModel | timers <- Dict.update id (Maybe.map (updateTimer timerAction)) newModel.timers }
RemoveTimer id ->
if numberOfTimers model > 1
then
@@ -93,11 +94,15 @@ update action model =
ClickAway ->
{ model | edition <- Nothing }
KeyPressed keyCode ->
- if isRemoveKeyCode keyCode
+ if isEnterKeyCode keyCode
then
- { model | edition <- Maybe.map (updateEdition DeleteLast) model.edition }
+ validEdition model
else
- { model | edition <- Maybe.map (updateEdition (AddChar keyCode)) model.edition }
+ let editionAction =
+ if isRemoveKeyCode keyCode
+ then DeleteLast
+ else AddChar keyCode
+ in { model | edition <- Maybe.map (updateEdition editionAction) model.edition }
validEdition : Model -> Model
validEdition model =
@@ -107,18 +112,21 @@ validEdition model =
then
model
else
- let action =
+ let timerAction =
case edition.kind of
Name ->
Rename (renderNameEdition edition.chars)
Time ->
SetTime (toTime edition.chars)
in { model
- | timers <- Dict.update edition.id (Maybe.map (updateTimer action)) model.timers
+ | timers <- Dict.update edition.id (Maybe.map (updateTimer timerAction)) model.timers
, edition <- Nothing
}
Nothing ->
model
+isEnterKeyCode : KeyCode -> Bool
+isEnterKeyCode = (==) 13
+
isRemoveKeyCode : KeyCode -> Bool
isRemoveKeyCode = (==) 8
diff --git a/src/View/Timer.elm b/src/View/Timer.elm
index 100514a..c8b6561 100644
--- a/src/View/Timer.elm
+++ b/src/View/Timer.elm
@@ -39,7 +39,7 @@ timerView model (id, timer) =
nameBlockReadOnly : Id -> Timer -> Html
nameBlockReadOnly id timer =
- button
+ div
[ class "name block"
, onClick (Signal.send updates (Edit id Name))
]
@@ -47,7 +47,7 @@ nameBlockReadOnly id timer =
nameBlockEdition : Id -> Timer -> Edition -> Html
nameBlockEdition id timer edition =
- button
+ div
[ [ (True, "name block edition")
, (List.isEmpty edition.chars, "empty")
]
@@ -68,7 +68,7 @@ timerName id = Maybe.withDefault ("Timer " ++ toString id) << .name
timeBlockReadOnly : Id -> Timer -> Html
timeBlockReadOnly id timer =
- button
+ div
[ [ (True, "time block")
, (timer.state == Ringing, "isRinging")
, (timer.state == Running, "isRunning")
@@ -84,7 +84,7 @@ timeBlockReadOnly id timer =
timeBlockEdition : Timer -> Edition -> Html
timeBlockEdition timer edition =
let isEmptyEdition = List.isEmpty edition.chars
- in button
+ in div
[ [ (True, "time block edition")
, (isEmptyEdition, "empty")
]