aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Dialog/AddPaymentButton
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/elm/Dialog/AddPaymentButton')
-rw-r--r--src/client/elm/Dialog/AddPaymentButton/View.elm82
1 files changed, 0 insertions, 82 deletions
diff --git a/src/client/elm/Dialog/AddPaymentButton/View.elm b/src/client/elm/Dialog/AddPaymentButton/View.elm
deleted file mode 100644
index 585b1b7..0000000
--- a/src/client/elm/Dialog/AddPaymentButton/View.elm
+++ /dev/null
@@ -1,82 +0,0 @@
-module Dialog.AddPaymentButton.View exposing
- ( view
- )
-
-import Html exposing (..)
-import Html.Attributes exposing (..)
-import Html.Events exposing (..)
-import Html.App as Html
-import Task
-
-import Form exposing (Form)
-import Form.Field as Field exposing (Field)
-import Utils.Form as Form
-
-import Dialog
-import Dialog.Model as DialogModel
-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.Payment as Payment exposing (Frequency(..))
-import Model.View exposing (View(LoggedInView))
-
-import LoggedData exposing (LoggedData)
-import LoggedIn.Home.Model as HomeModel
-
-view : LoggedData -> List (String, Field) -> String -> Html Msg -> Maybe String -> Html Msg
-view loggedData initialForm title buttonContent tooltip =
- let dialogConfig =
- { className = "paymentDialog"
- , title = getMessage title loggedData.translations
- , body = \model -> addPaymentForm loggedData model.addPayment
- , confirm = getMessage "Confirm" loggedData.translations
- , confirmMsg = submitForm << .addPayment
- , undo = getMessage "Undo" loggedData.translations
- }
- in button
- ( ( case tooltip of
- Just message -> Tooltip.show Msg.Tooltip message
- Nothing -> []
- )
- ++ [ class "addPayment"
- , onClick (Msg.Dialog <| Dialog.OpenWithUpdate dialogConfig (DialogMsg.AddPaymentMsg <| Form.Reset initialForm))
- ]
- )
- [ buttonContent ]
-
-addPaymentForm : LoggedData -> Form String DialogModel.AddPayment -> Html Msg
-addPaymentForm loggedData addPayment =
- let htmlMap = Html.map (Msg.Dialog << Dialog.Update << DialogMsg.AddPaymentMsg)
- in Html.form
- [ class "addPayment"
- , onSubmitPrevDefault Msg.NoOp
- ]
- [ htmlMap <| Form.textInput loggedData.translations addPayment "payment" "name"
- , htmlMap <| Form.textInput loggedData.translations addPayment "payment" "cost"
- , if (Form.getFieldAsString "frequency" addPayment).value == Just (toString Punctual)
- then htmlMap <| Form.textInput loggedData.translations addPayment "payment" "date"
- else text ""
- , htmlMap <| Form.radioInputs loggedData.translations addPayment "payment" "frequency" [ toString Punctual, toString Monthly ]
- , Form.hiddenSubmit (submitForm addPayment)
- ]
-
-submitForm : Form String DialogModel.AddPayment -> Msg
-submitForm addPayment =
- case Form.getOutput addPayment of
- Just data ->
- case data.id of
- Just paymentId ->
- Msg.Dialog <| Dialog.UpdateAndClose <| Msg.UpdateLoggedIn <| LoggedInMsg.EditPayment paymentId data.name data.cost data.date data.frequency
- Nothing ->
- Msg.Dialog <| Dialog.UpdateAndClose <| Msg.UpdateLoggedIn <| LoggedInMsg.CreatePayment data.name data.cost data.date data.frequency
- Nothing ->
- Msg.Dialog <| Dialog.Update <| DialogMsg.AddPaymentMsg <| Form.Submit