aboutsummaryrefslogtreecommitdiff
path: root/src/client/Dialog/AddCategory/View.elm
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/Dialog/AddCategory/View.elm')
-rw-r--r--src/client/Dialog/AddCategory/View.elm72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/client/Dialog/AddCategory/View.elm b/src/client/Dialog/AddCategory/View.elm
deleted file mode 100644
index dc55b60..0000000
--- a/src/client/Dialog/AddCategory/View.elm
+++ /dev/null
@@ -1,72 +0,0 @@
-module Dialog.AddCategory.View exposing
- ( button
- )
-
-import Html exposing (..)
-import Html.Attributes exposing (..)
-import Html.Events exposing (..)
-import Task
-
-import Form exposing (Form)
-import Form.Field as Field exposing (Field)
-import Utils.Form as Form
-
-import Dialog
-import Dialog.AddCategory.Model as AddCategory
-import Dialog.Msg as DialogMsg
-
-import Tooltip
-
-import View.Form as Form
-import View.Events exposing (onSubmitPrevDefault)
-
-import Msg exposing (Msg)
-import LoggedIn.Msg as LoggedInMsg
-import LoggedIn.Home.Msg as HomeMsg
-
-import Model.Translations exposing (getMessage)
-import Model.View exposing (View(LoggedInView))
-
-import LoggedData exposing (LoggedData)
-import LoggedIn.Home.Model as HomeModel
-
-button : LoggedData -> List (String, Field) -> String -> Html Msg -> Maybe String -> Html Msg
-button loggedData initialForm title buttonContent tooltip =
- let dialogConfig =
- { className = "categoryDialog"
- , title = getMessage loggedData.translations title
- , body = \model -> addCategoryForm loggedData model.addCategory
- , confirm = getMessage loggedData.translations "Confirm"
- , confirmMsg = submitForm << .addCategory
- , undo = getMessage loggedData.translations "Undo"
- }
- in Html.button
- ( ( case tooltip of
- Just message -> Tooltip.show Msg.Tooltip message
- Nothing -> []
- )
- ++ [ onClick (Msg.Dialog <| Dialog.OpenWithUpdate dialogConfig (DialogMsg.Init "categoryname" (DialogMsg.AddCategoryMsg (Form.Reset initialForm)))) ]
- )
- [ buttonContent ]
-
-addCategoryForm : LoggedData -> Form String AddCategory.Model -> Html Msg
-addCategoryForm loggedData addCategory =
- let htmlMap = Html.map (Msg.Dialog << Dialog.Update << DialogMsg.AddCategoryMsg)
- in Html.form
- [ onSubmitPrevDefault Msg.NoOp ]
- [ htmlMap <| Form.textInput loggedData.translations addCategory "category" "name"
- , htmlMap <| Form.colorInput loggedData.translations addCategory "category" "color"
- , Form.hiddenSubmit (submitForm addCategory)
- ]
-
-submitForm : Form String AddCategory.Model -> Msg
-submitForm addCategory =
- case Form.getOutput addCategory of
- Just data ->
- case data.id of
- Just categoryId ->
- Msg.Dialog <| Dialog.UpdateAndClose <| Msg.EditCategory categoryId (String.trim data.name) data.color
- Nothing ->
- Msg.Dialog <| Dialog.UpdateAndClose <| Msg.CreateCategory (String.trim data.name) data.color
- Nothing ->
- Msg.Dialog <| Dialog.Update <| DialogMsg.AddCategoryMsg <| Form.Submit