diff options
author | Joris | 2016-11-19 15:51:22 +0100 |
---|---|---|
committer | Joris | 2016-11-19 15:51:22 +0100 |
commit | 293eb8295162bf0a038f488237db9c9d1316c04d (patch) | |
tree | 3e217f2f3dc127c574613bd8a2b56c8bb0816a74 /src/client/elm/Model | |
parent | ede7b4fade5c396b47d386bd616e05805622b647 (diff) |
Search payments with multiple words and by cost too
Diffstat (limited to 'src/client/elm/Model')
-rw-r--r-- | src/client/elm/Model/Payment.elm | 8 |
1 files changed, 7 insertions, 1 deletions
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 = |