mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
Allow to search in deleted items
This commit is contained in:
parent
edb344314f
commit
3f1ff5c1ac
@ -45,6 +45,7 @@ import Data.Fields
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.ItemQuery as Q exposing (ItemQuery)
|
||||
import Data.PersonUse
|
||||
import Data.SearchMode exposing (SearchMode)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import DatePicker exposing (DatePicker)
|
||||
import Html exposing (..)
|
||||
@ -89,6 +90,7 @@ type alias Model =
|
||||
, customValues : CustomFieldValueCollect
|
||||
, sourceModel : Maybe String
|
||||
, openTabs : Set String
|
||||
, searchMode : SearchMode
|
||||
}
|
||||
|
||||
|
||||
@ -133,6 +135,7 @@ init flags =
|
||||
, customValues = Data.CustomFieldChange.emptyCollect
|
||||
, sourceModel = Nothing
|
||||
, openTabs = Set.fromList [ "Tags", "Inbox" ]
|
||||
, searchMode = Data.SearchMode.Normal
|
||||
}
|
||||
|
||||
|
||||
@ -323,6 +326,7 @@ resetModel model =
|
||||
model.customFieldModel
|
||||
, customValues = Data.CustomFieldChange.emptyCollect
|
||||
, sourceModel = Nothing
|
||||
, searchMode = Data.SearchMode.Normal
|
||||
}
|
||||
|
||||
|
||||
@ -343,6 +347,7 @@ type Msg
|
||||
| FromDueDateMsg Comp.DatePicker.Msg
|
||||
| UntilDueDateMsg Comp.DatePicker.Msg
|
||||
| ToggleInbox
|
||||
| ToggleSearchMode
|
||||
| GetOrgResp (Result Http.Error ReferenceList)
|
||||
| GetEquipResp (Result Http.Error EquipmentList)
|
||||
| GetPersonResp (Result Http.Error PersonList)
|
||||
@ -683,6 +688,24 @@ updateDrop ddm flags settings msg model =
|
||||
, dragDrop = DD.DragDropData ddm Nothing
|
||||
}
|
||||
|
||||
ToggleSearchMode ->
|
||||
let
|
||||
current =
|
||||
model.searchMode
|
||||
|
||||
next =
|
||||
if current == Data.SearchMode.Normal then
|
||||
Data.SearchMode.Trashed
|
||||
|
||||
else
|
||||
Data.SearchMode.Normal
|
||||
in
|
||||
{ model = { model | searchMode = next }
|
||||
, cmd = Cmd.none
|
||||
, stateChange = True
|
||||
, dragDrop = DD.DragDropData ddm Nothing
|
||||
}
|
||||
|
||||
FromDateMsg m ->
|
||||
let
|
||||
( dp, event ) =
|
||||
@ -962,6 +985,7 @@ type SearchTab
|
||||
| TabDueDate
|
||||
| TabSource
|
||||
| TabDirection
|
||||
| TabTrashed
|
||||
|
||||
|
||||
allTabs : List SearchTab
|
||||
@ -977,6 +1001,7 @@ allTabs =
|
||||
, TabDueDate
|
||||
, TabSource
|
||||
, TabDirection
|
||||
, TabTrashed
|
||||
]
|
||||
|
||||
|
||||
@ -1016,6 +1041,9 @@ tabName tab =
|
||||
TabDirection ->
|
||||
"direction"
|
||||
|
||||
TabTrashed ->
|
||||
"trashed"
|
||||
|
||||
|
||||
findTab : Comp.Tabs.Tab msg -> Maybe SearchTab
|
||||
findTab tab =
|
||||
@ -1053,6 +1081,9 @@ findTab tab =
|
||||
"direction" ->
|
||||
Just TabDirection
|
||||
|
||||
"trashed" ->
|
||||
Just TabTrashed
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
|
||||
@ -1099,6 +1130,9 @@ searchTabState settings model tab =
|
||||
Just TabInbox ->
|
||||
False
|
||||
|
||||
Just TabTrashed ->
|
||||
False
|
||||
|
||||
Nothing ->
|
||||
False
|
||||
|
||||
@ -1447,4 +1481,18 @@ searchTabs texts ddd flags settings model =
|
||||
)
|
||||
]
|
||||
}
|
||||
, { name = tabName TabTrashed
|
||||
, title = texts.basics.deleted
|
||||
, titleRight = []
|
||||
, info = Nothing
|
||||
, body =
|
||||
[ MB.viewItem <|
|
||||
MB.Checkbox
|
||||
{ id = "trashed"
|
||||
, value = model.searchMode == Data.SearchMode.Trashed
|
||||
, label = texts.basics.deleted
|
||||
, tagger = \_ -> ToggleSearchMode
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -21,6 +21,7 @@ module Data.ItemQuery exposing
|
||||
import Api.Model.CustomFieldValue exposing (CustomFieldValue)
|
||||
import Api.Model.ItemQuery as RQ
|
||||
import Data.Direction exposing (Direction)
|
||||
import Data.SearchMode exposing (SearchMode)
|
||||
|
||||
|
||||
type TagMatch
|
||||
@ -73,13 +74,13 @@ and list =
|
||||
Just (And es)
|
||||
|
||||
|
||||
request : Maybe ItemQuery -> RQ.ItemQuery
|
||||
request mq =
|
||||
request : SearchMode -> Maybe ItemQuery -> RQ.ItemQuery
|
||||
request smode mq =
|
||||
{ offset = Nothing
|
||||
, limit = Nothing
|
||||
, withDetails = Just True
|
||||
, query = renderMaybe mq
|
||||
, searchMode = Nothing
|
||||
, searchMode = Data.SearchMode.asString smode |> Just
|
||||
}
|
||||
|
||||
|
||||
|
40
modules/webapp/src/main/elm/Data/SearchMode.elm
Normal file
40
modules/webapp/src/main/elm/Data/SearchMode.elm
Normal file
@ -0,0 +1,40 @@
|
||||
{-
|
||||
Copyright 2020 Docspell Contributors
|
||||
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
-}
|
||||
|
||||
|
||||
module Data.SearchMode exposing
|
||||
( SearchMode(..)
|
||||
, asString
|
||||
, fromString
|
||||
)
|
||||
|
||||
|
||||
type SearchMode
|
||||
= Normal
|
||||
| Trashed
|
||||
|
||||
|
||||
fromString : String -> Maybe SearchMode
|
||||
fromString str =
|
||||
case String.toLower str of
|
||||
"normal" ->
|
||||
Just Normal
|
||||
|
||||
"trashed" ->
|
||||
Just Trashed
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
|
||||
|
||||
asString : SearchMode -> String
|
||||
asString smode =
|
||||
case smode of
|
||||
Normal ->
|
||||
"normal"
|
||||
|
||||
Trashed ->
|
||||
"trashed"
|
@ -239,7 +239,7 @@ doSearchDefaultCmd : SearchParam -> Model -> Cmd Msg
|
||||
doSearchDefaultCmd param model =
|
||||
let
|
||||
smask =
|
||||
Q.request <|
|
||||
Q.request model.searchMenuModel.searchMode <|
|
||||
Q.and
|
||||
[ Comp.SearchMenu.getItemQuery model.searchMenuModel
|
||||
, Maybe.map Q.Fragment model.powerSearchInput.input
|
||||
|
@ -23,6 +23,7 @@ import Data.Flags exposing (Flags)
|
||||
import Data.ItemQuery as Q
|
||||
import Data.ItemSelection
|
||||
import Data.Items
|
||||
import Data.SearchMode exposing (SearchMode)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Page exposing (Page(..))
|
||||
import Page.Home.Data exposing (..)
|
||||
@ -548,7 +549,7 @@ update mId key flags settings msg model =
|
||||
case model.viewMode of
|
||||
SelectView svm ->
|
||||
-- replace changed items in the view
|
||||
noSub ( nm, loadChangedItems flags svm.ids )
|
||||
noSub ( nm, loadChangedItems flags model.searchMenuModel.searchMode svm.ids )
|
||||
|
||||
_ ->
|
||||
noSub ( nm, Cmd.none )
|
||||
@ -717,8 +718,8 @@ replaceItems model newItems =
|
||||
{ model | itemListModel = newList }
|
||||
|
||||
|
||||
loadChangedItems : Flags -> Set String -> Cmd Msg
|
||||
loadChangedItems flags ids =
|
||||
loadChangedItems : Flags -> SearchMode -> Set String -> Cmd Msg
|
||||
loadChangedItems flags smode ids =
|
||||
if Set.isEmpty ids then
|
||||
Cmd.none
|
||||
|
||||
@ -728,7 +729,7 @@ loadChangedItems flags ids =
|
||||
Set.toList ids
|
||||
|
||||
searchInit =
|
||||
Q.request (Just <| Q.ItemIdIn idList)
|
||||
Q.request smode (Just <| Q.ItemIdIn idList)
|
||||
|
||||
search =
|
||||
{ searchInit
|
||||
|
Loading…
x
Reference in New Issue
Block a user