Fix item selection after merge

Issue: #1809
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

View File

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

View File

@ -17,8 +17,10 @@ module Data.ItemIds exposing
, fromSet , fromSet
, isEmpty , isEmpty
, isMember , isMember
, maybeOne
, noChange , noChange
, nonEmpty , nonEmpty
, one
, select , select
, selectAll , selectAll
, size , size
@ -66,6 +68,16 @@ fromSet ids =
ItemIds 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 -> ItemIds -> ItemIds
union (ItemIds ids1) (ItemIds ids2) = union (ItemIds ids1) (ItemIds ids2) =
ItemIds (Set.union ids1 ids2) ItemIds (Set.union ids1 ids2)

View File

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