mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Allow to reprocess single and multiple items in the ui
This commit is contained in:
@ -28,6 +28,7 @@ import Api.Model.SentMails exposing (SentMails)
|
||||
import Api.Model.Tag exposing (Tag)
|
||||
import Api.Model.TagList exposing (TagList)
|
||||
import Comp.AttachmentMeta
|
||||
import Comp.ConfirmModal
|
||||
import Comp.CustomFieldMultiInput
|
||||
import Comp.DatePicker
|
||||
import Comp.DetailEdit
|
||||
@ -72,7 +73,7 @@ type alias Model =
|
||||
, nameSaveThrottle : Throttle Msg
|
||||
, notesModel : Maybe String
|
||||
, notesField : NotesField
|
||||
, deleteItemConfirm : Comp.YesNoDimmer.Model
|
||||
, itemModal : Maybe (Comp.ConfirmModal.Settings Msg)
|
||||
, itemDatePicker : DatePicker
|
||||
, itemDate : Maybe Int
|
||||
, itemProposals : ItemProposals
|
||||
@ -87,7 +88,7 @@ type alias Model =
|
||||
, attachMeta : Dict String Comp.AttachmentMeta.Model
|
||||
, attachMetaOpen : Bool
|
||||
, pdfNativeView : Maybe Bool
|
||||
, deleteAttachConfirm : Comp.YesNoDimmer.Model
|
||||
, attachModal : Maybe (Comp.ConfirmModal.Settings Msg)
|
||||
, addFilesOpen : Bool
|
||||
, addFilesModel : Comp.Dropzone.Model
|
||||
, selectedFiles : List File
|
||||
@ -180,7 +181,7 @@ emptyModel =
|
||||
, nameSaveThrottle = Throttle.create 1
|
||||
, notesModel = Nothing
|
||||
, notesField = ViewNotes
|
||||
, deleteItemConfirm = Comp.YesNoDimmer.emptyModel
|
||||
, itemModal = Nothing
|
||||
, itemDatePicker = Comp.DatePicker.emptyModel
|
||||
, itemDate = Nothing
|
||||
, itemProposals = Api.Model.ItemProposals.empty
|
||||
@ -195,7 +196,7 @@ emptyModel =
|
||||
, attachMeta = Dict.empty
|
||||
, attachMetaOpen = False
|
||||
, pdfNativeView = Nothing
|
||||
, deleteAttachConfirm = Comp.YesNoDimmer.emptyModel
|
||||
, attachModal = Nothing
|
||||
, addFilesOpen = False
|
||||
, addFilesModel = Comp.Dropzone.init []
|
||||
, selectedFiles = []
|
||||
@ -247,7 +248,8 @@ type Msg
|
||||
| SetDueDateSuggestion Int
|
||||
| ItemDatePickerMsg Comp.DatePicker.Msg
|
||||
| DueDatePickerMsg Comp.DatePicker.Msg
|
||||
| DeleteItemConfirm Comp.YesNoDimmer.Msg
|
||||
| DeleteItemConfirmed
|
||||
| ItemModalCancelled
|
||||
| RequestDelete
|
||||
| SaveResp (Result Http.Error BasicResult)
|
||||
| DeleteResp (Result Http.Error BasicResult)
|
||||
@ -265,7 +267,8 @@ type Msg
|
||||
| AttachMetaMsg String Comp.AttachmentMeta.Msg
|
||||
| TogglePdfNativeView Bool
|
||||
| RequestDeleteAttachment String
|
||||
| DeleteAttachConfirm String Comp.YesNoDimmer.Msg
|
||||
| DeleteAttachConfirmed String
|
||||
| AttachModalCancelled
|
||||
| DeleteAttachResp (Result Http.Error BasicResult)
|
||||
| AddFilesToggle
|
||||
| AddFilesMsg Comp.Dropzone.Msg
|
||||
@ -304,6 +307,11 @@ type Msg
|
||||
| ToggleAttachmentDropdown
|
||||
| ToggleAkkordionTab String
|
||||
| ToggleOpenAllAkkordionTabs
|
||||
| RequestReprocessFile String
|
||||
| ReprocessFileConfirmed String
|
||||
| ReprocessFileResp (Result Http.Error BasicResult)
|
||||
| RequestReprocessItem
|
||||
| ReprocessItemConfirmed
|
||||
|
||||
|
||||
type SaveNameState
|
||||
|
@ -3,6 +3,7 @@ module Comp.ItemDetail.SingleAttachment exposing (view)
|
||||
import Api
|
||||
import Api.Model.Attachment exposing (Attachment)
|
||||
import Comp.AttachmentMeta
|
||||
import Comp.ConfirmModal
|
||||
import Comp.ItemDetail.Model
|
||||
exposing
|
||||
( Model
|
||||
@ -11,7 +12,6 @@ import Comp.ItemDetail.Model
|
||||
, SaveNameState(..)
|
||||
)
|
||||
import Comp.MenuBar as MB
|
||||
import Comp.YesNoDimmer
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Dict
|
||||
import Html exposing (..)
|
||||
@ -37,12 +37,7 @@ view settings model pos attach =
|
||||
[ ( "hidden", not (attachmentVisible model pos) )
|
||||
]
|
||||
]
|
||||
[ Html.map (DeleteAttachConfirm attach.id)
|
||||
(Comp.YesNoDimmer.viewN
|
||||
True
|
||||
(Comp.YesNoDimmer.defaultSettings2 "Really delete this file?")
|
||||
model.deleteAttachConfirm
|
||||
)
|
||||
[ renderModal model
|
||||
, div
|
||||
[ class "flex flex-row px-2 py-2 text-sm"
|
||||
, class S.border
|
||||
@ -213,6 +208,13 @@ attachHeader settings model _ attach =
|
||||
, href "#"
|
||||
]
|
||||
}
|
||||
, { icon = "fa fa-redo-alt"
|
||||
, label = "Re-process this file"
|
||||
, attrs =
|
||||
[ onClick (RequestReprocessFile attach.id)
|
||||
, href "#"
|
||||
]
|
||||
}
|
||||
, { icon = "fa fa-trash"
|
||||
, label = "Delete this file"
|
||||
, attrs =
|
||||
@ -344,3 +346,13 @@ menuItem model pos attach =
|
||||
|> text
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
renderModal : Model -> Html Msg
|
||||
renderModal model =
|
||||
case model.attachModal of
|
||||
Just confirmModal ->
|
||||
Comp.ConfirmModal.view confirmModal
|
||||
|
||||
Nothing ->
|
||||
span [ class "hidden" ] []
|
||||
|
@ -16,6 +16,7 @@ import Api.Model.ReferenceList exposing (ReferenceList)
|
||||
import Api.Model.Tag exposing (Tag)
|
||||
import Browser.Navigation as Nav
|
||||
import Comp.AttachmentMeta
|
||||
import Comp.ConfirmModal
|
||||
import Comp.CustomFieldMultiInput
|
||||
import Comp.DatePicker
|
||||
import Comp.DetailEdit
|
||||
@ -43,7 +44,6 @@ import Comp.MarkdownInput
|
||||
import Comp.OrgForm
|
||||
import Comp.PersonForm
|
||||
import Comp.SentMails
|
||||
import Comp.YesNoDimmer
|
||||
import Data.CustomFieldChange exposing (CustomFieldChange(..))
|
||||
import Data.Direction
|
||||
import Data.Fields exposing (Field)
|
||||
@ -532,22 +532,28 @@ update key flags inav settings msg model =
|
||||
RemoveDueDate ->
|
||||
resultModelCmd ( { model | dueDate = Nothing }, setDueDate flags model Nothing )
|
||||
|
||||
DeleteItemConfirm m ->
|
||||
DeleteItemConfirmed ->
|
||||
let
|
||||
( cm, confirmed ) =
|
||||
Comp.YesNoDimmer.update m model.deleteItemConfirm
|
||||
|
||||
cmd =
|
||||
if confirmed then
|
||||
Api.deleteItem flags model.item.id DeleteResp
|
||||
|
||||
else
|
||||
Cmd.none
|
||||
Api.deleteItem flags model.item.id DeleteResp
|
||||
in
|
||||
resultModelCmd ( { model | deleteItemConfirm = cm }, cmd )
|
||||
resultModelCmd ( { model | itemModal = Nothing }, cmd )
|
||||
|
||||
ItemModalCancelled ->
|
||||
resultModel { model | itemModal = Nothing }
|
||||
|
||||
RequestDelete ->
|
||||
update key flags inav settings (DeleteItemConfirm Comp.YesNoDimmer.activate) model
|
||||
let
|
||||
confirmMsg =
|
||||
"Really delete this item? This cannot be undone."
|
||||
|
||||
confirm =
|
||||
Comp.ConfirmModal.defaultSettings
|
||||
DeleteItemConfirmed
|
||||
ItemModalCancelled
|
||||
confirmMsg
|
||||
in
|
||||
resultModel { model | itemModal = Just confirm }
|
||||
|
||||
SetCorrOrgSuggestion idname ->
|
||||
resultModelCmd ( model, setCorrOrg flags model (Just idname) )
|
||||
@ -913,19 +919,15 @@ update key flags inav settings msg model =
|
||||
, attachmentDropdownOpen = False
|
||||
}
|
||||
|
||||
DeleteAttachConfirm attachId lmsg ->
|
||||
DeleteAttachConfirmed attachId ->
|
||||
let
|
||||
( cm, confirmed ) =
|
||||
Comp.YesNoDimmer.update lmsg model.deleteAttachConfirm
|
||||
|
||||
cmd =
|
||||
if confirmed then
|
||||
Api.deleteAttachment flags attachId DeleteAttachResp
|
||||
|
||||
else
|
||||
Cmd.none
|
||||
Api.deleteAttachment flags attachId DeleteAttachResp
|
||||
in
|
||||
resultModelCmd ( { model | deleteAttachConfirm = cm }, cmd )
|
||||
resultModelCmd ( { model | attachModal = Nothing }, cmd )
|
||||
|
||||
AttachModalCancelled ->
|
||||
resultModel { model | attachModal = Nothing }
|
||||
|
||||
DeleteAttachResp (Ok res) ->
|
||||
if res.success then
|
||||
@ -938,12 +940,20 @@ update key flags inav settings msg model =
|
||||
resultModel model
|
||||
|
||||
RequestDeleteAttachment id ->
|
||||
update key
|
||||
flags
|
||||
inav
|
||||
settings
|
||||
(DeleteAttachConfirm id Comp.YesNoDimmer.activate)
|
||||
{ model | attachmentDropdownOpen = False }
|
||||
let
|
||||
confirmModal =
|
||||
Comp.ConfirmModal.defaultSettings
|
||||
(DeleteAttachConfirmed id)
|
||||
AttachModalCancelled
|
||||
"Really delete this file?"
|
||||
|
||||
model_ =
|
||||
{ model
|
||||
| attachmentDropdownOpen = False
|
||||
, attachModal = Just confirmModal
|
||||
}
|
||||
in
|
||||
resultModel model_
|
||||
|
||||
AddFilesToggle ->
|
||||
resultModel
|
||||
@ -1508,6 +1518,73 @@ update key flags inav settings msg model =
|
||||
in
|
||||
resultModel { model | editMenuTabsOpen = next }
|
||||
|
||||
RequestReprocessFile id ->
|
||||
let
|
||||
confirmMsg =
|
||||
if model.item.state == "created" then
|
||||
"Reprocessing this file may change metadata of "
|
||||
++ "this item, since it is unconfirmed. Do you want to proceed?"
|
||||
|
||||
else
|
||||
"Reprocessing this file will not change metadata of "
|
||||
++ "this item, since it has been confirmed. Do you want to proceed?"
|
||||
|
||||
confirmModal =
|
||||
Comp.ConfirmModal.defaultSettings
|
||||
(ReprocessFileConfirmed id)
|
||||
AttachModalCancelled
|
||||
confirmMsg
|
||||
|
||||
model_ =
|
||||
{ model
|
||||
| attachmentDropdownOpen = False
|
||||
, attachModal = Just confirmModal
|
||||
}
|
||||
in
|
||||
resultModel model_
|
||||
|
||||
ReprocessFileConfirmed id ->
|
||||
let
|
||||
cmd =
|
||||
Api.reprocessItem flags model.item.id [ id ] ReprocessFileResp
|
||||
in
|
||||
resultModelCmd ( { model | attachModal = Nothing }, cmd )
|
||||
|
||||
ReprocessFileResp _ ->
|
||||
resultModel model
|
||||
|
||||
RequestReprocessItem ->
|
||||
let
|
||||
confirmMsg =
|
||||
if model.item.state == "created" then
|
||||
"Reprocessing this item may change its metadata, "
|
||||
++ "since it is unconfirmed. Do you want to proceed?"
|
||||
|
||||
else
|
||||
"Reprocessing this item will not change its metadata, "
|
||||
++ "since it has been confirmed. Do you want to proceed?"
|
||||
|
||||
confirmModal =
|
||||
Comp.ConfirmModal.defaultSettings
|
||||
ReprocessItemConfirmed
|
||||
ItemModalCancelled
|
||||
confirmMsg
|
||||
|
||||
model_ =
|
||||
{ model
|
||||
| attachmentDropdownOpen = False
|
||||
, itemModal = Just confirmModal
|
||||
}
|
||||
in
|
||||
resultModel model_
|
||||
|
||||
ReprocessItemConfirmed ->
|
||||
let
|
||||
cmd =
|
||||
Api.reprocessItem flags model.item.id [] ReprocessFileResp
|
||||
in
|
||||
resultModelCmd ( { model | itemModal = Nothing }, cmd )
|
||||
|
||||
|
||||
|
||||
--- Helper
|
||||
|
@ -1,6 +1,7 @@
|
||||
module Comp.ItemDetail.View2 exposing (view)
|
||||
|
||||
import Comp.Basic as B
|
||||
import Comp.ConfirmModal
|
||||
import Comp.DetailEdit
|
||||
import Comp.ItemDetail.AddFilesForm
|
||||
import Comp.ItemDetail.ItemInfoHeader
|
||||
@ -16,7 +17,6 @@ import Comp.ItemDetail.SingleAttachment
|
||||
import Comp.ItemMail
|
||||
import Comp.MenuBar as MB
|
||||
import Comp.SentMails
|
||||
import Comp.YesNoDimmer
|
||||
import Data.Icons as Icons
|
||||
import Data.ItemNav exposing (ItemNav)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
@ -34,15 +34,20 @@ view inav settings model =
|
||||
[ header settings model
|
||||
, menuBar inav settings model
|
||||
, body inav settings model
|
||||
, Html.map DeleteItemConfirm
|
||||
(Comp.YesNoDimmer.viewN
|
||||
True
|
||||
(Comp.YesNoDimmer.defaultSettings2 "Really delete the complete item?")
|
||||
model.deleteItemConfirm
|
||||
)
|
||||
, itemModal model
|
||||
]
|
||||
|
||||
|
||||
itemModal : Model -> Html Msg
|
||||
itemModal model =
|
||||
case model.itemModal of
|
||||
Just confirm ->
|
||||
Comp.ConfirmModal.view confirm
|
||||
|
||||
Nothing ->
|
||||
span [ class "hidden" ] []
|
||||
|
||||
|
||||
header : UiSettings -> Model -> Html Msg
|
||||
header settings model =
|
||||
div [ class "my-3" ]
|
||||
@ -166,6 +171,15 @@ menuBar inav settings model =
|
||||
]
|
||||
[ i [ class "fa fa-eye-slash font-thin" ] []
|
||||
]
|
||||
, MB.CustomElement <|
|
||||
a
|
||||
[ class S.secondaryBasicButton
|
||||
, href "#"
|
||||
, onClick RequestReprocessItem
|
||||
, title "Reprocess this item"
|
||||
]
|
||||
[ i [ class "fa fa-redo" ] []
|
||||
]
|
||||
, MB.CustomElement <|
|
||||
a
|
||||
[ class S.deleteButton
|
||||
|
Reference in New Issue
Block a user