Implement scroll to package (#257)
This commit is contained in:
parent
08943214d2
commit
aa366aa31c
|
@ -174,7 +174,10 @@ viewResultItem channel show item =
|
||||||
-- DEBUG: ]
|
-- DEBUG: ]
|
||||||
-- DEBUG: ]
|
-- DEBUG: ]
|
||||||
|> List.append
|
|> List.append
|
||||||
(tr [ onClick (SearchMsg (Search.ShowDetails item.source.name)) ]
|
(tr
|
||||||
|
[ onClick (SearchMsg (Search.ShowDetails item.source.name))
|
||||||
|
, Search.elementId item.source.name
|
||||||
|
]
|
||||||
[ td [] [ text item.source.name ]
|
[ td [] [ text item.source.name ]
|
||||||
]
|
]
|
||||||
:: packageDetails
|
:: packageDetails
|
||||||
|
|
|
@ -221,7 +221,10 @@ viewResultItem channel show item =
|
||||||
-- DEBUG: ]
|
-- DEBUG: ]
|
||||||
-- DEBUG: ]
|
-- DEBUG: ]
|
||||||
|> List.append
|
|> List.append
|
||||||
(tr [ onClick (SearchMsg (Search.ShowDetails item.source.attr_name)) ]
|
(tr
|
||||||
|
[ onClick (SearchMsg (Search.ShowDetails item.source.attr_name))
|
||||||
|
, Search.elementId item.source.attr_name
|
||||||
|
]
|
||||||
[ td [] [ text <| item.source.attr_name ]
|
[ td [] [ text <| item.source.attr_name ]
|
||||||
, td [] [ text item.source.pname ]
|
, td [] [ text item.source.pname ]
|
||||||
, td [] [ text item.source.pversion ]
|
, td [] [ text item.source.pversion ]
|
||||||
|
|
|
@ -8,6 +8,7 @@ module Search exposing
|
||||||
, channelDetailsFromId
|
, channelDetailsFromId
|
||||||
, channels
|
, channels
|
||||||
, decodeResult
|
, decodeResult
|
||||||
|
, elementId
|
||||||
, fromSortId
|
, fromSortId
|
||||||
, init
|
, init
|
||||||
, makeRequest
|
, makeRequest
|
||||||
|
@ -168,6 +169,11 @@ ensureLoading model =
|
||||||
model
|
model
|
||||||
|
|
||||||
|
|
||||||
|
elementId : String -> Html.Attribute msg
|
||||||
|
elementId str =
|
||||||
|
Html.Attributes.id <| "result-" ++ str
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- ---------------------------
|
-- ---------------------------
|
||||||
-- UPDATE
|
-- UPDATE
|
||||||
|
@ -185,6 +191,17 @@ type Msg a
|
||||||
| ChangePage Int
|
| ChangePage Int
|
||||||
|
|
||||||
|
|
||||||
|
scrollToEntry : Maybe String -> Cmd (Msg a)
|
||||||
|
scrollToEntry val =
|
||||||
|
let
|
||||||
|
doScroll id =
|
||||||
|
Browser.Dom.getElement ("result-" ++ id)
|
||||||
|
|> Task.andThen (\{ element } -> Browser.Dom.setViewport element.x element.y)
|
||||||
|
|> Task.attempt (always NoOp)
|
||||||
|
in
|
||||||
|
Maybe.withDefault Cmd.none <| Maybe.map doScroll val
|
||||||
|
|
||||||
|
|
||||||
update :
|
update :
|
||||||
Route.SearchRoute
|
Route.SearchRoute
|
||||||
-> Browser.Navigation.Key
|
-> Browser.Navigation.Key
|
||||||
|
@ -226,7 +243,7 @@ update toRoute navKey msg model =
|
||||||
|
|
||||||
QueryResponse result ->
|
QueryResponse result ->
|
||||||
( { model | result = result }
|
( { model | result = result }
|
||||||
, Cmd.none
|
, scrollToEntry model.show
|
||||||
)
|
)
|
||||||
|
|
||||||
ShowDetails selected ->
|
ShowDetails selected ->
|
||||||
|
|
Loading…
Reference in a new issue