mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-07 07:35:59 +00:00
Enable power search for power users via ui settings
A different search bar is presented if enabled in ui settings that allows to search via the new query language.
This commit is contained in:
parent
168f5a1a98
commit
b4b5acde13
@ -58,6 +58,7 @@ type alias Model =
|
|||||||
, showPatternHelp : Bool
|
, showPatternHelp : Bool
|
||||||
, searchStatsVisible : Bool
|
, searchStatsVisible : Bool
|
||||||
, sideMenuVisible : Bool
|
, sideMenuVisible : Bool
|
||||||
|
, powerSearchEnabled : Bool
|
||||||
, openTabs : Set String
|
, openTabs : Set String
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +152,7 @@ init flags settings =
|
|||||||
, showPatternHelp = False
|
, showPatternHelp = False
|
||||||
, searchStatsVisible = settings.searchStatsVisible
|
, searchStatsVisible = settings.searchStatsVisible
|
||||||
, sideMenuVisible = settings.sideMenuVisible
|
, sideMenuVisible = settings.sideMenuVisible
|
||||||
|
, powerSearchEnabled = settings.powerSearchEnabled
|
||||||
, openTabs = Set.empty
|
, openTabs = Set.empty
|
||||||
}
|
}
|
||||||
, Api.getTags flags "" GetTagsResp
|
, Api.getTags flags "" GetTagsResp
|
||||||
@ -178,6 +180,7 @@ type Msg
|
|||||||
| ToggleSearchStatsVisible
|
| ToggleSearchStatsVisible
|
||||||
| ToggleAkkordionTab String
|
| ToggleAkkordionTab String
|
||||||
| ToggleSideMenuVisible
|
| ToggleSideMenuVisible
|
||||||
|
| TogglePowerSearch
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -460,6 +463,15 @@ update sett msg model =
|
|||||||
, Just { sett | sideMenuVisible = next }
|
, Just { sett | sideMenuVisible = next }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
TogglePowerSearch ->
|
||||||
|
let
|
||||||
|
next =
|
||||||
|
not model.powerSearchEnabled
|
||||||
|
in
|
||||||
|
( { model | powerSearchEnabled = next }
|
||||||
|
, Just { sett | powerSearchEnabled = next }
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- View
|
--- View
|
||||||
@ -763,6 +775,15 @@ settingFormTabs flags _ model =
|
|||||||
, label = "Show basic search statistics by default"
|
, label = "Show basic search statistics by default"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
, div [ class "mb-4" ]
|
||||||
|
[ MB.viewItem <|
|
||||||
|
MB.Checkbox
|
||||||
|
{ id = "uisetting-powersearch-enabled"
|
||||||
|
, value = model.powerSearchEnabled
|
||||||
|
, tagger = \_ -> TogglePowerSearch
|
||||||
|
, label = "Enable power-user search bar"
|
||||||
|
}
|
||||||
|
]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
, { title = "Item Cards"
|
, { title = "Item Cards"
|
||||||
|
@ -52,6 +52,7 @@ type ItemQuery
|
|||||||
| ItemName AttrMatch String
|
| ItemName AttrMatch String
|
||||||
| AllNames String
|
| AllNames String
|
||||||
| Contents String
|
| Contents String
|
||||||
|
| Fragment String
|
||||||
|
|
||||||
|
|
||||||
and : List (Maybe ItemQuery) -> Maybe ItemQuery
|
and : List (Maybe ItemQuery) -> Maybe ItemQuery
|
||||||
@ -176,6 +177,9 @@ render q =
|
|||||||
Contents str ->
|
Contents str ->
|
||||||
"content:" ++ quoteStr str
|
"content:" ++ quoteStr str
|
||||||
|
|
||||||
|
Fragment str ->
|
||||||
|
"(& " ++ str ++ " )"
|
||||||
|
|
||||||
|
|
||||||
attrMatch : AttrMatch -> String
|
attrMatch : AttrMatch -> String
|
||||||
attrMatch am =
|
attrMatch am =
|
||||||
|
@ -62,6 +62,7 @@ type alias StoredUiSettings =
|
|||||||
, cardPreviewFullWidth : Bool
|
, cardPreviewFullWidth : Bool
|
||||||
, uiTheme : Maybe String
|
, uiTheme : Maybe String
|
||||||
, sideMenuVisible : Bool
|
, sideMenuVisible : Bool
|
||||||
|
, powerSearchEnabled : Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -92,6 +93,7 @@ type alias UiSettings =
|
|||||||
, cardPreviewFullWidth : Bool
|
, cardPreviewFullWidth : Bool
|
||||||
, uiTheme : UiTheme
|
, uiTheme : UiTheme
|
||||||
, sideMenuVisible : Bool
|
, sideMenuVisible : Bool
|
||||||
|
, powerSearchEnabled : Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -162,6 +164,7 @@ defaults =
|
|||||||
, cardPreviewFullWidth = False
|
, cardPreviewFullWidth = False
|
||||||
, uiTheme = Data.UiTheme.Light
|
, uiTheme = Data.UiTheme.Light
|
||||||
, sideMenuVisible = True
|
, sideMenuVisible = True
|
||||||
|
, powerSearchEnabled = False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -213,6 +216,7 @@ merge given fallback =
|
|||||||
Maybe.andThen Data.UiTheme.fromString given.uiTheme
|
Maybe.andThen Data.UiTheme.fromString given.uiTheme
|
||||||
|> Maybe.withDefault fallback.uiTheme
|
|> Maybe.withDefault fallback.uiTheme
|
||||||
, sideMenuVisible = given.sideMenuVisible
|
, sideMenuVisible = given.sideMenuVisible
|
||||||
|
, powerSearchEnabled = given.powerSearchEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -249,6 +253,7 @@ toStoredUiSettings settings =
|
|||||||
, cardPreviewFullWidth = settings.cardPreviewFullWidth
|
, cardPreviewFullWidth = settings.cardPreviewFullWidth
|
||||||
, uiTheme = Just (Data.UiTheme.toString settings.uiTheme)
|
, uiTheme = Just (Data.UiTheme.toString settings.uiTheme)
|
||||||
, sideMenuVisible = settings.sideMenuVisible
|
, sideMenuVisible = settings.sideMenuVisible
|
||||||
|
, powerSearchEnabled = settings.powerSearchEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ type alias Model =
|
|||||||
, dragDropData : DD.DragDropData
|
, dragDropData : DD.DragDropData
|
||||||
, scrollToCard : Maybe String
|
, scrollToCard : Maybe String
|
||||||
, searchStats : SearchStats
|
, searchStats : SearchStats
|
||||||
|
, powerSearchInput : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -121,6 +122,7 @@ init flags viewMode =
|
|||||||
, scrollToCard = Nothing
|
, scrollToCard = Nothing
|
||||||
, viewMode = viewMode
|
, viewMode = viewMode
|
||||||
, searchStats = Api.Model.SearchStats.empty
|
, searchStats = Api.Model.SearchStats.empty
|
||||||
|
, powerSearchInput = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -194,6 +196,8 @@ type Msg
|
|||||||
| SetLinkTarget LinkTarget
|
| SetLinkTarget LinkTarget
|
||||||
| SearchStatsResp (Result Http.Error SearchStats)
|
| SearchStatsResp (Result Http.Error SearchStats)
|
||||||
| TogglePreviewFullWidth
|
| TogglePreviewFullWidth
|
||||||
|
| SetPowerSearch String
|
||||||
|
| KeyUpPowerSearchbarMsg (Maybe KeyCode)
|
||||||
|
|
||||||
|
|
||||||
type SearchType
|
type SearchType
|
||||||
@ -240,8 +244,11 @@ doSearchDefaultCmd : SearchParam -> Model -> Cmd Msg
|
|||||||
doSearchDefaultCmd param model =
|
doSearchDefaultCmd param model =
|
||||||
let
|
let
|
||||||
smask =
|
smask =
|
||||||
Q.request
|
Q.request <|
|
||||||
(Comp.SearchMenu.getItemQuery model.searchMenuModel)
|
Q.and
|
||||||
|
[ Comp.SearchMenu.getItemQuery model.searchMenuModel
|
||||||
|
, Maybe.map Q.Fragment model.powerSearchInput
|
||||||
|
]
|
||||||
|
|
||||||
mask =
|
mask =
|
||||||
{ smask
|
{ smask
|
||||||
|
@ -54,7 +54,7 @@ update mId key flags settings msg model =
|
|||||||
ResetSearch ->
|
ResetSearch ->
|
||||||
let
|
let
|
||||||
nm =
|
nm =
|
||||||
{ model | searchOffset = 0 }
|
{ model | searchOffset = 0, powerSearchInput = Nothing }
|
||||||
in
|
in
|
||||||
update mId key flags settings (SearchMenuMsg Comp.SearchMenu.ResetForm) nm
|
update mId key flags settings (SearchMenuMsg Comp.SearchMenu.ResetForm) nm
|
||||||
|
|
||||||
@ -580,6 +580,15 @@ update mId key flags settings msg model =
|
|||||||
in
|
in
|
||||||
noSub ( model, cmd )
|
noSub ( model, cmd )
|
||||||
|
|
||||||
|
SetPowerSearch str ->
|
||||||
|
noSub ( { model | powerSearchInput = Util.Maybe.fromString str }, Cmd.none )
|
||||||
|
|
||||||
|
KeyUpPowerSearchbarMsg (Just Enter) ->
|
||||||
|
update mId key flags settings (DoSearch model.searchTypeDropdownValue) model
|
||||||
|
|
||||||
|
KeyUpPowerSearchbarMsg _ ->
|
||||||
|
withSub ( model, Cmd.none )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Helpers
|
--- Helpers
|
||||||
|
@ -92,7 +92,7 @@ itemsBar flags settings model =
|
|||||||
|
|
||||||
|
|
||||||
defaultMenuBar : Flags -> UiSettings -> Model -> Html Msg
|
defaultMenuBar : Flags -> UiSettings -> Model -> Html Msg
|
||||||
defaultMenuBar flags settings model =
|
defaultMenuBar _ settings model =
|
||||||
let
|
let
|
||||||
btnStyle =
|
btnStyle =
|
||||||
S.secondaryBasicButton ++ " text-sm"
|
S.secondaryBasicButton ++ " text-sm"
|
||||||
@ -100,35 +100,8 @@ defaultMenuBar flags settings model =
|
|||||||
searchInput =
|
searchInput =
|
||||||
Comp.SearchMenu.textSearchString
|
Comp.SearchMenu.textSearchString
|
||||||
model.searchMenuModel.textSearchModel
|
model.searchMenuModel.textSearchModel
|
||||||
in
|
|
||||||
MB.view
|
|
||||||
{ end =
|
|
||||||
[ MB.CustomElement <|
|
|
||||||
B.secondaryBasicButton
|
|
||||||
{ label = ""
|
|
||||||
, icon =
|
|
||||||
if model.searchInProgress then
|
|
||||||
"fa fa-sync animate-spin"
|
|
||||||
|
|
||||||
else
|
simpleSearchBar =
|
||||||
"fa fa-sync"
|
|
||||||
, disabled = model.searchInProgress
|
|
||||||
, handler = onClick ResetSearch
|
|
||||||
, attrs = [ href "#" ]
|
|
||||||
}
|
|
||||||
, MB.CustomButton
|
|
||||||
{ tagger = ToggleSelectView
|
|
||||||
, label = ""
|
|
||||||
, icon = Just "fa fa-tasks"
|
|
||||||
, title = "Select Mode"
|
|
||||||
, inputClass =
|
|
||||||
[ ( btnStyle, True )
|
|
||||||
, ( "bg-gray-200 dark:bg-bluegray-600", selectActive model )
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
, start =
|
|
||||||
[ MB.CustomElement <|
|
|
||||||
div
|
div
|
||||||
[ class "relative flex flex-row" ]
|
[ class "relative flex flex-row" ]
|
||||||
[ input
|
[ input
|
||||||
@ -158,6 +131,56 @@ defaultMenuBar flags settings model =
|
|||||||
[ i [ class "fa fa-exchange-alt" ] []
|
[ i [ class "fa fa-exchange-alt" ] []
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
powerSearchBar =
|
||||||
|
div
|
||||||
|
[ class "relative flex flex-grow flex-row" ]
|
||||||
|
[ input
|
||||||
|
[ type_ "text"
|
||||||
|
, placeholder "Search query …"
|
||||||
|
, onInput SetPowerSearch
|
||||||
|
, Util.Html.onKeyUpCode KeyUpPowerSearchbarMsg
|
||||||
|
, Maybe.map value model.powerSearchInput
|
||||||
|
|> Maybe.withDefault (value "")
|
||||||
|
, class S.textInput
|
||||||
|
, class "text-sm "
|
||||||
|
]
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
in
|
||||||
|
MB.view
|
||||||
|
{ end =
|
||||||
|
[ MB.CustomElement <|
|
||||||
|
B.secondaryBasicButton
|
||||||
|
{ label = ""
|
||||||
|
, icon =
|
||||||
|
if model.searchInProgress then
|
||||||
|
"fa fa-sync animate-spin"
|
||||||
|
|
||||||
|
else
|
||||||
|
"fa fa-sync"
|
||||||
|
, disabled = model.searchInProgress
|
||||||
|
, handler = onClick ResetSearch
|
||||||
|
, attrs = [ href "#" ]
|
||||||
|
}
|
||||||
|
, MB.CustomButton
|
||||||
|
{ tagger = ToggleSelectView
|
||||||
|
, label = ""
|
||||||
|
, icon = Just "fa fa-tasks"
|
||||||
|
, title = "Select Mode"
|
||||||
|
, inputClass =
|
||||||
|
[ ( btnStyle, True )
|
||||||
|
, ( "bg-gray-200 dark:bg-bluegray-600", selectActive model )
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
, start =
|
||||||
|
[ MB.CustomElement <|
|
||||||
|
if settings.powerSearchEnabled then
|
||||||
|
powerSearchBar
|
||||||
|
|
||||||
|
else
|
||||||
|
simpleSearchBar
|
||||||
, MB.CustomButton
|
, MB.CustomButton
|
||||||
{ tagger = TogglePreviewFullWidth
|
{ tagger = TogglePreviewFullWidth
|
||||||
, label = ""
|
, label = ""
|
||||||
@ -271,7 +294,7 @@ searchStats _ settings model =
|
|||||||
|
|
||||||
|
|
||||||
itemCardList : Flags -> UiSettings -> Model -> List (Html Msg)
|
itemCardList : Flags -> UiSettings -> Model -> List (Html Msg)
|
||||||
itemCardList flags settings model =
|
itemCardList _ settings model =
|
||||||
let
|
let
|
||||||
itemViewCfg =
|
itemViewCfg =
|
||||||
case model.viewMode of
|
case model.viewMode of
|
||||||
|
Loading…
x
Reference in New Issue
Block a user