aboutsummaryrefslogtreecommitdiff
path: root/src/client/Dialog/AddCategory
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Dialog/AddCategory')
-rw-r--r--src/client/Dialog/AddCategory/Model.elm8
-rw-r--r--src/client/Dialog/AddCategory/View.elm6
2 files changed, 8 insertions, 6 deletions
diff --git a/src/client/Dialog/AddCategory/Model.elm b/src/client/Dialog/AddCategory/Model.elm
index 7496c2b..3b70482 100644
--- a/src/client/Dialog/AddCategory/Model.elm
+++ b/src/client/Dialog/AddCategory/Model.elm
@@ -8,14 +8,16 @@ module Dialog.AddCategory.Model exposing
)
import Date exposing (Date)
-import View.Date as Date
+import Dict
import Form exposing (Form)
import Form.Field as Field exposing (Field)
import Form.Validate as Validate exposing (Validation)
+import Model.Category exposing (Categories, Category, CategoryId)
import Model.Translations exposing (Translations)
-import Model.Category exposing (Category, CategoryId)
+import Validation
+import View.Date as Date
type alias Model =
{ id : Maybe CategoryId
@@ -49,4 +51,4 @@ validation =
Validate.map3 Model
(Validate.field "id" (Validate.maybe Validate.int))
(Validate.field "name" (Validate.string |> Validate.andThen Validate.nonEmpty))
- (Validate.field "color" (Validate.string |> Validate.andThen Validate.nonEmpty))
+ (Validate.field "color" Validation.color)
diff --git a/src/client/Dialog/AddCategory/View.elm b/src/client/Dialog/AddCategory/View.elm
index 6c02351..dc55b60 100644
--- a/src/client/Dialog/AddCategory/View.elm
+++ b/src/client/Dialog/AddCategory/View.elm
@@ -45,7 +45,7 @@ button loggedData initialForm title buttonContent tooltip =
Just message -> Tooltip.show Msg.Tooltip message
Nothing -> []
)
- ++ [ onClick (Msg.Dialog <| Dialog.OpenWithUpdate dialogConfig (DialogMsg.Init "categoryname" (DialogMsg.AddCategoryMsg <| Form.Reset initialForm))) ]
+ ++ [ onClick (Msg.Dialog <| Dialog.OpenWithUpdate dialogConfig (DialogMsg.Init "categoryname" (DialogMsg.AddCategoryMsg (Form.Reset initialForm)))) ]
)
[ buttonContent ]
@@ -65,8 +65,8 @@ submitForm addCategory =
Just data ->
case data.id of
Just categoryId ->
- Msg.Dialog <| Dialog.UpdateAndClose <| Msg.EditCategory categoryId data.name data.color
+ Msg.Dialog <| Dialog.UpdateAndClose <| Msg.EditCategory categoryId (String.trim data.name) data.color
Nothing ->
- Msg.Dialog <| Dialog.UpdateAndClose <| Msg.CreateCategory data.name data.color
+ Msg.Dialog <| Dialog.UpdateAndClose <| Msg.CreateCategory (String.trim data.name) data.color
Nothing ->
Msg.Dialog <| Dialog.Update <| DialogMsg.AddCategoryMsg <| Form.Submit