mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Select bookmarks in search menu
This commit is contained in:
@ -2334,10 +2334,16 @@ getBookmarks flags receive =
|
|||||||
user =
|
user =
|
||||||
getBookmarksTask flags Data.BookmarkedQuery.User
|
getBookmarksTask flags Data.BookmarkedQuery.User
|
||||||
|
|
||||||
combine bc bu =
|
shares =
|
||||||
AllBookmarks bc bu
|
getSharesTask flags "" False
|
||||||
|
|
||||||
|
activeShare s =
|
||||||
|
s.enabled && s.name /= Nothing
|
||||||
|
|
||||||
|
combine bc bu bs =
|
||||||
|
AllBookmarks bc bu (List.filter activeShare bs.items)
|
||||||
in
|
in
|
||||||
Task.map2 combine coll user
|
Task.map3 combine coll user shares
|
||||||
|> Task.attempt receive
|
|> Task.attempt receive
|
||||||
|
|
||||||
|
|
||||||
@ -2436,10 +2442,12 @@ disableOtp flags otp receive =
|
|||||||
--- Share
|
--- Share
|
||||||
|
|
||||||
|
|
||||||
getShares : Flags -> String -> Bool -> (Result Http.Error ShareList -> msg) -> Cmd msg
|
getSharesTask : Flags -> String -> Bool -> Task.Task Http.Error ShareList
|
||||||
getShares flags query owning receive =
|
getSharesTask flags query owning =
|
||||||
Http2.authGet
|
Http2.authTask
|
||||||
{ url =
|
{ method =
|
||||||
|
"GET"
|
||||||
|
, url =
|
||||||
flags.config.baseUrl
|
flags.config.baseUrl
|
||||||
++ "/api/v1/sec/share?q="
|
++ "/api/v1/sec/share?q="
|
||||||
++ Url.percentEncode query
|
++ Url.percentEncode query
|
||||||
@ -2450,10 +2458,18 @@ getShares flags query owning receive =
|
|||||||
""
|
""
|
||||||
)
|
)
|
||||||
, account = getAccount flags
|
, account = getAccount flags
|
||||||
, expect = Http.expectJson receive Api.Model.ShareList.decoder
|
, body = Http.emptyBody
|
||||||
|
, resolver = Http2.jsonResolver Api.Model.ShareList.decoder
|
||||||
|
, headers = []
|
||||||
|
, timeout = Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
getShares : Flags -> String -> Bool -> (Result Http.Error ShareList -> msg) -> Cmd msg
|
||||||
|
getShares flags query owning receive =
|
||||||
|
getSharesTask flags query owning |> Task.attempt receive
|
||||||
|
|
||||||
|
|
||||||
getShare : Flags -> String -> (Result Http.Error ShareDetail -> msg) -> Cmd msg
|
getShare : Flags -> String -> (Result Http.Error ShareDetail -> msg) -> Cmd msg
|
||||||
getShare flags id receive =
|
getShare flags id receive =
|
||||||
Http2.authGet
|
Http2.authGet
|
||||||
|
202
modules/webapp/src/main/elm/Comp/BookmarkChooser.elm
Normal file
202
modules/webapp/src/main/elm/Comp/BookmarkChooser.elm
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
module Comp.BookmarkChooser exposing
|
||||||
|
( Model
|
||||||
|
, Msg
|
||||||
|
, Selection
|
||||||
|
, emptySelection
|
||||||
|
, getQueries
|
||||||
|
, init
|
||||||
|
, isEmpty
|
||||||
|
, isEmptySelection
|
||||||
|
, update
|
||||||
|
, view
|
||||||
|
)
|
||||||
|
|
||||||
|
import Api.Model.ShareDetail exposing (ShareDetail)
|
||||||
|
import Data.BookmarkedQuery exposing (AllBookmarks, BookmarkedQuery)
|
||||||
|
import Data.Icons as Icons
|
||||||
|
import Html exposing (Html, a, div, i, span, text)
|
||||||
|
import Html.Attributes exposing (class, classList, href)
|
||||||
|
import Html.Events exposing (onClick)
|
||||||
|
import Messages.Comp.BookmarkChooser exposing (Texts)
|
||||||
|
import Set exposing (Set)
|
||||||
|
|
||||||
|
|
||||||
|
type alias Model =
|
||||||
|
{ all : AllBookmarks
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
init : AllBookmarks -> Model
|
||||||
|
init all =
|
||||||
|
{ all = all
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
isEmpty : Model -> Bool
|
||||||
|
isEmpty model =
|
||||||
|
model.all == Data.BookmarkedQuery.allBookmarksEmpty
|
||||||
|
|
||||||
|
|
||||||
|
type alias Selection =
|
||||||
|
{ user : Set String
|
||||||
|
, collective : Set String
|
||||||
|
, shares : Set String
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
emptySelection : Selection
|
||||||
|
emptySelection =
|
||||||
|
{ user = Set.empty, collective = Set.empty, shares = Set.empty }
|
||||||
|
|
||||||
|
|
||||||
|
isEmptySelection : Selection -> Bool
|
||||||
|
isEmptySelection sel =
|
||||||
|
sel == emptySelection
|
||||||
|
|
||||||
|
|
||||||
|
type Kind
|
||||||
|
= User
|
||||||
|
| Collective
|
||||||
|
| Share
|
||||||
|
|
||||||
|
|
||||||
|
type Msg
|
||||||
|
= Toggle Kind String
|
||||||
|
|
||||||
|
|
||||||
|
getQueries : Model -> Selection -> List BookmarkedQuery
|
||||||
|
getQueries model sel =
|
||||||
|
let
|
||||||
|
member set bm =
|
||||||
|
Set.member bm.name set
|
||||||
|
|
||||||
|
filterBookmarks f bms =
|
||||||
|
Data.BookmarkedQuery.filter f bms |> Data.BookmarkedQuery.map identity
|
||||||
|
in
|
||||||
|
List.concat
|
||||||
|
[ filterBookmarks (member sel.user) model.all.user
|
||||||
|
, filterBookmarks (member sel.collective) model.all.collective
|
||||||
|
, List.map shareToBookmark model.all.shares
|
||||||
|
|> List.filter (member sel.shares)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Update
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> Model -> Selection -> ( Model, Selection )
|
||||||
|
update msg model current =
|
||||||
|
let
|
||||||
|
toggle name set =
|
||||||
|
if Set.member name set then
|
||||||
|
Set.remove name set
|
||||||
|
|
||||||
|
else
|
||||||
|
Set.insert name set
|
||||||
|
in
|
||||||
|
case msg of
|
||||||
|
Toggle kind name ->
|
||||||
|
case kind of
|
||||||
|
User ->
|
||||||
|
( model, { current | user = toggle name current.user } )
|
||||||
|
|
||||||
|
Collective ->
|
||||||
|
( model, { current | collective = toggle name current.collective } )
|
||||||
|
|
||||||
|
Share ->
|
||||||
|
( model, { current | shares = toggle name current.shares } )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- View
|
||||||
|
|
||||||
|
|
||||||
|
view : Texts -> Model -> Selection -> Html Msg
|
||||||
|
view texts model selection =
|
||||||
|
div [ class "flex flex-col" ]
|
||||||
|
[ userBookmarks texts model selection
|
||||||
|
, collBookmarks texts model selection
|
||||||
|
, shares texts model selection
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
userBookmarks : Texts -> Model -> Selection -> Html Msg
|
||||||
|
userBookmarks texts model sel =
|
||||||
|
div
|
||||||
|
[ class "mb-2"
|
||||||
|
, classList [ ( "hidden", Data.BookmarkedQuery.emptyBookmarks == model.all.user ) ]
|
||||||
|
]
|
||||||
|
[ div [ class " text-sm font-semibold py-0.5 " ]
|
||||||
|
[ text texts.userLabel
|
||||||
|
]
|
||||||
|
, div [ class "flex flex-col space-y-2 md:space-y-1" ]
|
||||||
|
(Data.BookmarkedQuery.map (mkItem "fa fa-bookmark" sel User) model.all.user)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
collBookmarks : Texts -> Model -> Selection -> Html Msg
|
||||||
|
collBookmarks texts model sel =
|
||||||
|
div
|
||||||
|
[ class "mb-2"
|
||||||
|
, classList [ ( "hidden", Data.BookmarkedQuery.emptyBookmarks == model.all.collective ) ]
|
||||||
|
]
|
||||||
|
[ div [ class " text-sm font-semibold py-0.5 " ]
|
||||||
|
[ text texts.collectiveLabel
|
||||||
|
]
|
||||||
|
, div [ class "flex flex-col space-y-2 md:space-y-1" ]
|
||||||
|
(Data.BookmarkedQuery.map (mkItem "fa fa-bookmark font-light" sel Collective) model.all.collective)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
shares : Texts -> Model -> Selection -> Html Msg
|
||||||
|
shares texts model sel =
|
||||||
|
let
|
||||||
|
bms =
|
||||||
|
List.map shareToBookmark model.all.shares
|
||||||
|
in
|
||||||
|
div
|
||||||
|
[ class ""
|
||||||
|
, classList [ ( "hidden", List.isEmpty bms ) ]
|
||||||
|
]
|
||||||
|
[ div [ class " text-sm font-semibold py-0.5 " ]
|
||||||
|
[ text texts.shareLabel
|
||||||
|
]
|
||||||
|
, div [ class "flex flex-col space-y-2 md:space-y-1" ]
|
||||||
|
(List.map (mkItem Icons.share sel Share) bms)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
mkItem : String -> Selection -> Kind -> BookmarkedQuery -> Html Msg
|
||||||
|
mkItem icon sel kind bm =
|
||||||
|
a
|
||||||
|
[ class "flex flex-row items-center rounded px-1 py-1 hover:bg-blue-100 dark:hover:bg-slate-600"
|
||||||
|
, href "#"
|
||||||
|
, onClick (Toggle kind bm.name)
|
||||||
|
]
|
||||||
|
[ if isSelected sel kind bm.name then
|
||||||
|
i [ class "fa fa-check" ] []
|
||||||
|
|
||||||
|
else
|
||||||
|
i [ class icon ] []
|
||||||
|
, span [ class "ml-2" ] [ text bm.name ]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
isSelected : Selection -> Kind -> String -> Bool
|
||||||
|
isSelected sel kind name =
|
||||||
|
Set.member name <|
|
||||||
|
case kind of
|
||||||
|
User ->
|
||||||
|
sel.user
|
||||||
|
|
||||||
|
Collective ->
|
||||||
|
sel.collective
|
||||||
|
|
||||||
|
Share ->
|
||||||
|
sel.shares
|
||||||
|
|
||||||
|
|
||||||
|
shareToBookmark : ShareDetail -> BookmarkedQuery
|
||||||
|
shareToBookmark share =
|
||||||
|
BookmarkedQuery (Maybe.withDefault "-" share.name) share.query
|
@ -16,6 +16,7 @@ module Comp.SearchMenu exposing
|
|||||||
, isFulltextSearch
|
, isFulltextSearch
|
||||||
, isNamesSearch
|
, isNamesSearch
|
||||||
, linkTargetMsg
|
, linkTargetMsg
|
||||||
|
, refreshBookmarks
|
||||||
, setFromStats
|
, setFromStats
|
||||||
, textSearchString
|
, textSearchString
|
||||||
, update
|
, update
|
||||||
@ -33,6 +34,7 @@ import Api.Model.ItemQuery exposing (ItemQuery)
|
|||||||
import Api.Model.PersonList exposing (PersonList)
|
import Api.Model.PersonList exposing (PersonList)
|
||||||
import Api.Model.ReferenceList exposing (ReferenceList)
|
import Api.Model.ReferenceList exposing (ReferenceList)
|
||||||
import Api.Model.SearchStats exposing (SearchStats)
|
import Api.Model.SearchStats exposing (SearchStats)
|
||||||
|
import Comp.BookmarkChooser
|
||||||
import Comp.CustomFieldMultiInput
|
import Comp.CustomFieldMultiInput
|
||||||
import Comp.DatePicker
|
import Comp.DatePicker
|
||||||
import Comp.Dropdown exposing (isDropdownChangeMsg)
|
import Comp.Dropdown exposing (isDropdownChangeMsg)
|
||||||
@ -41,6 +43,7 @@ import Comp.LinkTarget exposing (LinkTarget)
|
|||||||
import Comp.MenuBar as MB
|
import Comp.MenuBar as MB
|
||||||
import Comp.Tabs
|
import Comp.Tabs
|
||||||
import Comp.TagSelect
|
import Comp.TagSelect
|
||||||
|
import Data.BookmarkedQuery exposing (AllBookmarks)
|
||||||
import Data.CustomFieldChange exposing (CustomFieldValueCollect)
|
import Data.CustomFieldChange exposing (CustomFieldValueCollect)
|
||||||
import Data.Direction exposing (Direction)
|
import Data.Direction exposing (Direction)
|
||||||
import Data.DropdownStyle as DS
|
import Data.DropdownStyle as DS
|
||||||
@ -96,6 +99,8 @@ type alias Model =
|
|||||||
, customFieldModel : Comp.CustomFieldMultiInput.Model
|
, customFieldModel : Comp.CustomFieldMultiInput.Model
|
||||||
, customValues : CustomFieldValueCollect
|
, customValues : CustomFieldValueCollect
|
||||||
, sourceModel : Maybe String
|
, sourceModel : Maybe String
|
||||||
|
, allBookmarks : Comp.BookmarkChooser.Model
|
||||||
|
, selectedBookmarks : Comp.BookmarkChooser.Selection
|
||||||
, openTabs : Set String
|
, openTabs : Set String
|
||||||
, searchMode : SearchMode
|
, searchMode : SearchMode
|
||||||
}
|
}
|
||||||
@ -141,6 +146,8 @@ init flags =
|
|||||||
, customFieldModel = Comp.CustomFieldMultiInput.initWith []
|
, customFieldModel = Comp.CustomFieldMultiInput.initWith []
|
||||||
, customValues = Data.CustomFieldChange.emptyCollect
|
, customValues = Data.CustomFieldChange.emptyCollect
|
||||||
, sourceModel = Nothing
|
, sourceModel = Nothing
|
||||||
|
, allBookmarks = Comp.BookmarkChooser.init Data.BookmarkedQuery.allBookmarksEmpty
|
||||||
|
, selectedBookmarks = Comp.BookmarkChooser.emptySelection
|
||||||
, openTabs = Set.fromList [ "Tags", "Inbox" ]
|
, openTabs = Set.fromList [ "Tags", "Inbox" ]
|
||||||
, searchMode = Data.SearchMode.Normal
|
, searchMode = Data.SearchMode.Normal
|
||||||
}
|
}
|
||||||
@ -243,6 +250,10 @@ getItemQuery model =
|
|||||||
|
|
||||||
textSearch =
|
textSearch =
|
||||||
textSearchValue model.textSearchModel
|
textSearchValue model.textSearchModel
|
||||||
|
|
||||||
|
bookmarks =
|
||||||
|
List.map .query (Comp.BookmarkChooser.getQueries model.allBookmarks model.selectedBookmarks)
|
||||||
|
|> List.map Q.Fragment
|
||||||
in
|
in
|
||||||
Q.and
|
Q.and
|
||||||
[ when model.inboxCheckbox (Q.Inbox True)
|
[ when model.inboxCheckbox (Q.Inbox True)
|
||||||
@ -289,6 +300,7 @@ getItemQuery model =
|
|||||||
|> Maybe.map Q.Dir
|
|> Maybe.map Q.Dir
|
||||||
, textSearch.fullText
|
, textSearch.fullText
|
||||||
|> Maybe.map Q.Contents
|
|> Maybe.map Q.Contents
|
||||||
|
, whenNotEmpty bookmarks Q.And
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@ -333,6 +345,7 @@ resetModel model =
|
|||||||
model.customFieldModel
|
model.customFieldModel
|
||||||
, customValues = Data.CustomFieldChange.emptyCollect
|
, customValues = Data.CustomFieldChange.emptyCollect
|
||||||
, sourceModel = Nothing
|
, sourceModel = Nothing
|
||||||
|
, selectedBookmarks = Comp.BookmarkChooser.emptySelection
|
||||||
, searchMode = Data.SearchMode.Normal
|
, searchMode = Data.SearchMode.Normal
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,6 +393,8 @@ type Msg
|
|||||||
| GetAllTagsResp (Result Http.Error SearchStats)
|
| GetAllTagsResp (Result Http.Error SearchStats)
|
||||||
| ToggleAkkordionTab String
|
| ToggleAkkordionTab String
|
||||||
| ToggleOpenAllAkkordionTabs
|
| ToggleOpenAllAkkordionTabs
|
||||||
|
| AllBookmarksResp (Result Http.Error AllBookmarks)
|
||||||
|
| SelectBookmarkMsg Comp.BookmarkChooser.Msg
|
||||||
|
|
||||||
|
|
||||||
setFromStats : SearchStats -> Msg
|
setFromStats : SearchStats -> Msg
|
||||||
@ -426,6 +441,11 @@ type alias NextState =
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
refreshBookmarks : Flags -> Cmd Msg
|
||||||
|
refreshBookmarks flags =
|
||||||
|
Api.getBookmarks flags AllBookmarksResp
|
||||||
|
|
||||||
|
|
||||||
update : Flags -> UiSettings -> Msg -> Model -> NextState
|
update : Flags -> UiSettings -> Msg -> Model -> NextState
|
||||||
update =
|
update =
|
||||||
updateDrop DD.init
|
updateDrop DD.init
|
||||||
@ -488,6 +508,7 @@ updateDrop ddm flags settings msg model =
|
|||||||
, Api.getPersons flags "" Data.PersonOrder.NameAsc GetPersonResp
|
, Api.getPersons flags "" Data.PersonOrder.NameAsc GetPersonResp
|
||||||
, Cmd.map CustomFieldMsg (Comp.CustomFieldMultiInput.initCmd flags)
|
, Cmd.map CustomFieldMsg (Comp.CustomFieldMultiInput.initCmd flags)
|
||||||
, cdp
|
, cdp
|
||||||
|
, Api.getBookmarks flags AllBookmarksResp
|
||||||
]
|
]
|
||||||
, stateChange = False
|
, stateChange = False
|
||||||
, dragDrop = DD.DragDropData ddm Nothing
|
, dragDrop = DD.DragDropData ddm Nothing
|
||||||
@ -1040,6 +1061,31 @@ updateDrop ddm flags settings msg model =
|
|||||||
, dragDrop = DD.DragDropData ddm Nothing
|
, dragDrop = DD.DragDropData ddm Nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AllBookmarksResp (Ok bm) ->
|
||||||
|
{ model = { model | allBookmarks = Comp.BookmarkChooser.init bm }
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = False
|
||||||
|
, dragDrop = DD.DragDropData ddm Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
AllBookmarksResp (Err err) ->
|
||||||
|
{ model = model
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = False
|
||||||
|
, dragDrop = DD.DragDropData ddm Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectBookmarkMsg lm ->
|
||||||
|
let
|
||||||
|
( next, sel ) =
|
||||||
|
Comp.BookmarkChooser.update lm model.allBookmarks model.selectedBookmarks
|
||||||
|
in
|
||||||
|
{ model = { model | allBookmarks = next, selectedBookmarks = sel }
|
||||||
|
, cmd = Cmd.none
|
||||||
|
, stateChange = sel /= model.selectedBookmarks
|
||||||
|
, dragDrop = DD.DragDropData ddm Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- View2
|
--- View2
|
||||||
@ -1064,6 +1110,7 @@ viewDrop2 texts ddd flags cfg settings model =
|
|||||||
|
|
||||||
type SearchTab
|
type SearchTab
|
||||||
= TabInbox
|
= TabInbox
|
||||||
|
| TabBookmarks
|
||||||
| TabTags
|
| TabTags
|
||||||
| TabTagCategories
|
| TabTagCategories
|
||||||
| TabFolder
|
| TabFolder
|
||||||
@ -1080,6 +1127,7 @@ type SearchTab
|
|||||||
allTabs : List SearchTab
|
allTabs : List SearchTab
|
||||||
allTabs =
|
allTabs =
|
||||||
[ TabInbox
|
[ TabInbox
|
||||||
|
, TabBookmarks
|
||||||
, TabTags
|
, TabTags
|
||||||
, TabTagCategories
|
, TabTagCategories
|
||||||
, TabFolder
|
, TabFolder
|
||||||
@ -1100,6 +1148,9 @@ tabName tab =
|
|||||||
TabInbox ->
|
TabInbox ->
|
||||||
"inbox"
|
"inbox"
|
||||||
|
|
||||||
|
TabBookmarks ->
|
||||||
|
"bookmarks"
|
||||||
|
|
||||||
TabTags ->
|
TabTags ->
|
||||||
"tags"
|
"tags"
|
||||||
|
|
||||||
@ -1140,6 +1191,9 @@ findTab tab =
|
|||||||
"inbox" ->
|
"inbox" ->
|
||||||
Just TabInbox
|
Just TabInbox
|
||||||
|
|
||||||
|
"bookmarks" ->
|
||||||
|
Just TabBookmarks
|
||||||
|
|
||||||
"tags" ->
|
"tags" ->
|
||||||
Just TabTags
|
Just TabTags
|
||||||
|
|
||||||
@ -1215,6 +1269,16 @@ tabLook settings model tab =
|
|||||||
TabInbox ->
|
TabInbox ->
|
||||||
activeWhen model.inboxCheckbox
|
activeWhen model.inboxCheckbox
|
||||||
|
|
||||||
|
TabBookmarks ->
|
||||||
|
if Comp.BookmarkChooser.isEmpty model.allBookmarks then
|
||||||
|
Comp.Tabs.Hidden
|
||||||
|
|
||||||
|
else if not <| Comp.BookmarkChooser.isEmptySelection model.selectedBookmarks then
|
||||||
|
Comp.Tabs.Active
|
||||||
|
|
||||||
|
else
|
||||||
|
Comp.Tabs.Normal
|
||||||
|
|
||||||
TabTags ->
|
TabTags ->
|
||||||
hiddenOr [ Data.Fields.Tag ]
|
hiddenOr [ Data.Fields.Tag ]
|
||||||
(activeWhenNotEmpty model.tagSelection.includeTags model.tagSelection.excludeTags)
|
(activeWhenNotEmpty model.tagSelection.includeTags model.tagSelection.excludeTags)
|
||||||
@ -1329,52 +1393,15 @@ searchTabs texts ddd flags settings model =
|
|||||||
, label = texts.inbox
|
, label = texts.inbox
|
||||||
, tagger = \_ -> ToggleInbox
|
, tagger = \_ -> ToggleInbox
|
||||||
}
|
}
|
||||||
, div [ class "mt-2 hidden" ]
|
|
||||||
[ label [ class S.inputLabel ]
|
|
||||||
[ text
|
|
||||||
(case model.textSearchModel of
|
|
||||||
Fulltext _ ->
|
|
||||||
texts.fulltextSearch
|
|
||||||
|
|
||||||
Names _ ->
|
|
||||||
texts.searchInNames
|
|
||||||
)
|
|
||||||
, a
|
|
||||||
[ classList
|
|
||||||
[ ( "hidden", not flags.config.fullTextSearchEnabled )
|
|
||||||
]
|
|
||||||
, class "float-right"
|
|
||||||
, class S.link
|
|
||||||
, href "#"
|
|
||||||
, onClick SwapTextSearch
|
|
||||||
, title texts.switchSearchModes
|
|
||||||
]
|
|
||||||
[ i [ class "fa fa-exchange-alt" ] []
|
|
||||||
]
|
|
||||||
]
|
|
||||||
, input
|
|
||||||
[ type_ "text"
|
|
||||||
, onInput SetTextSearch
|
|
||||||
, Util.Html.onKeyUpCode KeyUpMsg
|
|
||||||
, textSearchString model.textSearchModel |> Maybe.withDefault "" |> value
|
|
||||||
, case model.textSearchModel of
|
|
||||||
Fulltext _ ->
|
|
||||||
placeholder texts.contentSearch
|
|
||||||
|
|
||||||
Names _ ->
|
|
||||||
placeholder texts.searchInNamesPlaceholder
|
|
||||||
, class S.textInputSidebar
|
|
||||||
]
|
|
||||||
[]
|
|
||||||
, span [ class "opacity-50 text-sm" ]
|
|
||||||
[ case model.textSearchModel of
|
|
||||||
Fulltext _ ->
|
|
||||||
text texts.fulltextSearchInfo
|
|
||||||
|
|
||||||
Names _ ->
|
|
||||||
text texts.nameSearchInfo
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
, { name = tabName TabBookmarks
|
||||||
|
, title = texts.bookmarks
|
||||||
|
, titleRight = []
|
||||||
|
, info = Nothing
|
||||||
|
, body =
|
||||||
|
[ Html.map SelectBookmarkMsg
|
||||||
|
(Comp.BookmarkChooser.view texts.bookmarkChooser model.allBookmarks model.selectedBookmarks)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
, { name = tabName TabTags
|
, { name = tabName TabTags
|
||||||
|
@ -5,13 +5,17 @@ module Data.BookmarkedQuery exposing
|
|||||||
, Bookmarks
|
, Bookmarks
|
||||||
, Location(..)
|
, Location(..)
|
||||||
, add
|
, add
|
||||||
|
, allBookmarksEmpty
|
||||||
, bookmarksDecoder
|
, bookmarksDecoder
|
||||||
, bookmarksEncode
|
, bookmarksEncode
|
||||||
, emptyBookmarks
|
, emptyBookmarks
|
||||||
, exists
|
, exists
|
||||||
|
, filter
|
||||||
|
, map
|
||||||
, remove
|
, remove
|
||||||
)
|
)
|
||||||
|
|
||||||
|
import Api.Model.ShareDetail exposing (ShareDetail)
|
||||||
import Json.Decode as D
|
import Json.Decode as D
|
||||||
import Json.Encode as E
|
import Json.Encode as E
|
||||||
|
|
||||||
@ -52,6 +56,20 @@ type Bookmarks
|
|||||||
= Bookmarks (List BookmarkedQuery)
|
= Bookmarks (List BookmarkedQuery)
|
||||||
|
|
||||||
|
|
||||||
|
map : (BookmarkedQuery -> a) -> Bookmarks -> List a
|
||||||
|
map f bms =
|
||||||
|
case bms of
|
||||||
|
Bookmarks items ->
|
||||||
|
List.map f items
|
||||||
|
|
||||||
|
|
||||||
|
filter : (BookmarkedQuery -> Bool) -> Bookmarks -> Bookmarks
|
||||||
|
filter f bms =
|
||||||
|
case bms of
|
||||||
|
Bookmarks items ->
|
||||||
|
Bookmarks <| List.filter f items
|
||||||
|
|
||||||
|
|
||||||
emptyBookmarks : Bookmarks
|
emptyBookmarks : Bookmarks
|
||||||
emptyBookmarks =
|
emptyBookmarks =
|
||||||
Bookmarks []
|
Bookmarks []
|
||||||
@ -60,9 +78,15 @@ emptyBookmarks =
|
|||||||
type alias AllBookmarks =
|
type alias AllBookmarks =
|
||||||
{ collective : Bookmarks
|
{ collective : Bookmarks
|
||||||
, user : Bookmarks
|
, user : Bookmarks
|
||||||
|
, shares : List ShareDetail
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
allBookmarksEmpty : AllBookmarks
|
||||||
|
allBookmarksEmpty =
|
||||||
|
AllBookmarks emptyBookmarks emptyBookmarks []
|
||||||
|
|
||||||
|
|
||||||
{-| Checks wether a bookmark of this name already exists.
|
{-| Checks wether a bookmark of this name already exists.
|
||||||
-}
|
-}
|
||||||
exists : String -> Bookmarks -> Bool
|
exists : String -> Bookmarks -> Bool
|
||||||
|
@ -71,7 +71,7 @@ and list =
|
|||||||
Nothing
|
Nothing
|
||||||
|
|
||||||
es ->
|
es ->
|
||||||
Just (And es)
|
Just (unwrap (And es))
|
||||||
|
|
||||||
|
|
||||||
request : SearchMode -> Maybe ItemQuery -> RQ.ItemQuery
|
request : SearchMode -> Maybe ItemQuery -> RQ.ItemQuery
|
||||||
@ -90,6 +90,32 @@ renderMaybe mq =
|
|||||||
|> Maybe.withDefault ""
|
|> Maybe.withDefault ""
|
||||||
|
|
||||||
|
|
||||||
|
unwrap : ItemQuery -> ItemQuery
|
||||||
|
unwrap query =
|
||||||
|
case query of
|
||||||
|
And inner ->
|
||||||
|
case inner of
|
||||||
|
first :: [] ->
|
||||||
|
unwrap first
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
And (List.map unwrap inner)
|
||||||
|
|
||||||
|
Or inner ->
|
||||||
|
case inner of
|
||||||
|
first :: [] ->
|
||||||
|
unwrap first
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
Or (List.map unwrap inner)
|
||||||
|
|
||||||
|
Not (Not inner) ->
|
||||||
|
unwrap inner
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
query
|
||||||
|
|
||||||
|
|
||||||
render : ItemQuery -> String
|
render : ItemQuery -> String
|
||||||
render q =
|
render q =
|
||||||
let
|
let
|
||||||
@ -118,7 +144,7 @@ render q =
|
|||||||
String.replace "\"" "\\\""
|
String.replace "\"" "\\\""
|
||||||
>> surround "\""
|
>> surround "\""
|
||||||
in
|
in
|
||||||
case q of
|
case unwrap q of
|
||||||
And inner ->
|
And inner ->
|
||||||
List.map render inner
|
List.map render inner
|
||||||
|> String.join " "
|
|> String.join " "
|
||||||
|
@ -0,0 +1,40 @@
|
|||||||
|
{-
|
||||||
|
Copyright 2020 Eike K. & Contributors
|
||||||
|
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
-}
|
||||||
|
|
||||||
|
|
||||||
|
module Messages.Comp.BookmarkChooser exposing
|
||||||
|
( Texts
|
||||||
|
, de
|
||||||
|
, gb
|
||||||
|
)
|
||||||
|
|
||||||
|
import Messages.Basics
|
||||||
|
|
||||||
|
|
||||||
|
type alias Texts =
|
||||||
|
{ basics : Messages.Basics.Texts
|
||||||
|
, userLabel : String
|
||||||
|
, collectiveLabel : String
|
||||||
|
, shareLabel : String
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gb : Texts
|
||||||
|
gb =
|
||||||
|
{ basics = Messages.Basics.gb
|
||||||
|
, userLabel = "Personal"
|
||||||
|
, collectiveLabel = "Collective"
|
||||||
|
, shareLabel = "Shares"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
de : Texts
|
||||||
|
de =
|
||||||
|
{ basics = Messages.Basics.de
|
||||||
|
, userLabel = "Persönlich"
|
||||||
|
, collectiveLabel = "Kollektiv"
|
||||||
|
, shareLabel = "Freigaben"
|
||||||
|
}
|
@ -13,6 +13,7 @@ module Messages.Comp.SearchMenu exposing
|
|||||||
|
|
||||||
import Data.Direction exposing (Direction)
|
import Data.Direction exposing (Direction)
|
||||||
import Messages.Basics
|
import Messages.Basics
|
||||||
|
import Messages.Comp.BookmarkChooser
|
||||||
import Messages.Comp.CustomFieldMultiInput
|
import Messages.Comp.CustomFieldMultiInput
|
||||||
import Messages.Comp.FolderSelect
|
import Messages.Comp.FolderSelect
|
||||||
import Messages.Comp.TagSelect
|
import Messages.Comp.TagSelect
|
||||||
@ -24,6 +25,7 @@ type alias Texts =
|
|||||||
, customFieldMultiInput : Messages.Comp.CustomFieldMultiInput.Texts
|
, customFieldMultiInput : Messages.Comp.CustomFieldMultiInput.Texts
|
||||||
, tagSelect : Messages.Comp.TagSelect.Texts
|
, tagSelect : Messages.Comp.TagSelect.Texts
|
||||||
, folderSelect : Messages.Comp.FolderSelect.Texts
|
, folderSelect : Messages.Comp.FolderSelect.Texts
|
||||||
|
, bookmarkChooser : Messages.Comp.BookmarkChooser.Texts
|
||||||
, chooseDirection : String
|
, chooseDirection : String
|
||||||
, choosePerson : String
|
, choosePerson : String
|
||||||
, chooseEquipment : String
|
, chooseEquipment : String
|
||||||
@ -47,6 +49,7 @@ type alias Texts =
|
|||||||
, searchInItemSource : String
|
, searchInItemSource : String
|
||||||
, direction : Direction -> String
|
, direction : Direction -> String
|
||||||
, trashcan : String
|
, trashcan : String
|
||||||
|
, bookmarks : String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -56,6 +59,7 @@ gb =
|
|||||||
, customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.gb
|
, customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.gb
|
||||||
, tagSelect = Messages.Comp.TagSelect.gb
|
, tagSelect = Messages.Comp.TagSelect.gb
|
||||||
, folderSelect = Messages.Comp.FolderSelect.gb
|
, folderSelect = Messages.Comp.FolderSelect.gb
|
||||||
|
, bookmarkChooser = Messages.Comp.BookmarkChooser.gb
|
||||||
, chooseDirection = "Choose a direction…"
|
, chooseDirection = "Choose a direction…"
|
||||||
, choosePerson = "Choose a person"
|
, choosePerson = "Choose a person"
|
||||||
, chooseEquipment = "Choose an equipment"
|
, chooseEquipment = "Choose an equipment"
|
||||||
@ -79,6 +83,7 @@ gb =
|
|||||||
, searchInItemSource = "Search in item source…"
|
, searchInItemSource = "Search in item source…"
|
||||||
, direction = Messages.Data.Direction.gb
|
, direction = Messages.Data.Direction.gb
|
||||||
, trashcan = "Trash"
|
, trashcan = "Trash"
|
||||||
|
, bookmarks = "Bookmarks"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -88,6 +93,7 @@ de =
|
|||||||
, customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.de
|
, customFieldMultiInput = Messages.Comp.CustomFieldMultiInput.de
|
||||||
, tagSelect = Messages.Comp.TagSelect.de
|
, tagSelect = Messages.Comp.TagSelect.de
|
||||||
, folderSelect = Messages.Comp.FolderSelect.de
|
, folderSelect = Messages.Comp.FolderSelect.de
|
||||||
|
, bookmarkChooser = Messages.Comp.BookmarkChooser.de
|
||||||
, chooseDirection = "Wähle eine Richtung…"
|
, chooseDirection = "Wähle eine Richtung…"
|
||||||
, choosePerson = "Wähle eine Person…"
|
, choosePerson = "Wähle eine Person…"
|
||||||
, chooseEquipment = "Wähle eine Ausstattung"
|
, chooseEquipment = "Wähle eine Ausstattung"
|
||||||
@ -111,4 +117,5 @@ de =
|
|||||||
, searchInItemSource = "Suche in Dokumentquelle…"
|
, searchInItemSource = "Suche in Dokumentquelle…"
|
||||||
, direction = Messages.Data.Direction.de
|
, direction = Messages.Data.Direction.de
|
||||||
, trashcan = "Papierkorb"
|
, trashcan = "Papierkorb"
|
||||||
|
, bookmarks = "Bookmarks"
|
||||||
}
|
}
|
||||||
|
@ -966,10 +966,20 @@ update mId key flags texts settings msg model =
|
|||||||
|
|
||||||
else
|
else
|
||||||
BookmarkQuery res.model
|
BookmarkQuery res.model
|
||||||
|
|
||||||
|
refreshCmd =
|
||||||
|
if res.outcome == Comp.BookmarkQueryManage.Done then
|
||||||
|
Cmd.map SearchMenuMsg (Comp.SearchMenu.refreshBookmarks flags)
|
||||||
|
|
||||||
|
else
|
||||||
|
Cmd.none
|
||||||
in
|
in
|
||||||
makeResult
|
makeResult
|
||||||
( { model | topWidgetModel = nextModel }
|
( { model | topWidgetModel = nextModel }
|
||||||
, Cmd.map BookmarkQueryMsg res.cmd
|
, Cmd.batch
|
||||||
|
[ Cmd.map BookmarkQueryMsg res.cmd
|
||||||
|
, refreshCmd
|
||||||
|
]
|
||||||
, Sub.map BookmarkQueryMsg res.sub
|
, Sub.map BookmarkQueryMsg res.sub
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -991,7 +1001,10 @@ update mId key flags texts settings msg model =
|
|||||||
)
|
)
|
||||||
|
|
||||||
Comp.PublishItems.OutcomeDone ->
|
Comp.PublishItems.OutcomeDone ->
|
||||||
noSub ( { model | viewMode = SearchView }, Cmd.none )
|
noSub
|
||||||
|
( { model | viewMode = SearchView }
|
||||||
|
, Cmd.map SearchMenuMsg (Comp.SearchMenu.refreshBookmarks flags)
|
||||||
|
)
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
noSub ( model, Cmd.none )
|
noSub ( model, Cmd.none )
|
||||||
|
Reference in New Issue
Block a user