Simplify search bar and menu

The option "contents" has been removed from the search bar. This field
is not intended to be used alone, but rather in conjunction with other
fields. Otherwise it may be really slow on large databases.

The "name" option has been removed from the search menu. This doesn't
provide anything better over the "Names" field, that search more
fields, including item names.
This commit is contained in:
Eike Kettner 2020-08-01 00:14:33 +02:00
parent 5bf302a40e
commit 46b784cc33
3 changed files with 57 additions and 48 deletions

View File

@ -599,24 +599,6 @@ view flags settings model =
]
]
]
, div
[ classList
[ ( "field", True )
, ( "invisible hidden", not flags.config.fullTextSearchEnabled )
]
]
[ label [] [ text "Content Search" ]
, input
[ type_ "text"
, onInput SetFulltext
, Util.Html.onKeyUpCode KeyUpMsg
, model.fulltextModel |> Maybe.withDefault "" |> value
]
[]
, span [ class "small-info" ]
[ text "Fulltext search in document contents."
]
]
, formHeaderHelp nameIcon "Names" ToggleNameHelp
, span
[ classList
@ -632,7 +614,7 @@ view flags settings model =
, text " to start searching."
]
, div [ class "field" ]
[ label [] [ text "All Names" ]
[ label [] [ text "Names" ]
, input
[ type_ "text"
, onInput SetAllName
@ -649,24 +631,6 @@ view flags settings model =
[ text "Looks in correspondents, concerned entities, item name and notes."
]
]
, div [ class "field" ]
[ label [] [ text "Name" ]
, input
[ type_ "text"
, onInput SetName
, Util.Html.onKeyUpCode KeyUpMsg
, model.nameModel |> Maybe.withDefault "" |> value
]
[]
, span
[ classList
[ ( "small-info", True )
, ( "invisible hidden", not model.showNameHelp )
]
]
[ text "Looks in item name only."
]
]
, formHeader (Icons.folderIcon "") "Folder"
, div [ class "field" ]
[ label [] [ text "Folder" ]
@ -681,6 +645,25 @@ view flags settings model =
[ label [] [ text "Exclude (or)" ]
, Html.map TagExcMsg (Comp.Dropdown.view settings model.tagExclModel)
]
, formHeader (Icons.searchIcon "") "Content"
, div
[ classList
[ ( "field", True )
, ( "invisible hidden", not flags.config.fullTextSearchEnabled )
]
]
[ label [] [ text "Content Search" ]
, input
[ type_ "text"
, onInput SetFulltext
, Util.Html.onKeyUpCode KeyUpMsg
, model.fulltextModel |> Maybe.withDefault "" |> value
]
[]
, span [ class "small-info" ]
[ text "Fulltext search in document contents and notes."
]
]
, formHeader (Icons.correspondentIcon "")
(case getDirection model of
Just Data.Direction.Incoming ->

View File

@ -21,6 +21,8 @@ module Data.Icons exposing
, organizationIcon
, person
, personIcon
, search
, searchIcon
, tag
, tagIcon
, tags
@ -31,6 +33,16 @@ import Html exposing (Html, i)
import Html.Attributes exposing (class)
search : String
search =
"search icon"
searchIcon : String -> Html msg
searchIcon classes =
i [ class (search ++ " " ++ classes) ] []
folder : String
folder =
"folder outline icon"

View File

@ -13,6 +13,7 @@ module Page.Home.Data exposing
import Api
import Api.Model.ItemLightList exposing (ItemLightList)
import Api.Model.ItemSearch
import Comp.FixedDropdown
import Comp.ItemCardList
import Comp.SearchMenu
@ -45,7 +46,7 @@ init flags =
let
searchTypeOptions =
if flags.config.fullTextSearchEnabled then
[ BasicSearch, ContentSearch, ContentOnlySearch ]
[ BasicSearch, ContentOnlySearch ]
else
[ BasicSearch ]
@ -70,7 +71,7 @@ init flags =
defaultSearchType : Flags -> SearchType
defaultSearchType flags =
if flags.config.fullTextSearchEnabled then
ContentSearch
ContentOnlySearch
else
BasicSearch
@ -103,7 +104,7 @@ searchTypeString : SearchType -> String
searchTypeString st =
case st of
BasicSearch ->
"All Names"
"Names"
ContentSearch ->
"Contents"
@ -133,15 +134,19 @@ itemNav id model =
doSearchCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg
doSearchCmd flags settings offset model =
case model.searchType of
BasicSearch ->
doSearchDefaultCmd flags settings offset model
if model.menuCollapsed then
case model.searchType of
BasicSearch ->
doSearchDefaultCmd flags settings offset model
ContentSearch ->
doSearchDefaultCmd flags settings offset model
ContentSearch ->
doSearchDefaultCmd flags settings offset model
ContentOnlySearch ->
doSearchIndexCmd flags settings offset model
ContentOnlySearch ->
doSearchIndexCmd flags settings offset model
else
doSearchDefaultCmd flags settings offset model
doSearchDefaultCmd : Flags -> UiSettings -> Int -> Model -> Cmd Msg
@ -181,7 +186,16 @@ doSearchIndexCmd flags settings offset model =
Api.itemIndexSearch flags mask ItemSearchAddResp
Nothing ->
Cmd.none
-- If there is no fulltext query, render simply the most
-- current ones
let
emptyMask =
Api.Model.ItemSearch.empty
mask =
{ emptyMask | limit = settings.itemSearchPageSize }
in
Api.itemSearch flags mask ItemSearchResp
resultsBelowLimit : UiSettings -> Model -> Bool