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 cfg settings model item =
let
isConfirmed =
item.state /= "created"
isCreated =
item.state == "created"
isDeleted =
item.state == "deleted"
cardColor =
if not isConfirmed then
if isCreated then
"text-blue-500 dark:text-lightblue-500"
else if isDeleted then
"text-red-600 dark:text-orange-600"
else
""
@ -207,7 +213,7 @@ view2 texts cfg settings 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
, notesContent2 settings item
, fulltextResultsContent2 item
@ -293,11 +299,12 @@ mainContent2 :
-> List (Attribute Msg)
-> String
-> Bool
-> Bool
-> UiSettings
-> ViewConfig
-> ItemLight
-> Html Msg
mainContent2 texts cardAction cardColor isConfirmed settings _ item =
mainContent2 texts _ cardColor isCreated isDeleted settings _ item =
let
dirIcon =
i
@ -353,12 +360,22 @@ mainContent2 texts cardAction cardColor isConfirmed settings _ item =
[ classList
[ ( "absolute right-1 top-1 text-4xl", True )
, ( cardColor, True )
, ( "hidden", isConfirmed )
, ( "hidden", not isCreated )
]
, title texts.new
]
[ 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
[ classList
[ ( "opacity-75", True )

View File

@ -118,30 +118,57 @@ view texts settings model =
]
, True
)
isDeleted =
model.item.state == "deleted"
isCreated =
model.item.state == "created"
in
div [ class "flex flex-col pb-2" ]
[ div [ class "flex flex-row items-center text-2xl" ]
[ i
[ classList
[ ( "hidden", Data.UiSettings.fieldHidden settings Data.Fields.Direction )
[ if isDeleted then
div
[ 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)
, class "mr-2"
, title model.item.direction
]
[]
[ i [ class "mr-2 fa fa-trash-alt" ] []
]
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 flex-row items-center font-semibold" ]
[ text model.item.name
, div
[ 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"
]
[ text texts.new
, 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
| ReprocessItemConfirmed
| ToggleSelectView
| RestoreItem
type SaveNameState

View File

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

View File

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

View File

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