diff options
author | Joris | 2019-11-06 19:44:15 +0100 |
---|---|---|
committer | Joris | 2019-11-06 19:44:15 +0100 |
commit | f4f24158a46d8c0975f1b8813bbdbbeebad8c108 (patch) | |
tree | d0aeaa3a920caaff7408a1f6cd12b45f21cb2620 /server/src/Controller | |
parent | 58f6c4e25f5f20f1b608242c83786e2f13947804 (diff) |
Show the payment table with server side paging
Diffstat (limited to 'server/src/Controller')
-rw-r--r-- | server/src/Controller/Payment.hs | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/server/src/Controller/Payment.hs b/server/src/Controller/Payment.hs index 30b63ff..01702cb 100644 --- a/server/src/Controller/Payment.hs +++ b/server/src/Controller/Payment.hs @@ -1,5 +1,6 @@ module Controller.Payment - ( list + ( deprecatedList + , list , listPaymentCategories , create , edit @@ -15,6 +16,7 @@ import Common.Model (Category (..), CreatePaymentForm (..), EditPaymentForm (..), Payment (..), PaymentId, + PaymentPage (..), SavedPayment (..), User (..)) import qualified Common.Msg as Msg import qualified Controller.Helper as ControllerHelper @@ -27,12 +29,23 @@ import qualified Persistence.PaymentCategory as PaymentCategoryPersistence import qualified Secure import qualified Validation.Payment as PaymentValidation -list :: ActionM () -list = +deprecatedList :: ActionM () +deprecatedList = Secure.loggedAction (\_ -> (liftIO . Query.run $ PaymentPersistence.listActive) >>= json ) +list :: Int -> Int -> ActionM () +list page perPage = + Secure.loggedAction (\_ -> + (liftIO . Query.run $ do + count <- PaymentPersistence.count + payments <- PaymentPersistence.listActivePage page perPage + paymentCategories <- PaymentCategoryPersistence.list + return $ PaymentPage payments paymentCategories count + ) >>= json + ) + listPaymentCategories :: ActionM () listPaymentCategories = Secure.loggedAction (\_ -> |