mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
@ -38,7 +38,6 @@ import Set exposing (Set)
|
|||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Folder
|
import Util.Folder
|
||||||
import Util.Person
|
import Util.Person
|
||||||
import Util.Tag
|
|
||||||
|
|
||||||
|
|
||||||
view2 : Texts -> Flags -> UiSettings -> Model -> Html Msg
|
view2 : Texts -> Flags -> UiSettings -> Model -> Html Msg
|
||||||
|
@ -70,7 +70,7 @@ searchMenuStyle =
|
|||||||
{ rootClasses = "border-0 "
|
{ rootClasses = "border-0 "
|
||||||
, tabClasses = "border-0 "
|
, tabClasses = "border-0 "
|
||||||
, titleClasses = "py-4 md:py-2 pl-2 bg-blue-50 hover:bg-blue-100 dark:bg-slate-700 dark:hover:bg-opacity-100 dark:hover:bg-slate-600 rounded"
|
, titleClasses = "py-4 md:py-2 pl-2 bg-blue-50 hover:bg-blue-100 dark:bg-slate-700 dark:hover:bg-opacity-100 dark:hover:bg-slate-600 rounded"
|
||||||
, bodyClasses = "mt-1 py-1 pl-2"
|
, bodyClasses = "mt-1 pl-2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
{-
|
||||||
|
Copyright 2020 Eike K. & Contributors
|
||||||
|
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Comp.TagDropdown exposing
|
module Comp.TagDropdown exposing
|
||||||
( Model
|
( Model
|
||||||
, Msg
|
, Msg
|
||||||
@ -20,25 +27,31 @@ import Data.DropdownStyle exposing (DropdownStyle)
|
|||||||
import Data.Flags exposing (Flags)
|
import Data.Flags exposing (Flags)
|
||||||
import Data.TagOrder
|
import Data.TagOrder
|
||||||
import Data.UiSettings exposing (UiSettings)
|
import Data.UiSettings exposing (UiSettings)
|
||||||
import Html exposing (Html)
|
import Html exposing (Html, a, div, i)
|
||||||
|
import Html.Attributes exposing (class, classList, href, title)
|
||||||
|
import Html.Events exposing (onClick)
|
||||||
import Messages.Comp.TagDropdown exposing (Texts)
|
import Messages.Comp.TagDropdown exposing (Texts)
|
||||||
|
import Util.List
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
{ ddm : Comp.Dropdown.Model Tag
|
{ ddm : Comp.Dropdown.Model Tag
|
||||||
, allTags : List Tag
|
, allTags : List Tag
|
||||||
|
, constrainedCat : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type Msg
|
type Msg
|
||||||
= DropdownMsg (Comp.Dropdown.Msg Tag)
|
= DropdownMsg (Comp.Dropdown.Msg Tag)
|
||||||
| GetTagsResp TagList
|
| GetTagsResp TagList
|
||||||
|
| ConstrainCat String
|
||||||
|
|
||||||
|
|
||||||
emptyModel : Model
|
emptyModel : Model
|
||||||
emptyModel =
|
emptyModel =
|
||||||
{ ddm = makeDropdownModel
|
{ ddm = makeDropdownModel
|
||||||
, allTags = []
|
, allTags = []
|
||||||
|
, constrainedCat = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -70,7 +83,7 @@ getSelected model =
|
|||||||
|
|
||||||
setOptions : List Tag -> Msg
|
setOptions : List Tag -> Msg
|
||||||
setOptions tags =
|
setOptions tags =
|
||||||
DropdownMsg (Comp.Dropdown.SetOptions tags)
|
GetTagsResp (TagList 0 tags)
|
||||||
|
|
||||||
|
|
||||||
setSelected : List Tag -> Msg
|
setSelected : List Tag -> Msg
|
||||||
@ -88,6 +101,11 @@ isChangeMsg msg =
|
|||||||
False
|
False
|
||||||
|
|
||||||
|
|
||||||
|
isConstrained : Model -> String -> Bool
|
||||||
|
isConstrained model category =
|
||||||
|
model.constrainedCat == Just category
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- api
|
--- api
|
||||||
|
|
||||||
@ -109,7 +127,17 @@ update msg model =
|
|||||||
( dm, dc ) =
|
( dm, dc ) =
|
||||||
Comp.Dropdown.update lm model.ddm
|
Comp.Dropdown.update lm model.ddm
|
||||||
in
|
in
|
||||||
( { model | ddm = dm }, Cmd.map DropdownMsg dc )
|
( { model
|
||||||
|
| ddm = dm
|
||||||
|
, constrainedCat =
|
||||||
|
if isChangeMsg msg then
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
else
|
||||||
|
model.constrainedCat
|
||||||
|
}
|
||||||
|
, Cmd.map DropdownMsg dc
|
||||||
|
)
|
||||||
|
|
||||||
GetTagsResp list ->
|
GetTagsResp list ->
|
||||||
let
|
let
|
||||||
@ -121,6 +149,24 @@ update msg model =
|
|||||||
in
|
in
|
||||||
update (DropdownMsg ddMsg) newModel
|
update (DropdownMsg ddMsg) newModel
|
||||||
|
|
||||||
|
ConstrainCat cat ->
|
||||||
|
let
|
||||||
|
setOpts tags =
|
||||||
|
DropdownMsg (Comp.Dropdown.SetOptions tags)
|
||||||
|
in
|
||||||
|
if model.constrainedCat == Just cat then
|
||||||
|
update (setOpts model.allTags)
|
||||||
|
{ model | constrainedCat = Nothing }
|
||||||
|
|
||||||
|
else
|
||||||
|
update (setOpts <| List.filter (isCategory cat) model.allTags)
|
||||||
|
{ model | constrainedCat = Just cat }
|
||||||
|
|
||||||
|
|
||||||
|
isCategory : String -> Tag -> Bool
|
||||||
|
isCategory cat tag =
|
||||||
|
tag.category == Just cat || (tag.category == Nothing && cat == "")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- view
|
--- view
|
||||||
@ -132,7 +178,62 @@ view texts settings dds model =
|
|||||||
viewSettings =
|
viewSettings =
|
||||||
tagSettings texts.placeholder dds
|
tagSettings texts.placeholder dds
|
||||||
in
|
in
|
||||||
Html.map DropdownMsg (Comp.Dropdown.view2 viewSettings settings model.ddm)
|
div [ class "flex flex-col" ]
|
||||||
|
[ viewCategorySelect texts settings model
|
||||||
|
, Html.map DropdownMsg (Comp.Dropdown.view2 viewSettings settings model.ddm)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
viewCategorySelect : Texts -> UiSettings -> Model -> Html Msg
|
||||||
|
viewCategorySelect texts settings model =
|
||||||
|
let
|
||||||
|
categories =
|
||||||
|
List.map .category model.allTags
|
||||||
|
|> List.map (Maybe.withDefault "")
|
||||||
|
|> Util.List.distinct
|
||||||
|
|> List.sort
|
||||||
|
|
||||||
|
catFilterLink cat =
|
||||||
|
a
|
||||||
|
[ classList
|
||||||
|
[ ( "opacity-75", not (isConstrained model cat) )
|
||||||
|
]
|
||||||
|
, href "#"
|
||||||
|
, title <|
|
||||||
|
if cat == "" then
|
||||||
|
texts.noCategory
|
||||||
|
|
||||||
|
else
|
||||||
|
cat
|
||||||
|
, onClick (ConstrainCat cat)
|
||||||
|
]
|
||||||
|
[ if cat == "" then
|
||||||
|
i
|
||||||
|
[ class <|
|
||||||
|
if isConstrained model cat then
|
||||||
|
"fa fa-check-circle font-thin"
|
||||||
|
|
||||||
|
else
|
||||||
|
"fa fa-circle font-thin"
|
||||||
|
]
|
||||||
|
[]
|
||||||
|
|
||||||
|
else
|
||||||
|
i
|
||||||
|
[ classList
|
||||||
|
[ ( "fa fa-circle", not (isConstrained model cat) )
|
||||||
|
, ( "fa fa-check-circle", isConstrained model cat )
|
||||||
|
]
|
||||||
|
, class <| Data.UiSettings.catColorFg2 settings cat
|
||||||
|
]
|
||||||
|
[]
|
||||||
|
]
|
||||||
|
in
|
||||||
|
div
|
||||||
|
[ class "flex-wrap space-x-1 text-xl sm:text-sm "
|
||||||
|
, classList [ ( "hidden", not model.ddm.menuOpen ) ]
|
||||||
|
]
|
||||||
|
(List.map catFilterLink categories)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -243,7 +243,7 @@ toStringFg2 color =
|
|||||||
"text-purple-600 dark:text-purple-400"
|
"text-purple-600 dark:text-purple-400"
|
||||||
|
|
||||||
Pink ->
|
Pink ->
|
||||||
"text-pink-600 text:text-pink-400"
|
"text-pink-600 dark:text-pink-400"
|
||||||
|
|
||||||
Brown ->
|
Brown ->
|
||||||
"text-amber-700 dark:text-amber-700"
|
"text-amber-700 dark:text-amber-700"
|
||||||
|
@ -17,6 +17,7 @@ import Messages.Basics
|
|||||||
type alias Texts =
|
type alias Texts =
|
||||||
{ basics : Messages.Basics.Texts
|
{ basics : Messages.Basics.Texts
|
||||||
, placeholder : String
|
, placeholder : String
|
||||||
|
, noCategory : String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ gb : Texts
|
|||||||
gb =
|
gb =
|
||||||
{ basics = Messages.Basics.gb
|
{ basics = Messages.Basics.gb
|
||||||
, placeholder = "Search…"
|
, placeholder = "Search…"
|
||||||
|
, noCategory = "No category"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -31,4 +33,5 @@ de : Texts
|
|||||||
de =
|
de =
|
||||||
{ basics = Messages.Basics.de
|
{ basics = Messages.Basics.de
|
||||||
, placeholder = "Suche…"
|
, placeholder = "Suche…"
|
||||||
|
, noCategory = "Keine Kategorie"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user