From 35c9409680f81f51e7e4808a077c7ad0701fb581 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Sat, 13 Jun 2020 16:31:16 +0200 Subject: [PATCH] Automatically add wildcards to name search If wildcards are already present or if the search string appears in quotes, wildcard '*' characters are not added. --- .../webapp/src/main/elm/Comp/SearchMenu.elm | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/modules/webapp/src/main/elm/Comp/SearchMenu.elm b/modules/webapp/src/main/elm/Comp/SearchMenu.elm index f2f2e8b4..fea9037d 100644 --- a/modules/webapp/src/main/elm/Comp/SearchMenu.elm +++ b/modules/webapp/src/main/elm/Comp/SearchMenu.elm @@ -154,6 +154,17 @@ getItemSearch model = let e = Api.Model.ItemSearch.empty + + amendWildcards s = + if String.startsWith "\"" s && String.endsWith "\"" s then + String.dropLeft 1 s + |> String.dropRight 1 + + else if String.contains "*" s then + s + + else + "*" ++ s ++ "*" in { e | tagsInclude = Comp.Dropdown.getSelected model.tagInclModel |> List.map .id @@ -168,7 +179,9 @@ getItemSearch model = , dateUntil = model.untilDate , dueDateFrom = model.fromDueDate , dueDateUntil = model.untilDueDate - , name = model.nameModel + , name = + model.nameModel + |> Maybe.map amendWildcards } @@ -493,9 +506,10 @@ view settings model = ] [] , span [ class "small-info" ] - [ text "May contain wildcard " + [ text "Use wildcards " , code [] [ text "*" ] - , text " at beginning or end" + , text " at beginning or end. Added automatically if not " + , text "present and not quoted." ] ] , formHeader (Icons.tagsIcon "") "Tags"