diff --git a/modules/webapp/src/main/elm/Comp/ItemMerge.elm b/modules/webapp/src/main/elm/Comp/ItemMerge.elm index 55e823d78a..2d2c813270 100644 --- a/modules/webapp/src/main/elm/Comp/ItemMerge.elm +++ b/modules/webapp/src/main/elm/Comp/ItemMerge.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 diff --git a/modules/webapp/src/main/elm/Data/ItemIds.elm b/modules/webapp/src/main/elm/Data/ItemIds.elm index 54760187a9..74a1d76009 100644 --- a/modules/webapp/src/main/elm/Data/ItemIds.elm +++ b/modules/webapp/src/main/elm/Data/ItemIds.elm @@ -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) diff --git a/modules/webapp/src/main/elm/Page/Search/Update.elm b/modules/webapp/src/main/elm/Page/Search/Update.elm index 5a1afa04d8..61d6c2d01e 100644 --- a/modules/webapp/src/main/elm/Page/Search/Update.elm +++ b/modules/webapp/src/main/elm/Page/Search/Update.elm @@ -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 )