Remove a deleted item from search results

When an item is deleted in detail view, the results must be updated to
reflect the new state. The results are now changed by removing the
corresponding item.

Fixes: #920
This commit is contained in:
eikek
2021-07-25 16:03:52 +02:00
parent df5b59a7ce
commit 782ca0fa4f
8 changed files with 61 additions and 17 deletions

View File

@ -46,6 +46,7 @@ type Msg
= SetResults ItemLightList
| AddResults ItemLightList
| ItemCardMsg ItemLight Comp.ItemCard.Msg
| RemoveItem String
init : Model
@ -145,6 +146,13 @@ updateDrag dm _ msg model =
result.selection
result.linkTarget
RemoveItem id ->
UpdateResult { model | results = removeItemById id model.results }
Cmd.none
dm
Data.ItemSelection.Inactive
Comp.LinkTarget.LinkNone
--- View2
@ -232,3 +240,15 @@ isMultiSelectMode cfg =
Data.ItemSelection.Inactive ->
False
removeItemById : String -> ItemLightList -> ItemLightList
removeItemById id list =
let
filterItem item =
item.id /= id
filterGroup group =
{ group | items = List.filter filterItem group.items }
in
{ list | groups = List.map filterGroup list.groups }