mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-02 13:32:51 +00:00
Prepare ui to handle content search
This commit is contained in:
parent
3d82e03a8a
commit
af4522c0a7
@ -170,7 +170,7 @@ viewLogin model =
|
||||
|
||||
viewHome : Model -> Html Msg
|
||||
viewHome model =
|
||||
Html.map HomeMsg (Page.Home.View.view model.uiSettings model.homeModel)
|
||||
Html.map HomeMsg (Page.Home.View.view model.flags model.uiSettings model.homeModel)
|
||||
|
||||
|
||||
menuEntry : Model -> Page -> List (Html Msg) -> Html Msg
|
||||
|
@ -9,6 +9,7 @@ module Comp.FixedDropdown exposing
|
||||
, update
|
||||
, view
|
||||
, viewString
|
||||
, viewStyled
|
||||
)
|
||||
|
||||
import Html exposing (..)
|
||||
@ -69,11 +70,12 @@ update msg model =
|
||||
( model, Just item.id )
|
||||
|
||||
|
||||
view : Maybe (Item a) -> Model a -> Html (Msg a)
|
||||
view selected model =
|
||||
viewStyled : String -> Maybe (Item a) -> Model a -> Html (Msg a)
|
||||
viewStyled classes selected model =
|
||||
div
|
||||
[ classList
|
||||
[ ( "ui selection dropdown", True )
|
||||
, ( classes, True )
|
||||
, ( "open", model.menuOpen )
|
||||
]
|
||||
, onClick ToggleMenu
|
||||
@ -102,6 +104,11 @@ view selected model =
|
||||
]
|
||||
|
||||
|
||||
view : Maybe (Item a) -> Model a -> Html (Msg a)
|
||||
view selected model =
|
||||
viewStyled "" selected model
|
||||
|
||||
|
||||
viewString : Maybe String -> Model String -> Html (Msg String)
|
||||
viewString selected model =
|
||||
view (Maybe.map (\s -> Item s s) selected) model
|
||||
|
@ -504,8 +504,8 @@ update flags settings msg model =
|
||||
-- View
|
||||
|
||||
|
||||
view : UiSettings -> Model -> Html Msg
|
||||
view settings model =
|
||||
view : Flags -> UiSettings -> Model -> Html Msg
|
||||
view flags settings model =
|
||||
let
|
||||
formHeader icon headline =
|
||||
div [ class "ui small dividing header" ]
|
||||
@ -532,7 +532,12 @@ view settings model =
|
||||
]
|
||||
]
|
||||
]
|
||||
, div [ class "field" ]
|
||||
, div
|
||||
[ classList
|
||||
[ ( "field", True )
|
||||
, ( "invisible hidden", not flags.config.fullTextSearchEnabled )
|
||||
]
|
||||
]
|
||||
[ label [] [ text "Content Search" ]
|
||||
, input
|
||||
[ type_ "text"
|
||||
|
@ -1,15 +1,18 @@
|
||||
module Page.Home.Data exposing
|
||||
( Model
|
||||
, Msg(..)
|
||||
, SearchType(..)
|
||||
, ViewMode(..)
|
||||
, doSearchCmd
|
||||
, init
|
||||
, itemNav
|
||||
, resultsBelowLimit
|
||||
, searchTypeString
|
||||
)
|
||||
|
||||
import Api
|
||||
import Api.Model.ItemLightList exposing (ItemLightList)
|
||||
import Comp.FixedDropdown
|
||||
import Comp.ItemCardList
|
||||
import Comp.SearchMenu
|
||||
import Data.Flags exposing (Flags)
|
||||
@ -29,11 +32,28 @@ type alias Model =
|
||||
, moreAvailable : Bool
|
||||
, moreInProgress : Bool
|
||||
, throttle : Throttle Msg
|
||||
, searchTypeDropdown : Comp.FixedDropdown.Model SearchType
|
||||
, searchType : SearchType
|
||||
}
|
||||
|
||||
|
||||
init : Flags -> Model
|
||||
init _ =
|
||||
init flags =
|
||||
let
|
||||
searchTypeOptions =
|
||||
if flags.config.fullTextSearchEnabled then
|
||||
[ BasicSearch, ContentSearch, ContentOnlySearch ]
|
||||
|
||||
else
|
||||
[ BasicSearch ]
|
||||
|
||||
defaultSearchType =
|
||||
if flags.config.fullTextSearchEnabled then
|
||||
ContentSearch
|
||||
|
||||
else
|
||||
BasicSearch
|
||||
in
|
||||
{ searchMenuModel = Comp.SearchMenu.init
|
||||
, itemListModel = Comp.ItemCardList.init
|
||||
, searchInProgress = False
|
||||
@ -43,6 +63,10 @@ init _ =
|
||||
, moreAvailable = True
|
||||
, moreInProgress = False
|
||||
, throttle = Throttle.create 1
|
||||
, searchTypeDropdown =
|
||||
Comp.FixedDropdown.initMap searchTypeString
|
||||
searchTypeOptions
|
||||
, searchType = defaultSearchType
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +82,26 @@ type Msg
|
||||
| LoadMore
|
||||
| UpdateThrottle
|
||||
| SetBasicSearch String
|
||||
| SetFulltextSearch String
|
||||
| SearchTypeMsg (Comp.FixedDropdown.Msg SearchType)
|
||||
|
||||
|
||||
type SearchType
|
||||
= BasicSearch
|
||||
| ContentSearch
|
||||
| ContentOnlySearch
|
||||
|
||||
|
||||
searchTypeString : SearchType -> String
|
||||
searchTypeString st =
|
||||
case st of
|
||||
BasicSearch ->
|
||||
"All Names"
|
||||
|
||||
ContentSearch ->
|
||||
"Contents"
|
||||
|
||||
ContentOnlySearch ->
|
||||
"Contents Only"
|
||||
|
||||
|
||||
type ViewMode
|
||||
|
@ -1,6 +1,7 @@
|
||||
module Page.Home.Update exposing (update)
|
||||
|
||||
import Browser.Navigation as Nav
|
||||
import Comp.FixedDropdown
|
||||
import Comp.ItemCardList
|
||||
import Comp.SearchMenu
|
||||
import Data.Flags exposing (Flags)
|
||||
@ -150,17 +151,31 @@ update key flags settings msg model =
|
||||
|
||||
SetBasicSearch str ->
|
||||
let
|
||||
m =
|
||||
SearchMenuMsg (Comp.SearchMenu.SetAllName str)
|
||||
in
|
||||
update key flags settings m model
|
||||
smMsg =
|
||||
case model.searchType of
|
||||
BasicSearch ->
|
||||
SearchMenuMsg (Comp.SearchMenu.SetAllName str)
|
||||
|
||||
SetFulltextSearch str ->
|
||||
let
|
||||
m =
|
||||
SearchMenuMsg (Comp.SearchMenu.SetFulltext str)
|
||||
ContentSearch ->
|
||||
SearchMenuMsg (Comp.SearchMenu.SetFulltext str)
|
||||
|
||||
ContentOnlySearch ->
|
||||
Debug.todo "implement"
|
||||
in
|
||||
update key flags settings m model
|
||||
update key flags settings smMsg model
|
||||
|
||||
SearchTypeMsg lm ->
|
||||
let
|
||||
( sm, mv ) =
|
||||
Comp.FixedDropdown.update lm model.searchTypeDropdown
|
||||
in
|
||||
withSub
|
||||
( { model
|
||||
| searchTypeDropdown = sm
|
||||
, searchType = Maybe.withDefault model.searchType mv
|
||||
}
|
||||
, Cmd.none
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
@ -1,8 +1,10 @@
|
||||
module Page.Home.View exposing (view)
|
||||
|
||||
import Api.Model.ItemSearch
|
||||
import Comp.FixedDropdown
|
||||
import Comp.ItemCardList
|
||||
import Comp.SearchMenu
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@ -11,8 +13,8 @@ import Page exposing (Page(..))
|
||||
import Page.Home.Data exposing (..)
|
||||
|
||||
|
||||
view : UiSettings -> Model -> Html Msg
|
||||
view settings model =
|
||||
view : Flags -> UiSettings -> Model -> Html Msg
|
||||
view flags settings model =
|
||||
div [ class "home-page ui padded grid" ]
|
||||
[ div
|
||||
[ classList
|
||||
@ -61,7 +63,7 @@ view settings model =
|
||||
]
|
||||
]
|
||||
, div [ class "ui attached fluid segment" ]
|
||||
[ Html.map SearchMenuMsg (Comp.SearchMenu.view settings model.searchMenuModel)
|
||||
[ Html.map SearchMenuMsg (Comp.SearchMenu.view flags settings model.searchMenuModel)
|
||||
]
|
||||
]
|
||||
, div
|
||||
@ -73,7 +75,7 @@ view settings model =
|
||||
, ( "item-card-list", True )
|
||||
]
|
||||
]
|
||||
[ viewSearchBar model
|
||||
[ viewSearchBar flags model
|
||||
, case model.viewMode of
|
||||
Listing ->
|
||||
Html.map ItemCardListMsg
|
||||
@ -115,12 +117,36 @@ view settings model =
|
||||
]
|
||||
|
||||
|
||||
viewSearchBar : Model -> Html Msg
|
||||
viewSearchBar model =
|
||||
viewSearchBar : Flags -> Model -> Html Msg
|
||||
viewSearchBar flags model =
|
||||
let
|
||||
searchTypeItem =
|
||||
Comp.FixedDropdown.Item
|
||||
model.searchType
|
||||
(searchTypeString model.searchType)
|
||||
|
||||
searchInput =
|
||||
case model.searchType of
|
||||
BasicSearch ->
|
||||
model.searchMenuModel.allNameModel
|
||||
|
||||
ContentSearch ->
|
||||
model.searchMenuModel.fulltextModel
|
||||
|
||||
ContentOnlySearch ->
|
||||
Debug.todo "implement"
|
||||
|
||||
searchTypeClass =
|
||||
if flags.config.fullTextSearchEnabled then
|
||||
"compact"
|
||||
|
||||
else
|
||||
"hidden invisible"
|
||||
in
|
||||
div
|
||||
[ classList
|
||||
[ ( "invisible hidden", not model.menuCollapsed )
|
||||
, ( "ui menu container", True )
|
||||
, ( "ui secondary menu container", True )
|
||||
]
|
||||
]
|
||||
[ a
|
||||
@ -141,41 +167,33 @@ viewSearchBar model =
|
||||
]
|
||||
]
|
||||
, div [ class "ui category search item" ]
|
||||
[ div [ class "ui transparent icon input" ]
|
||||
[ div [ class "ui action input" ]
|
||||
[ input
|
||||
[ type_ "text"
|
||||
, placeholder "Basic search…"
|
||||
, placeholder "Search …"
|
||||
, onInput SetBasicSearch
|
||||
, Maybe.map value model.searchMenuModel.allNameModel
|
||||
, Maybe.map value searchInput
|
||||
|> Maybe.withDefault (value "")
|
||||
]
|
||||
[]
|
||||
, i
|
||||
[ classList
|
||||
[ ( "search link icon", not model.searchInProgress )
|
||||
, ( "loading spinner icon", model.searchInProgress )
|
||||
, Html.map SearchTypeMsg
|
||||
(Comp.FixedDropdown.viewStyled searchTypeClass
|
||||
(Just searchTypeItem)
|
||||
model.searchTypeDropdown
|
||||
)
|
||||
, a
|
||||
[ class "ui basic icon button"
|
||||
, href "#"
|
||||
, onClick DoSearch
|
||||
]
|
||||
[ i
|
||||
[ classList
|
||||
[ ( "search link icon", not model.searchInProgress )
|
||||
, ( "loading spinner icon", model.searchInProgress )
|
||||
]
|
||||
]
|
||||
[]
|
||||
]
|
||||
[]
|
||||
]
|
||||
]
|
||||
, div [ class "ui category search item" ]
|
||||
[ div [ class "ui transparent icon input" ]
|
||||
[ input
|
||||
[ type_ "text"
|
||||
, placeholder "Fulltext search…"
|
||||
, onInput SetFulltextSearch
|
||||
, Maybe.map value model.searchMenuModel.fulltextModel
|
||||
|> Maybe.withDefault (value "")
|
||||
]
|
||||
[]
|
||||
, i
|
||||
[ classList
|
||||
[ ( "search link icon", not model.searchInProgress )
|
||||
, ( "loading spinner icon", model.searchInProgress )
|
||||
]
|
||||
]
|
||||
[]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user