diff --git a/jarbas/frontend/elm/Reimbursement/Fields.elm b/jarbas/frontend/elm/Reimbursement/Fields.elm index 6b32e3c..4de8f89 100644 --- a/jarbas/frontend/elm/Reimbursement/Fields.elm +++ b/jarbas/frontend/elm/Reimbursement/Fields.elm @@ -102,10 +102,10 @@ sets = {-| Filter to get numbers only fields: - >>> isNumeric "year" + >>> isNumeric Year True - >>> isNumeric "format" + >>> isNumeric Company False -} diff --git a/jarbas/frontend/elm/Reimbursement/Search/Update.elm b/jarbas/frontend/elm/Reimbursement/Search/Update.elm index 5de81e6..714c3ed 100644 --- a/jarbas/frontend/elm/Reimbursement/Search/Update.elm +++ b/jarbas/frontend/elm/Reimbursement/Search/Update.elm @@ -89,8 +89,22 @@ updateFromQuery model query = model +{-| Convert a list of non-empty, searchable fields into a pair of key/value: + >>> import Reimbursement.Fields exposing (Field(..), Label(..)) + + >>> toQuery [ Field Year "2016" ] + [ ( "year", "2016" ) ] + + >>> toQuery [ Field LegOfTheTrip "any" ] + [] + + >>> toQuery [ Field Year "" ] + [] + +-} toQuery : Model -> List ( String, String ) toQuery model = model - |> List.filter (Fields.getValue >> String.trim >> String.isEmpty >> not) |> List.map (\(Field label value) -> ( Fields.labelToUrl label, value |> String.trim )) + |> List.filter (Tuple.first >> String.isEmpty >> not) + |> List.filter (Tuple.second >> String.isEmpty >> not) diff --git a/jarbas/frontend/elm/Reimbursement/Update.elm b/jarbas/frontend/elm/Reimbursement/Update.elm index 4acf67c..a69c9ba 100644 --- a/jarbas/frontend/elm/Reimbursement/Update.elm +++ b/jarbas/frontend/elm/Reimbursement/Update.elm @@ -414,26 +414,19 @@ loadReimbursements lang apiKey query = {-| Convert a list of key/value query pairs to a valid URL: - >>> toUrl [ ( "year", "2016" ), ( "foo", "bar" ) ] - "#/year/2016" - - >>> toUrl [ ( "foo", "bar" ) ] - "" + >>> toUrl [ ( "year", "2016" ), ( "month", "10" ) ] + "#/year/2016/month/10" -} toUrl : List ( String, String ) -> String toUrl query = - let - validQueries = - List.filter (Tuple.first >> String.isEmpty >> not) query - in - if List.isEmpty validQueries then - "" - else - validQueries - |> List.map (\( key, value ) -> key ++ "/" ++ value) - |> String.join "/" - |> (++) "#/" + if List.isEmpty query then + "" + else + query + |> List.map (\( key, value ) -> key ++ "/" ++ value) + |> String.join "/" + |> (++) "#/" updateJumpTo : Model -> Maybe Int -> ( Model, Cmd Msg ) diff --git a/jarbas/frontend/tests/elm-doc-test.json b/jarbas/frontend/tests/elm-doc-test.json index a565855..bfcd81e 100644 --- a/jarbas/frontend/tests/elm-doc-test.json +++ b/jarbas/frontend/tests/elm-doc-test.json @@ -17,9 +17,6 @@ "Reimbursement.Company.View", "Reimbursement.Decoder", "Reimbursement.Fields", - "Reimbursement.Inputs.Model", - "Reimbursement.Inputs.Update", - "Reimbursement.Inputs.View", "Reimbursement.Map.Model", "Reimbursement.Map.Update", "Reimbursement.Map.View", @@ -36,6 +33,9 @@ "Reimbursement.SameDay.View", "Reimbursement.SameSubquota.Update", "Reimbursement.SameSubquota.View", + "Reimbursement.Search.Model", + "Reimbursement.Search.Update", + "Reimbursement.Search.View", "Reimbursement.Update", "Reimbursement.View", "Update",