mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-05 02:49:32 +00:00
Allow to restore deleted items in webui
This commit is contained in:
parent
f999662905
commit
828e5cf703
@ -99,6 +99,8 @@ module Api exposing
|
||||
, removeTagsMultiple
|
||||
, reprocessItem
|
||||
, reprocessMultiple
|
||||
, restoreAllItems
|
||||
, restoreItem
|
||||
, saveClientSettings
|
||||
, sendMail
|
||||
, setAttachmentName
|
||||
@ -1676,6 +1678,20 @@ deleteAllItems flags ids receive =
|
||||
}
|
||||
|
||||
|
||||
restoreAllItems :
|
||||
Flags
|
||||
-> Set String
|
||||
-> (Result Http.Error BasicResult -> msg)
|
||||
-> Cmd msg
|
||||
restoreAllItems flags ids receive =
|
||||
Http2.authPost
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/sec/items/restoreAll"
|
||||
, account = getAccount flags
|
||||
, body = Http.jsonBody (Api.Model.IdList.encode (IdList (Set.toList ids)))
|
||||
, expect = Http.expectJson receive Api.Model.BasicResult.decoder
|
||||
}
|
||||
|
||||
|
||||
|
||||
--- Item
|
||||
|
||||
@ -1973,6 +1989,16 @@ setUnconfirmed flags item receive =
|
||||
}
|
||||
|
||||
|
||||
restoreItem : Flags -> String -> (Result Http.Error BasicResult -> msg) -> Cmd msg
|
||||
restoreItem flags item receive =
|
||||
Http2.authPost
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/sec/item/" ++ item ++ "/restore"
|
||||
, account = getAccount flags
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson receive Api.Model.BasicResult.decoder
|
||||
}
|
||||
|
||||
|
||||
deleteItem : Flags -> String -> (Result Http.Error BasicResult -> msg) -> Cmd msg
|
||||
deleteItem flags item receive =
|
||||
Http2.authDelete
|
||||
|
@ -1605,11 +1605,7 @@ update key flags inav settings msg model =
|
||||
)
|
||||
|
||||
RestoreItem ->
|
||||
let
|
||||
_ =
|
||||
Debug.todo "implement"
|
||||
in
|
||||
resultModelCmd ( model, Cmd.none )
|
||||
resultModelCmd ( model, Api.restoreItem flags model.item.id SaveResp )
|
||||
|
||||
|
||||
|
||||
|
@ -1482,7 +1482,7 @@ searchTabs texts ddd flags settings model =
|
||||
]
|
||||
}
|
||||
, { name = tabName TabTrashed
|
||||
, title = texts.basics.deleted
|
||||
, title = texts.trashcan
|
||||
, titleRight = []
|
||||
, info = Nothing
|
||||
, body =
|
||||
@ -1490,7 +1490,7 @@ searchTabs texts ddd flags settings model =
|
||||
MB.Checkbox
|
||||
{ id = "trashed"
|
||||
, value = model.searchMode == Data.SearchMode.Trashed
|
||||
, label = texts.basics.deleted
|
||||
, label = texts.trashcan
|
||||
, tagger = \_ -> ToggleSearchMode
|
||||
}
|
||||
]
|
||||
|
@ -46,6 +46,7 @@ type alias Texts =
|
||||
, sourceTab : String
|
||||
, searchInItemSource : String
|
||||
, direction : Direction -> String
|
||||
, trashcan : String
|
||||
}
|
||||
|
||||
|
||||
@ -77,6 +78,7 @@ gb =
|
||||
, sourceTab = "Source"
|
||||
, searchInItemSource = "Search in item source…"
|
||||
, direction = Messages.Data.Direction.gb
|
||||
, trashcan = "Trash"
|
||||
}
|
||||
|
||||
|
||||
@ -108,4 +110,5 @@ de =
|
||||
, sourceTab = "Quelle"
|
||||
, searchInItemSource = "Suche in Dokumentquelle…"
|
||||
, direction = Messages.Data.Direction.de
|
||||
, trashcan = "Papierkorb"
|
||||
}
|
||||
|
@ -30,9 +30,11 @@ type alias Texts =
|
||||
, powerSearchPlaceholder : String
|
||||
, reallyReprocessQuestion : String
|
||||
, reallyDeleteQuestion : String
|
||||
, reallyRestoreQuestion : String
|
||||
, editSelectedItems : Int -> String
|
||||
, reprocessSelectedItems : Int -> String
|
||||
, deleteSelectedItems : Int -> String
|
||||
, undeleteSelectedItems : Int -> String
|
||||
, selectAllVisible : String
|
||||
, selectNone : String
|
||||
, resetSearchForm : String
|
||||
@ -54,9 +56,11 @@ gb =
|
||||
, powerSearchPlaceholder = "Search query …"
|
||||
, reallyReprocessQuestion = "Really reprocess all selected items? Metadata of unconfirmed items may change."
|
||||
, reallyDeleteQuestion = "Really delete all selected items?"
|
||||
, reallyRestoreQuestion = "Really restore all selected items?"
|
||||
, editSelectedItems = \n -> "Edit " ++ String.fromInt n ++ " selected items"
|
||||
, reprocessSelectedItems = \n -> "Reprocess " ++ String.fromInt n ++ " selected items"
|
||||
, deleteSelectedItems = \n -> "Delete " ++ String.fromInt n ++ " selected items"
|
||||
, undeleteSelectedItems = \n -> "Restore " ++ String.fromInt n ++ " selected items"
|
||||
, selectAllVisible = "Select all visible"
|
||||
, selectNone = "Select none"
|
||||
, resetSearchForm = "Reset search form"
|
||||
@ -78,9 +82,11 @@ de =
|
||||
, powerSearchPlaceholder = "Suchanfrage…"
|
||||
, reallyReprocessQuestion = "Wirklich die gewählten Dokumente neu verarbeiten? Die Metadaten von nicht bestätigten Dokumenten können sich dabei ändern."
|
||||
, reallyDeleteQuestion = "Wirklich alle gewählten Dokumente löschen?"
|
||||
, reallyRestoreQuestion = "Wirklich alle gewählten Dokumente wiederherstellen?"
|
||||
, editSelectedItems = \n -> "Ändere " ++ String.fromInt n ++ " gewählte Dokumente"
|
||||
, reprocessSelectedItems = \n -> "Erneute Verarbeitung von " ++ String.fromInt n ++ " gewählten Dokumenten"
|
||||
, deleteSelectedItems = \n -> "Lösche " ++ String.fromInt n ++ " gewählte Dokumente"
|
||||
, undeleteSelectedItems = \n -> "Stelle " ++ String.fromInt n ++ " gewählte Dokumente wieder her"
|
||||
, selectAllVisible = "Wähle alle Dokumente in der Liste"
|
||||
, selectNone = "Wähle alle Dokumente ab"
|
||||
, resetSearchForm = "Suchformular zurücksetzen"
|
||||
|
@ -68,6 +68,7 @@ type alias Model =
|
||||
type ConfirmModalValue
|
||||
= ConfirmReprocessItems
|
||||
| ConfirmDelete
|
||||
| ConfirmRestore
|
||||
|
||||
|
||||
type alias SelectViewModel =
|
||||
@ -185,7 +186,9 @@ type Msg
|
||||
| SelectAllItems
|
||||
| SelectNoItems
|
||||
| RequestDeleteSelected
|
||||
| RequestRestoreSelected
|
||||
| DeleteSelectedConfirmed
|
||||
| RestoreSelectedConfirmed
|
||||
| CloseConfirmModal
|
||||
| EditSelectedItems
|
||||
| EditMenuMsg Comp.ItemDetail.MultiEditMenu.Msg
|
||||
@ -214,6 +217,7 @@ type SelectActionMode
|
||||
| DeleteSelected
|
||||
| EditSelected
|
||||
| ReprocessSelected
|
||||
| RestoreSelected
|
||||
|
||||
|
||||
type alias SearchParam =
|
||||
|
@ -361,6 +361,28 @@ update mId key flags settings msg model =
|
||||
|
||||
_ ->
|
||||
noSub ( model, Cmd.none )
|
||||
RestoreSelectedConfirmed ->
|
||||
case model.viewMode of
|
||||
SelectView svm ->
|
||||
let
|
||||
cmd =
|
||||
Api.restoreAllItems flags svm.ids DeleteAllResp
|
||||
in
|
||||
noSub
|
||||
( { model
|
||||
| viewMode =
|
||||
SelectView
|
||||
{ svm
|
||||
| confirmModal = Nothing
|
||||
, action = RestoreSelected
|
||||
}
|
||||
}
|
||||
, cmd
|
||||
)
|
||||
|
||||
_ ->
|
||||
noSub ( model, Cmd.none )
|
||||
|
||||
|
||||
DeleteAllResp (Ok res) ->
|
||||
if res.success then
|
||||
@ -469,6 +491,29 @@ update mId key flags settings msg model =
|
||||
_ ->
|
||||
noSub ( model, Cmd.none )
|
||||
|
||||
RequestRestoreSelected ->
|
||||
case model.viewMode of
|
||||
SelectView svm ->
|
||||
if svm.ids == Set.empty then
|
||||
noSub ( model, Cmd.none )
|
||||
|
||||
else
|
||||
let
|
||||
model_ =
|
||||
{ model
|
||||
| viewMode =
|
||||
SelectView
|
||||
{ svm
|
||||
| action = RestoreSelected
|
||||
, confirmModal = Just ConfirmRestore
|
||||
}
|
||||
}
|
||||
in
|
||||
noSub ( model_, Cmd.none )
|
||||
|
||||
_ ->
|
||||
noSub ( model, Cmd.none )
|
||||
|
||||
EditSelectedItems ->
|
||||
case model.viewMode of
|
||||
SelectView svm ->
|
||||
|
@ -78,6 +78,14 @@ confirmModal texts model =
|
||||
texts.basics.yes
|
||||
texts.basics.no
|
||||
texts.reallyDeleteQuestion
|
||||
ConfirmRestore ->
|
||||
Comp.ConfirmModal.defaultSettings
|
||||
RestoreSelectedConfirmed
|
||||
CloseConfirmModal
|
||||
texts.basics.yes
|
||||
texts.basics.no
|
||||
texts.reallyRestoreQuestion
|
||||
|
||||
in
|
||||
case model.viewMode of
|
||||
SelectView svm ->
|
||||
@ -264,6 +272,16 @@ editMenuBar texts model svm =
|
||||
, ( "bg-gray-200 dark:bg-bluegray-600", svm.action == DeleteSelected )
|
||||
]
|
||||
}
|
||||
, MB.CustomButton
|
||||
{ tagger = RequestRestoreSelected
|
||||
, label = ""
|
||||
, icon = Just "fa fa-trash-restore"
|
||||
, title = texts.undeleteSelectedItems selectCount
|
||||
, inputClass =
|
||||
[ ( btnStyle, True )
|
||||
, ( "bg-gray-200 dark:bg-bluegray-600", svm.action == RestoreSelected )
|
||||
]
|
||||
}
|
||||
]
|
||||
, end =
|
||||
[ MB.CustomButton
|
||||
|
Loading…
x
Reference in New Issue
Block a user