aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/LoggedIn
diff options
context:
space:
mode:
authorJoris2016-06-19 21:18:56 +0200
committerJoris2016-06-21 12:49:51 +0200
commit36a90770ebeb9bd99e136bfe035fdda5dfabc304 (patch)
tree42b605108f4b8b731fecd65b028006aa41399f40 /src/client/elm/LoggedIn
parentfb5629d7f705b7e80dcf1852da58d2864c2b0d25 (diff)
Add a dialog to confirm income deletion
Diffstat (limited to 'src/client/elm/LoggedIn')
-rw-r--r--src/client/elm/LoggedIn/Home/AddPayment/Update.elm4
-rw-r--r--src/client/elm/LoggedIn/Home/Update.elm4
-rw-r--r--src/client/elm/LoggedIn/Income/Model.elm2
-rw-r--r--src/client/elm/LoggedIn/Income/Msg.elm1
-rw-r--r--src/client/elm/LoggedIn/Income/Update.elm9
-rw-r--r--src/client/elm/LoggedIn/Income/View.elm15
-rw-r--r--src/client/elm/LoggedIn/Update.elm4
7 files changed, 28 insertions, 11 deletions
diff --git a/src/client/elm/LoggedIn/Home/AddPayment/Update.elm b/src/client/elm/LoggedIn/Home/AddPayment/Update.elm
index 46b3786..dc1ea57 100644
--- a/src/client/elm/LoggedIn/Home/AddPayment/Update.elm
+++ b/src/client/elm/LoggedIn/Home/AddPayment/Update.elm
@@ -13,8 +13,8 @@ import Model.Translations exposing (Translations, getMessage)
import Model.Payment exposing (Frequency(..))
update : AddPaymentMsg.Msg -> AddPaymentModel.Model -> AddPaymentModel.Model
-update action addPayment =
- case action of
+update msg addPayment =
+ case msg of
AddPaymentMsg.NoOp ->
addPayment
diff --git a/src/client/elm/LoggedIn/Home/Update.elm b/src/client/elm/LoggedIn/Home/Update.elm
index 078036d..af3504a 100644
--- a/src/client/elm/LoggedIn/Home/Update.elm
+++ b/src/client/elm/LoggedIn/Home/Update.elm
@@ -12,8 +12,8 @@ import LoggedIn.Home.Model as HomeModel
import LoggedIn.Home.AddPayment.Update as AddPaymentUpdate
update : LoggedData -> HomeMsg.Msg -> HomeModel.Model -> (HomeModel.Model, Cmd HomeMsg.Msg)
-update loggedData action homeModel =
- case action of
+update loggedData msg homeModel =
+ case msg of
HomeMsg.NoOp -> (homeModel, Cmd.none)
diff --git a/src/client/elm/LoggedIn/Income/Model.elm b/src/client/elm/LoggedIn/Income/Model.elm
index 4c82ab1..e56e290 100644
--- a/src/client/elm/LoggedIn/Income/Model.elm
+++ b/src/client/elm/LoggedIn/Income/Model.elm
@@ -16,6 +16,7 @@ import Form.Validate as Validate exposing (..)
type alias Model =
{ addIncome : Form String AddIncome
+ , test : Bool
}
type alias AddIncome =
@@ -26,6 +27,7 @@ type alias AddIncome =
init : Model
init =
{ addIncome = initForm
+ , test = False
}
initForm : Form String AddIncome
diff --git a/src/client/elm/LoggedIn/Income/Msg.elm b/src/client/elm/LoggedIn/Income/Msg.elm
index 0a09dad..b3f3633 100644
--- a/src/client/elm/LoggedIn/Income/Msg.elm
+++ b/src/client/elm/LoggedIn/Income/Msg.elm
@@ -7,3 +7,4 @@ import Form exposing (Form)
type Msg =
NoOp
| AddIncomeMsg Form.Msg
+ | ToggleTest
diff --git a/src/client/elm/LoggedIn/Income/Update.elm b/src/client/elm/LoggedIn/Income/Update.elm
index 74920f3..8fa47fc 100644
--- a/src/client/elm/LoggedIn/Income/Update.elm
+++ b/src/client/elm/LoggedIn/Income/Update.elm
@@ -10,8 +10,8 @@ import LoggedIn.Income.Model as IncomeModel
import LoggedIn.Income.Msg as IncomeMsg
update : LoggedData -> IncomeMsg.Msg -> IncomeModel.Model -> (IncomeModel.Model, Cmd IncomeMsg.Msg)
-update loggedData action model =
- case action of
+update loggedData msg model =
+ case msg of
IncomeMsg.NoOp ->
( model
@@ -22,3 +22,8 @@ update loggedData action model =
( { model | addIncome = Form.update formMsg model.addIncome }
, Cmd.none
)
+
+ IncomeMsg.ToggleTest ->
+ ( { model | test = not model.test }
+ , Cmd.none
+ )
diff --git a/src/client/elm/LoggedIn/Income/View.elm b/src/client/elm/LoggedIn/Income/View.elm
index d5863ab..7970284 100644
--- a/src/client/elm/LoggedIn/Income/View.elm
+++ b/src/client/elm/LoggedIn/Income/View.elm
@@ -14,6 +14,7 @@ import Html.Events exposing (..)
import Html.Attributes exposing (..)
import Html.App as Html
import Form exposing (Form)
+import Dialog
import Msg exposing (Msg)
@@ -23,6 +24,7 @@ import Model.Income exposing (IncomeId, Income, userCumulativeIncomeSince)
import Model.Translations exposing (getMessage, getParamMessage)
import Model.Payer exposing (useIncomesFrom)
import Model.User exposing (UserId, User)
+import Model.View as View
import LoggedIn.Income.Model as IncomeModel
import LoggedIn.Msg as LoggedInMsg
@@ -108,7 +110,14 @@ incomeView loggedData (incomeId, income) =
[ text <| renderShortDate (Date.fromTime income.time) loggedData.translations
, text " − "
, text <| Format.price loggedData.conf income.amount
- , button
- [ onClick (Msg.UpdateLoggedIn <| LoggedInMsg.DeleteIncome incomeId) ]
- [ FontAwesome.remove Color.chestnutRose 14 ]
+ , let dialogConfig =
+ { title = getMessage "ConfirmDelete" loggedData.translations
+ , body = always <| text ""
+ , confirm = getMessage "Confirm" loggedData.translations
+ , confirmMsg = Msg.UpdateLoggedIn <| LoggedInMsg.DeleteIncome incomeId
+ , undo = getMessage "Undo" loggedData.translations
+ }
+ in button
+ [ onClick (Msg.Dialog <| Dialog.Open dialogConfig) ]
+ [ FontAwesome.remove Color.chestnutRose 14 ]
]
diff --git a/src/client/elm/LoggedIn/Update.elm b/src/client/elm/LoggedIn/Update.elm
index 23f242d..7133786 100644
--- a/src/client/elm/LoggedIn/Update.elm
+++ b/src/client/elm/LoggedIn/Update.elm
@@ -35,9 +35,9 @@ import Utils.Tuple as Tuple
import Utils.Cmd exposing ((:>))
update : Model -> LoggedInMsg.Msg -> LoggedInModel.Model -> (LoggedInModel.Model, Cmd LoggedInMsg.Msg)
-update model action loggedIn =
+update model msg loggedIn =
let loggedData = LoggedData.build model loggedIn
- in case action of
+ in case msg of
LoggedInMsg.NoOp ->
(loggedIn, Cmd.none)