Fix item selection after merge

Issue: 
This commit is contained in:
eikek 2022-11-07 17:14:33 +01:00
parent dc061b10a6
commit e701040212
3 changed files with 28 additions and 15 deletions
modules/webapp/src/main/elm

@ -105,7 +105,7 @@ type alias Action =
type Outcome
= OutcomeCancel
| OutcomeActionDone
| OutcomeActionDone (Maybe ItemLight)
| OutcomeNotYet
@ -148,7 +148,7 @@ update _ action msg model =
if result.success then
{ model = { model | formState = FormStateActionSuccessful }
, cmd = Cmd.none
, outcome = OutcomeActionDone
, outcome = OutcomeActionDone (List.head model.items)
}
else

@ -17,8 +17,10 @@ module Data.ItemIds exposing
, fromSet
, isEmpty
, isMember
, maybeOne
, noChange
, nonEmpty
, one
, select
, selectAll
, size
@ -66,6 +68,16 @@ fromSet ids =
ItemIds ids
one : String -> ItemIds
one id =
ItemIds (Set.singleton id)
maybeOne : Maybe String -> ItemIds
maybeOne id =
Maybe.map one id |> Maybe.withDefault empty
union : ItemIds -> ItemIds -> ItemIds
union (ItemIds ids1) (ItemIds ids2) =
ItemIds (Set.union ids1 ids2)

@ -620,25 +620,26 @@ update texts bookmarkId lastViewedItemId env msg model =
Comp.ItemMerge.OutcomeNotYet ->
SelectView { svm | mergeModel = createModel result.model }
Comp.ItemMerge.OutcomeActionDone ->
Comp.ItemMerge.OutcomeActionDone _ ->
SearchView
model_ =
{ model | viewMode = nextView }
in
if result.outcome == Comp.ItemMerge.OutcomeActionDone then
update texts
bookmarkId
lastViewedItemId
env
(DoSearch model.searchTypeDropdownValue)
model_
case result.outcome of
Comp.ItemMerge.OutcomeActionDone target ->
update texts
bookmarkId
lastViewedItemId
{ env | selectedItems = Data.ItemIds.maybeOne <| Maybe.map .id target }
(DoSearch model.searchTypeDropdownValue)
model_
else
resultModelCmd env.selectedItems
( model_
, Cmd.map MergeItemsMsg result.cmd
)
_ ->
resultModelCmd env.selectedItems
( model_
, Cmd.map MergeItemsMsg result.cmd
)
_ ->
resultModelCmd env.selectedItems ( model, Cmd.none )