aboutsummaryrefslogtreecommitdiff
path: root/src/client/elm/Model
diff options
context:
space:
mode:
authorJoris2016-06-26 17:30:03 +0200
committerJoris2016-06-26 17:30:03 +0200
commit885dfd7708e338a3220c85b7f22a3ac267aad3f7 (patch)
treeff259354eb9fd97fc0bab2775296830dcced5693 /src/client/elm/Model
parentcfade71c343eb29c8873011f5878a39aed8257b2 (diff)
Add the clone functionality on payments
Diffstat (limited to 'src/client/elm/Model')
-rw-r--r--src/client/elm/Model/Payment.elm9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/client/elm/Model/Payment.elm b/src/client/elm/Model/Payment.elm
index c89e709..7e5b37d 100644
--- a/src/client/elm/Model/Payment.elm
+++ b/src/client/elm/Model/Payment.elm
@@ -101,9 +101,14 @@ search : String -> Frequency -> Payments -> Payments
search name frequency payments =
payments
|> List.filter ((==) frequency << .frequency)
- |> List.sortBy (Date.toTime << .date)
+ |> paymentSort frequency
|> List.filter (searchSuccess name)
- |> List.reverse
+
+paymentSort : Frequency -> Payments -> Payments
+paymentSort frequency =
+ case frequency of
+ Punctual -> List.reverse << List.sortBy (Date.toTime << .date)
+ Monthly -> List.sortBy (String.toLower << .name)
searchSuccess : String -> Payment -> Bool
searchSuccess text { name } = (String.toLower text) `String.contains` (String.toLower name)