diff --git a/modules/webapp/src/main/elm/Comp/SearchMenu.elm b/modules/webapp/src/main/elm/Comp/SearchMenu.elm index b3411b28..10f6843d 100644 --- a/modules/webapp/src/main/elm/Comp/SearchMenu.elm +++ b/modules/webapp/src/main/elm/Comp/SearchMenu.elm @@ -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 -> diff --git a/modules/webapp/src/main/elm/Data/Icons.elm b/modules/webapp/src/main/elm/Data/Icons.elm index 86999931..72c78be0 100644 --- a/modules/webapp/src/main/elm/Data/Icons.elm +++ b/modules/webapp/src/main/elm/Data/Icons.elm @@ -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" diff --git a/modules/webapp/src/main/elm/Page/Home/Data.elm b/modules/webapp/src/main/elm/Page/Home/Data.elm index ad60e3db..b49ddc02 100644 --- a/modules/webapp/src/main/elm/Page/Home/Data.elm +++ b/modules/webapp/src/main/elm/Page/Home/Data.elm @@ -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 diff --git a/website/site/content/docs/webapp/finding.md b/website/site/content/docs/webapp/finding.md index 61d532ca..2a2dac5e 100644 --- a/website/site/content/docs/webapp/finding.md +++ b/website/site/content/docs/webapp/finding.md @@ -18,34 +18,23 @@ is visible. You can switch between them without affecting the results. {{ imgright(file="search-bar.png") }} -By default, the search bar is shown. It provides a refined view of the -search menu. The dropdown contains different options to do a quick -search. +By default, the search bar is shown. It provides a shortcut to search +for names and a mode for fulltext-only search. The dropdown contains +the different options. -## *All Names* and *Contents* +## The *Names* option {#names} -These two options correspond to the same named field in the search -menu. If you switch between search menu and search bar (by clicking -the icon on the left), you'll see that they are the same fields. -Typing in the search bar also fills the corresponding field in the -search menu (and vice versa). +This option corresponds to the same named field in the search menu. If +you switch between search menu and search bar (by clicking the icon on +the left), you'll see that they are the same fields. Typing in the +search bar also fills the corresponding field in the search menu (and +vice versa). -- The *All Names* searches in the item name, item notes, names of - correspondent organization and person, and names of concering person - and equipment. It uses a simple substring search. -- The option *Contents* searches the contents of all attachments - (documents), attachment names, the item name and item notes. It uses - full text search. However, it does not search the names of attached - meta data. - -When searching with one of these fields active, it simply submits the -(hidden) search menu. So if the menu has other fields filled out, they -will affect the result, too. Using one of these fields, the bar is -just a reduced view of the search menu. - -So you can choose tags or correspondents in the search menu and -further restrict the results using full text search. The results will -be returned sorted by the item date, newest first. +The *Names* searches in the item name, names of correspondent +organization and person, and names of concering person and equipment. +It uses a simple substring search. When searching with this option +active, it simply submits the (hidden) search menu. So if the menu has +other fields filled out, they will affect the result, too. If the left button in the search bar shows a little blue bubble, it means that there are more search fields filled out in the search menu @@ -54,10 +43,10 @@ restricted by the search term given in the search-bar, but also by what is specified in the search menu. -## *Contents Only* +## The *Contents Only* option {#contents-only} This option has no corresponding part in the search menu. Searching -with this option active, there is only a full text search done in the +with this option active, there is a full text search done in: attachments contents, attachment names, item name and item notes. The results are not ordered by item date, but by relevance with @@ -80,10 +69,8 @@ looked at are marked as "new" automatically. ## Names -Searches in names of certain properties. The `All Names` field is the -same as the search in the search bar (see above). - -The `Name` field only searches in the name property of an item. +Searches in names of certain properties. The `Names` field is the same +as the search in the search bar ([see above](#names)). ## Folder @@ -100,6 +87,22 @@ included in the results. When adding tags to the "Exclude" list, then an item is removed from the results if it has at least one of these tags. +## Content + +You can choose tags or correspondents in the search menu and further +restrict the results using full text search using the *content* field. + +{% infobubble(mode="warning", title="Please note") %} +This field is intended to be used in conjunction with other fields in +the search menu. It *may be really slow* if used alone, since first +the database query is executed and its results are furhter constrained +by fulltext search. + +Use the search-bar with option *Contents Only* to do quick fulltext +searches. +{% end %} + + ## Correspondent Pick a correspondent to show only these items. diff --git a/website/site/content/docs/webapp/search-bar.png b/website/site/content/docs/webapp/search-bar.png index b7424bf3..049523a2 100644 Binary files a/website/site/content/docs/webapp/search-bar.png and b/website/site/content/docs/webapp/search-bar.png differ diff --git a/website/site/content/docs/webapp/search-menu.png b/website/site/content/docs/webapp/search-menu.png index c35b4ad6..57478482 100644 Binary files a/website/site/content/docs/webapp/search-menu.png and b/website/site/content/docs/webapp/search-menu.png differ diff --git a/website/site/templates/shortcodes/imgright.html b/website/site/templates/shortcodes/imgright.html index cd028127..ca48753c 100644 --- a/website/site/templates/shortcodes/imgright.html +++ b/website/site/templates/shortcodes/imgright.html @@ -1,3 +1,3 @@ {% set len = page.components | length %} {% set p = page.components | slice(end=len - 1) | join(sep='/') %} - + diff --git a/website/site/templates/shortcodes/infobubble.html b/website/site/templates/shortcodes/infobubble.html new file mode 100644 index 00000000..b78b31d6 --- /dev/null +++ b/website/site/templates/shortcodes/infobubble.html @@ -0,0 +1,10 @@ +
+
+

+ {{ title }} +

+
+ {{ body | markdown | safe }} +
+
+