Skip to content

Commit

Permalink
Merge pull request #1831 from eikek/fix/1809-clear-selection
Browse files Browse the repository at this point in the history
Fix item selection after merge
  • Loading branch information
mergify[bot] authored Nov 7, 2022
2 parents dc061b1 + e701040 commit e8ce3a6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
4 changes: 2 additions & 2 deletions modules/webapp/src/main/elm/Comp/ItemMerge.elm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type alias Action =

type Outcome
= OutcomeCancel
| OutcomeActionDone
| OutcomeActionDone (Maybe ItemLight)
| OutcomeNotYet


Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions modules/webapp/src/main/elm/Data/ItemIds.elm
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ module Data.ItemIds exposing
, fromSet
, isEmpty
, isMember
, maybeOne
, noChange
, nonEmpty
, one
, select
, selectAll
, size
Expand Down Expand Up @@ -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)
Expand Down
27 changes: 14 additions & 13 deletions modules/webapp/src/main/elm/Page/Search/Update.elm
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down

0 comments on commit e8ce3a6

Please sign in to comment.