aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Dialog/AddIncome
diff options
context:
space:
mode:
authorJoris2017-03-24 09:21:06 +0000
committerJoris2017-03-24 09:21:06 +0000
commitc0ac16a713c4e53cf6af8e72a6d5f6b8ac5d6456 (patch)
tree8a438430cee7411259fc395d8f3898488e85d750 /src/client/elm/Dialog/AddIncome
parent293eb8295162bf0a038f488237db9c9d1316c04d (diff)
parentcfca18262c1ff48dcb683ddab7d03cf8e55573ff (diff)
Merge branch 'features/categories' into 'master'
Features/categories See merge request !1
Diffstat (limited to 'src/client/elm/Dialog/AddIncome')
-rw-r--r--src/client/elm/Dialog/AddIncome/Model.elm27
-rw-r--r--src/client/elm/Dialog/AddIncome/View.elm9
2 files changed, 17 insertions, 19 deletions
diff --git a/src/client/elm/Dialog/AddIncome/Model.elm b/src/client/elm/Dialog/AddIncome/Model.elm
index 0d52b22..ad7b25a 100644
--- a/src/client/elm/Dialog/AddIncome/Model.elm
+++ b/src/client/elm/Dialog/AddIncome/Model.elm
@@ -4,6 +4,7 @@ module Dialog.AddIncome.Model exposing
, initialAdd
, initialClone
, initialEdit
+ , validation
)
import Date exposing (Date)
@@ -24,29 +25,29 @@ type alias Model =
}
init : Form String Model
-init = Form.initial [] validate
+init = Form.initial [] validation
initialAdd : Translations -> Date -> List (String, Field)
initialAdd translations date =
- [ ("date", Field.Text (Date.shortView date translations))
+ [ ("date", Field.string (Date.shortView date translations))
]
initialClone : Translations -> Date -> Income -> List (String, Field)
initialClone translations date income =
- [ ("amount", Field.Text (toString income.amount))
- , ("date", Field.Text (Date.shortView date translations))
+ [ ("amount", Field.string (toString income.amount))
+ , ("date", Field.string (Date.shortView date translations))
]
initialEdit : Translations -> IncomeId -> Income -> List (String, Field)
initialEdit translations incomeId income =
- [ ("id", Field.Text (toString incomeId))
- , ("amount", Field.Text (toString income.amount))
- , ("date", Field.Text (Date.shortView (Date.fromTime income.time) translations))
+ [ ("id", Field.string (toString incomeId))
+ , ("amount", Field.string (toString income.amount))
+ , ("date", Field.string (Date.shortView (Date.fromTime income.time) translations))
]
-validate : Validation String Model
-validate =
- Validate.form3 Model
- (Validate.get "id" (Validate.maybe Validate.int))
- (Validate.get "amount" (Validate.int `Validate.andThen` (Validate.minInt 1)))
- (Validate.get "date" Validation.date)
+validation : Validation String Model
+validation =
+ Validate.map3 Model
+ (Validate.field "id" (Validate.maybe Validate.int))
+ (Validate.field "amount" (Validate.int |> Validate.andThen (Validate.minInt 1)))
+ (Validate.field "date" Validation.date)
diff --git a/src/client/elm/Dialog/AddIncome/View.elm b/src/client/elm/Dialog/AddIncome/View.elm
index c628d37..b413308 100644
--- a/src/client/elm/Dialog/AddIncome/View.elm
+++ b/src/client/elm/Dialog/AddIncome/View.elm
@@ -5,7 +5,6 @@ module Dialog.AddIncome.View exposing
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
-import Html.App as Html
import Task
import Form exposing (Form)
@@ -31,8 +30,8 @@ import Model.View exposing (View(LoggedInView))
import LoggedData exposing (LoggedData)
import LoggedIn.Home.Model as HomeModel
-button : String -> LoggedData -> List (String, Field) -> String -> Html Msg -> Maybe String -> Html Msg
-button className loggedData initialForm title buttonContent tooltip =
+button : LoggedData -> List (String, Field) -> String -> Html Msg -> Maybe String -> Html Msg
+button loggedData initialForm title buttonContent tooltip =
let dialogConfig =
{ className = "incomeDialog"
, title = getMessage loggedData.translations title
@@ -46,9 +45,7 @@ button className loggedData initialForm title buttonContent tooltip =
Just message -> Tooltip.show Msg.Tooltip message
Nothing -> []
)
- ++ [ class className
- , onClick (Msg.Dialog <| Dialog.OpenWithUpdate dialogConfig (DialogMsg.AddIncomeMsg <| Form.Reset initialForm))
- ]
+ ++ [ onClick (Msg.Dialog <| Dialog.OpenWithUpdate dialogConfig (DialogMsg.Init "incomeamount" (DialogMsg.AddIncomeMsg <| Form.Reset initialForm))) ]
)
[ buttonContent ]