From 293eb8295162bf0a038f488237db9c9d1316c04d Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 19 Nov 2016 15:51:22 +0100 Subject: Search payments with multiple words and by cost too --- src/client/elm/Model/Payment.elm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/client/elm/Model/Payment.elm b/src/client/elm/Model/Payment.elm index b986148..5109b2f 100644 --- a/src/client/elm/Model/Payment.elm +++ b/src/client/elm/Model/Payment.elm @@ -20,6 +20,7 @@ import Date exposing (..) import Date.Extra.Core exposing (monthToInt, intToMonth) import Json.Decode as Json exposing ((:=)) import String +import List import Form.Validate as Validate exposing (Validation) import Model.User exposing (UserId, userIdDecoder) @@ -115,7 +116,12 @@ paymentSort frequency = Monthly -> List.sortBy (String.toLower << .name) searchSuccess : String -> Payment -> Bool -searchSuccess text { name } = (String.toLower text) `String.contains` (String.toLower name) +searchSuccess search { name, cost } = + let searchSuccessWord word = + ( String.contains (String.toLower word) (String.toLower name) + || String.contains word (toString cost) + ) + in List.all searchSuccessWord (String.words search) validateFrequency : Validation String Frequency validateFrequency = -- cgit v1.2.3