Display deleted items in the webui

The card renders a trash can in the top right corner and the detail
page shows a label and also this trash can.
This commit is contained in:
eikek
2021-08-14 16:06:55 +02:00
parent 3f1ff5c1ac
commit eede20b014
7 changed files with 96 additions and 24 deletions

View File

@ -149,13 +149,19 @@ update ddm msg model =
view2 : Texts -> ViewConfig -> UiSettings -> Model -> ItemLight -> Html Msg view2 : Texts -> ViewConfig -> UiSettings -> Model -> ItemLight -> Html Msg
view2 texts cfg settings model item = view2 texts cfg settings model item =
let let
isConfirmed = isCreated =
item.state /= "created" item.state == "created"
isDeleted =
item.state == "deleted"
cardColor = cardColor =
if not isConfirmed then if isCreated then
"text-blue-500 dark:text-lightblue-500" "text-blue-500 dark:text-lightblue-500"
else if isDeleted then
"text-red-600 dark:text-orange-600"
else else
"" ""
@ -207,7 +213,7 @@ view2 texts cfg settings model item =
[ previewImage2 settings cardAction model item [ previewImage2 settings cardAction model item
] ]
) )
++ [ mainContent2 texts cardAction cardColor isConfirmed settings cfg item ++ [ mainContent2 texts cardAction cardColor isCreated isDeleted settings cfg item
, metaDataContent2 texts settings item , metaDataContent2 texts settings item
, notesContent2 settings item , notesContent2 settings item
, fulltextResultsContent2 item , fulltextResultsContent2 item
@ -293,11 +299,12 @@ mainContent2 :
-> List (Attribute Msg) -> List (Attribute Msg)
-> String -> String
-> Bool -> Bool
-> Bool
-> UiSettings -> UiSettings
-> ViewConfig -> ViewConfig
-> ItemLight -> ItemLight
-> Html Msg -> Html Msg
mainContent2 texts cardAction cardColor isConfirmed settings _ item = mainContent2 texts _ cardColor isCreated isDeleted settings _ item =
let let
dirIcon = dirIcon =
i i
@ -353,12 +360,22 @@ mainContent2 texts cardAction cardColor isConfirmed settings _ item =
[ classList [ classList
[ ( "absolute right-1 top-1 text-4xl", True ) [ ( "absolute right-1 top-1 text-4xl", True )
, ( cardColor, True ) , ( cardColor, True )
, ( "hidden", isConfirmed ) , ( "hidden", not isCreated )
] ]
, title texts.new , title texts.new
] ]
[ i [ class "ml-2 fa fa-exclamation-circle" ] [] [ i [ class "ml-2 fa fa-exclamation-circle" ] []
] ]
, div
[ classList
[ ( "absolute right-1 top-1 text-4xl", True )
, ( cardColor, True )
, ( "hidden", not isDeleted )
]
, title texts.basics.deleted
]
[ i [ class "ml-2 fa fa-trash-alt" ] []
]
, div , div
[ classList [ classList
[ ( "opacity-75", True ) [ ( "opacity-75", True )

View File

@ -118,30 +118,57 @@ view texts settings model =
] ]
, True , True
) )
isDeleted =
model.item.state == "deleted"
isCreated =
model.item.state == "created"
in in
div [ class "flex flex-col pb-2" ] div [ class "flex flex-col pb-2" ]
[ div [ class "flex flex-row items-center text-2xl" ] [ div [ class "flex flex-row items-center text-2xl" ]
[ i [ if isDeleted then
[ classList div
[ ( "hidden", Data.UiSettings.fieldHidden settings Data.Fields.Direction ) [ classList
[ ( "text-red-500 dark:text-orange-600 text-4xl", True )
, ( "hidden", not isDeleted )
]
, title texts.basics.deleted
] ]
, class (Data.Direction.iconFromString2 model.item.direction) [ i [ class "mr-2 fa fa-trash-alt" ] []
, class "mr-2" ]
, title model.item.direction
] else
[] i
[ classList
[ ( "hidden", Data.UiSettings.fieldHidden settings Data.Fields.Direction )
]
, class (Data.Direction.iconFromString2 model.item.direction)
, class "mr-2"
, title model.item.direction
]
[]
, div [ class "flex-grow ml-1 flex flex-col" ] , div [ class "flex-grow ml-1 flex flex-col" ]
[ div [ class "flex flex-row items-center font-semibold" ] [ div [ class "flex flex-row items-center font-semibold" ]
[ text model.item.name [ text model.item.name
, div , div
[ classList [ classList
[ ( "hidden", model.item.state /= "created" ) [ ( "hidden", not isCreated )
] ]
, class "ml-3 text-base label bg-blue-500 dark:bg-lightblue-500 text-white rounded-lg" , class "ml-3 text-base label bg-blue-500 dark:bg-lightblue-500 text-white rounded-lg"
] ]
[ text texts.new [ text texts.new
, i [ class "fa fa-exclamation ml-2" ] [] , i [ class "fa fa-exclamation ml-2" ] []
] ]
, div
[ classList
[ ( "hidden", not isDeleted )
]
, class "ml-3 text-base label bg-red-500 dark:bg-orange-500 text-white rounded-lg"
]
[ text texts.basics.deleted
, i [ class "fa fa-exclamation ml-2" ] []
]
] ]
] ]
] ]

View File

@ -339,6 +339,7 @@ type Msg
| RequestReprocessItem | RequestReprocessItem
| ReprocessItemConfirmed | ReprocessItemConfirmed
| ToggleSelectView | ToggleSelectView
| RestoreItem
type SaveNameState type SaveNameState

View File

@ -1604,6 +1604,13 @@ update key flags inav settings msg model =
, cmd , cmd
) )
RestoreItem ->
let
_ =
Debug.todo "implement"
in
resultModelCmd ( model, Cmd.none )
--- Helper --- Helper

View File

@ -188,15 +188,27 @@ menuBar texts inav settings model =
] ]
[ i [ class "fa fa-redo" ] [] [ i [ class "fa fa-redo" ] []
] ]
, MB.CustomElement <| , if model.item.state == "deleted" then
a MB.CustomElement <|
[ class S.deleteButton a
, href "#" [ class S.undeleteButton
, onClick RequestDelete , href "#"
, title texts.deleteThisItem , onClick RestoreItem
] , title texts.undeleteThisItem
[ i [ class "fa fa-trash" ] [] ]
] [ i [ class "fa fa-trash-restore" ] []
]
else
MB.CustomElement <|
a
[ class S.deleteButton
, href "#"
, onClick RequestDelete
, title texts.deleteThisItem
]
[ i [ class "fa fa-trash" ] []
]
] ]
, rootClasses = "mb-2" , rootClasses = "mb-2"
} }

View File

@ -46,6 +46,7 @@ type alias Texts =
, unconfirmItemMetadata : String , unconfirmItemMetadata : String
, reprocessItem : String , reprocessItem : String
, deleteThisItem : String , deleteThisItem : String
, undeleteThisItem : String
, sentEmails : String , sentEmails : String
, sendThisItemViaEmail : String , sendThisItemViaEmail : String
, itemId : String , itemId : String
@ -79,6 +80,7 @@ gb =
, unconfirmItemMetadata = "Un-confirm item metadata" , unconfirmItemMetadata = "Un-confirm item metadata"
, reprocessItem = "Reprocess this item" , reprocessItem = "Reprocess this item"
, deleteThisItem = "Delete this item" , deleteThisItem = "Delete this item"
, undeleteThisItem = "Restore this item"
, sentEmails = "Sent E-Mails" , sentEmails = "Sent E-Mails"
, sendThisItemViaEmail = "Send this item via E-Mail" , sendThisItemViaEmail = "Send this item via E-Mail"
, itemId = "Item ID" , itemId = "Item ID"
@ -112,6 +114,7 @@ de =
, unconfirmItemMetadata = "Widerrufe Bestätigung" , unconfirmItemMetadata = "Widerrufe Bestätigung"
, reprocessItem = "Das Dokument erneut verarbeiten" , reprocessItem = "Das Dokument erneut verarbeiten"
, deleteThisItem = "Das Dokument löschen" , deleteThisItem = "Das Dokument löschen"
, undeleteThisItem = "Das Dokument wiederherstellen"
, sentEmails = "Versendete E-Mails" , sentEmails = "Versendete E-Mails"
, sendThisItemViaEmail = "Sende dieses Dokument via E-Mail" , sendThisItemViaEmail = "Sende dieses Dokument via E-Mail"
, itemId = "Dokument-ID" , itemId = "Dokument-ID"

View File

@ -200,6 +200,11 @@ deleteButton =
" rounded my-auto whitespace-nowrap border border-red-500 dark:border-lightred-500 text-red-500 dark:text-orange-500 text-center px-4 py-2 shadow-none focus:outline-none focus:ring focus:ring-opacity-75 hover:bg-red-600 hover:text-white dark:hover:text-white dark:hover:bg-orange-500 dark:hover:text-bluegray-900 " " rounded my-auto whitespace-nowrap border border-red-500 dark:border-lightred-500 text-red-500 dark:text-orange-500 text-center px-4 py-2 shadow-none focus:outline-none focus:ring focus:ring-opacity-75 hover:bg-red-600 hover:text-white dark:hover:text-white dark:hover:bg-orange-500 dark:hover:text-bluegray-900 "
undeleteButton : String
undeleteButton =
" rounded my-auto whitespace-nowrap border border-green-500 dark:border-lightgreen-500 text-green-500 dark:text-lightgreen-500 text-center px-4 py-2 shadow-none focus:outline-none focus:ring focus:ring-opacity-75 hover:bg-green-600 hover:text-white dark:hover:text-white dark:hover:bg-lightgreen-500 dark:hover:text-bluegray-900 "
deleteLabel : String deleteLabel : String
deleteLabel = deleteLabel =
"label my-auto whitespace-nowrap border border-red-500 dark:border-lightred-500 text-red-500 dark:text-orange-500 text-center focus:outline-none focus:ring focus:ring-opacity-75 hover:bg-red-600 hover:text-white dark:hover:text-white dark:hover:bg-orange-500 dark:hover:text-bluegray-900" "label my-auto whitespace-nowrap border border-red-500 dark:border-lightred-500 text-red-500 dark:text-orange-500 text-center focus:outline-none focus:ring focus:ring-opacity-75 hover:bg-red-600 hover:text-white dark:hover:text-white dark:hover:bg-orange-500 dark:hover:text-bluegray-900"