mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-06 15:15:58 +00:00
Search by tag category via web ui
This commit is contained in:
parent
070c2b5e5f
commit
a6a6e334d5
@ -41,6 +41,8 @@ import Util.Update
|
|||||||
type alias Model =
|
type alias Model =
|
||||||
{ tagInclModel : Comp.Dropdown.Model Tag
|
{ tagInclModel : Comp.Dropdown.Model Tag
|
||||||
, tagExclModel : Comp.Dropdown.Model Tag
|
, tagExclModel : Comp.Dropdown.Model Tag
|
||||||
|
, tagCatInclModel : Comp.Dropdown.Model String
|
||||||
|
, tagCatExclModel : Comp.Dropdown.Model String
|
||||||
, directionModel : Comp.Dropdown.Model Direction
|
, directionModel : Comp.Dropdown.Model Direction
|
||||||
, orgModel : Comp.Dropdown.Model IdName
|
, orgModel : Comp.Dropdown.Model IdName
|
||||||
, corrPersonModel : Comp.Dropdown.Model IdName
|
, corrPersonModel : Comp.Dropdown.Model IdName
|
||||||
@ -68,6 +70,8 @@ init : Model
|
|||||||
init =
|
init =
|
||||||
{ tagInclModel = Util.Tag.makeDropdownModel
|
{ tagInclModel = Util.Tag.makeDropdownModel
|
||||||
, tagExclModel = Util.Tag.makeDropdownModel
|
, tagExclModel = Util.Tag.makeDropdownModel
|
||||||
|
, tagCatInclModel = Util.Tag.makeCatDropdownModel
|
||||||
|
, tagCatExclModel = Util.Tag.makeCatDropdownModel
|
||||||
, directionModel =
|
, directionModel =
|
||||||
Comp.Dropdown.makeSingleList
|
Comp.Dropdown.makeSingleList
|
||||||
{ makeOption =
|
{ makeOption =
|
||||||
@ -157,6 +161,8 @@ type Msg
|
|||||||
| ToggleNameHelp
|
| ToggleNameHelp
|
||||||
| FolderMsg (Comp.Dropdown.Msg IdName)
|
| FolderMsg (Comp.Dropdown.Msg IdName)
|
||||||
| GetFolderResp (Result Http.Error FolderList)
|
| GetFolderResp (Result Http.Error FolderList)
|
||||||
|
| TagCatIncMsg (Comp.Dropdown.Msg String)
|
||||||
|
| TagCatExcMsg (Comp.Dropdown.Msg String)
|
||||||
|
|
||||||
|
|
||||||
getDirection : Model -> Maybe Direction
|
getDirection : Model -> Maybe Direction
|
||||||
@ -211,6 +217,8 @@ getItemSearch model =
|
|||||||
model.allNameModel
|
model.allNameModel
|
||||||
|> Maybe.map amendWildcards
|
|> Maybe.map amendWildcards
|
||||||
, fullText = model.fulltextModel
|
, fullText = model.fulltextModel
|
||||||
|
, tagCategoriesInclude = Comp.Dropdown.getSelected model.tagCatInclModel
|
||||||
|
, tagCategoriesExclude = Comp.Dropdown.getSelected model.tagCatExclModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -280,11 +288,17 @@ update flags settings msg model =
|
|||||||
let
|
let
|
||||||
tagList =
|
tagList =
|
||||||
Comp.Dropdown.SetOptions tags.items
|
Comp.Dropdown.SetOptions tags.items
|
||||||
|
|
||||||
|
catList =
|
||||||
|
Util.Tag.getCategories tags.items
|
||||||
|
|> Comp.Dropdown.SetOptions
|
||||||
in
|
in
|
||||||
noChange <|
|
noChange <|
|
||||||
Util.Update.andThen1
|
Util.Update.andThen1
|
||||||
[ update flags settings (TagIncMsg tagList) >> .modelCmd
|
[ update flags settings (TagIncMsg tagList) >> .modelCmd
|
||||||
, update flags settings (TagExcMsg tagList) >> .modelCmd
|
, update flags settings (TagExcMsg tagList) >> .modelCmd
|
||||||
|
, update flags settings (TagCatIncMsg catList) >> .modelCmd
|
||||||
|
, update flags settings (TagCatExcMsg catList) >> .modelCmd
|
||||||
]
|
]
|
||||||
model
|
model
|
||||||
|
|
||||||
@ -551,6 +565,28 @@ update flags settings msg model =
|
|||||||
)
|
)
|
||||||
(isDropdownChangeMsg lm)
|
(isDropdownChangeMsg lm)
|
||||||
|
|
||||||
|
TagCatIncMsg m ->
|
||||||
|
let
|
||||||
|
( m2, c2 ) =
|
||||||
|
Comp.Dropdown.update m model.tagCatInclModel
|
||||||
|
in
|
||||||
|
NextState
|
||||||
|
( { model | tagCatInclModel = m2 }
|
||||||
|
, Cmd.map TagCatIncMsg c2
|
||||||
|
)
|
||||||
|
(isDropdownChangeMsg m)
|
||||||
|
|
||||||
|
TagCatExcMsg m ->
|
||||||
|
let
|
||||||
|
( m2, c2 ) =
|
||||||
|
Comp.Dropdown.update m model.tagCatExclModel
|
||||||
|
in
|
||||||
|
NextState
|
||||||
|
( { model | tagCatExclModel = m2 }
|
||||||
|
, Cmd.map TagCatExcMsg c2
|
||||||
|
)
|
||||||
|
(isDropdownChangeMsg m)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- View
|
-- View
|
||||||
@ -645,6 +681,14 @@ view flags settings model =
|
|||||||
[ label [] [ text "Exclude (or)" ]
|
[ label [] [ text "Exclude (or)" ]
|
||||||
, Html.map TagExcMsg (Comp.Dropdown.view settings model.tagExclModel)
|
, Html.map TagExcMsg (Comp.Dropdown.view settings model.tagExclModel)
|
||||||
]
|
]
|
||||||
|
, div [ class "field" ]
|
||||||
|
[ label [] [ text "Category Include (and)" ]
|
||||||
|
, Html.map TagCatIncMsg (Comp.Dropdown.view settings model.tagCatInclModel)
|
||||||
|
]
|
||||||
|
, div [ class "field" ]
|
||||||
|
[ label [] [ text "Category Exclude (or)" ]
|
||||||
|
, Html.map TagCatExcMsg (Comp.Dropdown.view settings model.tagCatExclModel)
|
||||||
|
]
|
||||||
, formHeader (Icons.searchIcon "") "Content"
|
, formHeader (Icons.searchIcon "") "Content"
|
||||||
, div
|
, div
|
||||||
[ classList
|
[ classList
|
||||||
|
@ -18,7 +18,7 @@ import Html exposing (..)
|
|||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Html.Events exposing (onCheck)
|
import Html.Events exposing (onCheck)
|
||||||
import Http
|
import Http
|
||||||
import Util.List
|
import Util.Tag
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
@ -148,8 +148,7 @@ update sett msg model =
|
|||||||
GetTagsResp (Ok tl) ->
|
GetTagsResp (Ok tl) ->
|
||||||
let
|
let
|
||||||
categories =
|
categories =
|
||||||
List.filterMap .category tl.items
|
Util.Tag.getCategories tl.items
|
||||||
|> Util.List.distinct
|
|
||||||
in
|
in
|
||||||
( { model
|
( { model
|
||||||
| tagColorModel =
|
| tagColorModel =
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
module Util.Tag exposing (makeDropdownModel)
|
module Util.Tag exposing
|
||||||
|
( getCategories
|
||||||
|
, makeCatDropdownModel
|
||||||
|
, makeDropdownModel
|
||||||
|
)
|
||||||
|
|
||||||
import Api.Model.Tag exposing (Tag)
|
import Api.Model.Tag exposing (Tag)
|
||||||
import Comp.Dropdown
|
import Comp.Dropdown
|
||||||
import Data.UiSettings
|
import Data.UiSettings
|
||||||
|
import Util.List
|
||||||
|
|
||||||
|
|
||||||
makeDropdownModel : Comp.Dropdown.Model Tag
|
makeDropdownModel : Comp.Dropdown.Model Tag
|
||||||
@ -17,3 +22,20 @@ makeDropdownModel =
|
|||||||
"basic " ++ Data.UiSettings.tagColorString tag settings
|
"basic " ++ Data.UiSettings.tagColorString tag settings
|
||||||
, placeholder = "Choose a tag…"
|
, placeholder = "Choose a tag…"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
makeCatDropdownModel : Comp.Dropdown.Model String
|
||||||
|
makeCatDropdownModel =
|
||||||
|
Comp.Dropdown.makeModel
|
||||||
|
{ multiple = True
|
||||||
|
, searchable = \n -> n > 5
|
||||||
|
, makeOption = \cat -> { value = cat, text = cat, additional = "" }
|
||||||
|
, labelColor = \_ -> \_ -> ""
|
||||||
|
, placeholder = "Choose a tag category…"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getCategories : List Tag -> List String
|
||||||
|
getCategories tags =
|
||||||
|
List.filterMap .category tags
|
||||||
|
|> Util.List.distinct
|
||||||
|
Loading…
x
Reference in New Issue
Block a user