aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorJoris2019-08-10 15:29:56 +0200
committerJoris2019-08-10 15:29:56 +0200
commitc5c54722f4736108c8418c9865f81f05a6db560d (patch)
treef79f5464536d2453a18ffb01bb29cc5cc6f811fa /client
parent234b5b29361734656dc780148309962f932d9907 (diff)
downloadbudget-c5c54722f4736108c8418c9865f81f05a6db560d.tar.gz
budget-c5c54722f4736108c8418c9865f81f05a6db560d.tar.bz2
budget-c5c54722f4736108c8418c9865f81f05a6db560d.zip
Fix payment add frequency to the one selected in the page
Diffstat (limited to 'client')
-rw-r--r--client/src/View/Payment/Add.hs15
-rw-r--r--client/src/View/Payment/Header.hs23
2 files changed, 20 insertions, 18 deletions
diff --git a/client/src/View/Payment/Add.hs b/client/src/View/Payment/Add.hs
index bd10e5a..d2d2dc4 100644
--- a/client/src/View/Payment/Add.hs
+++ b/client/src/View/Payment/Add.hs
@@ -37,6 +37,7 @@ import qualified Util.WaitFor as WaitFor
data AddIn t = AddIn
{ _addIn_categories :: [Category]
, _addIn_paymentCategories :: Dynamic t [PaymentCategory]
+ , _addIn_frequency :: Dynamic t Frequency
, _addIn_cancel :: Event t ()
}
@@ -92,16 +93,6 @@ view addIn = do
(const currentDay <$> reset)
confirm)
- frequency <- _selectOut_value <$> (Component.select $ SelectIn
- { _selectIn_label = Msg.get Msg.Payment_Frequency
- , _selectIn_initialValue = Punctual
- , _selectIn_value = R.never
- , _selectIn_values = R.constDyn frequencies
- , _selectIn_reset = reset
- , _selectIn_isValid = const True
- , _selectIn_validate = confirm
- })
-
let setCategory =
R.fmapMaybe id
. R.updated
@@ -122,13 +113,13 @@ view addIn = do
c <- cost
d <- date
cat <- category
- f <- frequency
+ f <- _addIn_frequency addIn
return (CreatePayment
<$> ValidationUtil.nelError n
<*> ValidationUtil.nelError c
<*> ValidationUtil.nelError d
<*> ValidationUtil.nelError cat
- <*> ValidationUtil.nelError f)
+ <*> V.Success f)
(addPayment, cancel, confirm) <- R.divClass "buttons" $ do
rec
diff --git a/client/src/View/Payment/Header.hs b/client/src/View/Payment/Header.hs
index 7a85493..fa21731 100644
--- a/client/src/View/Payment/Header.hs
+++ b/client/src/View/Payment/Header.hs
@@ -51,11 +51,20 @@ data HeaderOut t = HeaderOut
widget :: forall t m. MonadWidget t m => HeaderIn t -> m (HeaderOut t)
widget headerIn =
R.divClass "header" $ do
- addPayment <- payerAndAdd incomes payments users categories paymentCategories currency
- let resetSearchName = fmap (const ()) $ addPayment
- (searchName, searchFrequency) <- searchLine resetSearchName
-
- infos (_headerIn_searchPayments headerIn) users currency
+ rec
+ addPayment <-
+ payerAndAdd
+ incomes
+ payments
+ users
+ categories
+ paymentCategories
+ currency
+ searchFrequency
+ let resetSearchName = fmap (const ()) $ addPayment
+ (searchName, searchFrequency) <- searchLine resetSearchName
+
+ infos (_headerIn_searchPayments headerIn) users currency
return $ HeaderOut
{ _headerOut_searchName = searchName
@@ -80,8 +89,9 @@ payerAndAdd
-> [Category]
-> Dynamic t [PaymentCategory]
-> Currency
+ -> Dynamic t Frequency
-> m (Event t CreatedPayment)
-payerAndAdd incomes payments users categories paymentCategories currency = do
+payerAndAdd incomes payments users categories paymentCategories currency frequency = do
time <- liftIO Time.getCurrentTime
R.divClass "payerAndAdd" $ do
@@ -119,6 +129,7 @@ payerAndAdd incomes payments users categories paymentCategories currency = do
, _modalIn_content = Add.view $ AddIn
{ _addIn_categories = categories
, _addIn_paymentCategories = paymentCategories
+ , _addIn_frequency = frequency
, _addIn_cancel = _modalOut_hide modalOut
}
}