From 9dfa7a7e2c6fac564a456b11623c04d0b26fbce5 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 4 Jun 2016 10:04:05 +0200 Subject: Add search on payments and use inline font awesome from elm --- src/client/elm/Model/Payment.elm | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/client/elm/Model/Payment.elm') diff --git a/src/client/elm/Model/Payment.elm b/src/client/elm/Model/Payment.elm index 4f0f85a..d9a5d68 100644 --- a/src/client/elm/Model/Payment.elm +++ b/src/client/elm/Model/Payment.elm @@ -11,10 +11,12 @@ module Model.Payment exposing , punctual , monthly , groupAndSortByMonth + , sortedFiltredPunctual ) import Date exposing (..) import Json.Decode as Json exposing ((:=)) +import String import Model.User exposing (UserId, userIdDecoder) import Model.Date exposing (dateDecoder) @@ -93,3 +95,13 @@ groupAndSortByMonth payments = |> List.sortBy fst |> List.map (\((year, month), payments) -> ((Date.numToMonth month, year), payments)) |> List.reverse + +sortedFiltredPunctual : String -> Payments -> Payments +sortedFiltredPunctual search payments = + punctual payments + |> List.sortBy (Date.toTime << .creation) + |> List.filter (searchSuccess search) + |> List.reverse + +searchSuccess : String -> Payment -> Bool +searchSuccess text { name } = (String.toLower text) `String.contains` (String.toLower name) -- cgit v1.2.3