diff options
author | Joris | 2019-08-10 14:53:41 +0200 |
---|---|---|
committer | Joris | 2019-08-10 14:53:41 +0200 |
commit | fb8f0fe577e28dae69903413b761da50586e0099 (patch) | |
tree | 91149151facf24348ce1f9798edd5c70be795d11 /client/src/View/Payment/Table.hs | |
parent | 3943c50d5320f7137bd5acec4485dd56a2aa52b3 (diff) | |
download | budget-fb8f0fe577e28dae69903413b761da50586e0099.tar.gz budget-fb8f0fe577e28dae69903413b761da50586e0099.tar.bz2 budget-fb8f0fe577e28dae69903413b761da50586e0099.zip |
Remove payment category if unused after a payment is deleted
Diffstat (limited to 'client/src/View/Payment/Table.hs')
-rw-r--r-- | client/src/View/Payment/Table.hs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/client/src/View/Payment/Table.hs b/client/src/View/Payment/Table.hs index cdc4bb3..b09f30f 100644 --- a/client/src/View/Payment/Table.hs +++ b/client/src/View/Payment/Table.hs @@ -13,11 +13,9 @@ import Reflex.Dom (Dynamic, Event, MonadWidget) import qualified Reflex.Dom as R import Common.Model (Category (..), Init (..), Payment (..), - PaymentCategory (..), PaymentId, - User (..)) + PaymentCategory (..), User (..)) import qualified Common.Model as CM import qualified Common.Msg as Msg -import qualified Common.Util.Text as T import qualified Common.View.Format as Format import Component (ButtonIn (..), ButtonOut (..), ModalIn (..), ModalOut (..)) @@ -37,7 +35,7 @@ data TableIn t = TableIn } data TableOut t = TableOut - { _tableOut_deletePayment :: Event t PaymentId + { _tableOut_deletePayment :: Event t Payment } widget :: forall t m. MonadWidget t m => TableIn t -> m (TableOut t) @@ -84,7 +82,7 @@ paymentRow => Init -> Dynamic t [PaymentCategory] -> Dynamic t Payment - -> m (Event t PaymentId) + -> m (Event t Payment) paymentRow init paymentCategories payment = R.divClass "row" $ do @@ -151,13 +149,13 @@ paymentRow init paymentCategories payment = [ _deleteOut_cancel . _modalOut_content $ modalOut , fmap (const ()) . _deleteOut_validate . _modalOut_content $ modalOut ] - , _modalIn_content = Delete.view (DeleteIn { _deleteIn_id = fmap _payment_id payment }) + , _modalIn_content = Delete.view (DeleteIn { _deleteIn_payment = payment }) } return (_deleteOut_validate . _modalOut_content $ modalOut) findCategory :: [Category] -> [PaymentCategory] -> Text -> Maybe Category findCategory categories paymentCategories paymentName = do paymentCategory <- L.find - ((== T.formatSearch paymentName) . _paymentCategory_name) + ((== T.toLower paymentName) . _paymentCategory_name) paymentCategories L.find ((== (_paymentCategory_category paymentCategory)) . _category_id) categories |