aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoris2016-11-19 15:51:22 +0100
committerJoris2016-11-19 15:51:22 +0100
commit293eb8295162bf0a038f488237db9c9d1316c04d (patch)
tree3e217f2f3dc127c574613bd8a2b56c8bb0816a74 /src
parentede7b4fade5c396b47d386bd616e05805622b647 (diff)
downloadbudget-293eb8295162bf0a038f488237db9c9d1316c04d.tar.gz
budget-293eb8295162bf0a038f488237db9c9d1316c04d.tar.bz2
budget-293eb8295162bf0a038f488237db9c9d1316c04d.zip
Search payments with multiple words and by cost too
Diffstat (limited to 'src')
-rw-r--r--src/client/elm/Model/Payment.elm8
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 =