Dont reload when showing result item details (#152)
fixes #148 fixes #142 also adding missing fields to package details view
This commit is contained in:
parent
91527f1deb
commit
e4fec33f2b
25
src/Main.elm
25
src/Main.elm
|
@ -158,8 +158,15 @@ changeRouteTo :
|
|||
-> ( Model, Cmd Msg )
|
||||
changeRouteTo model url =
|
||||
let
|
||||
cleanUrl =
|
||||
if url.fragment == Just "disabled" then
|
||||
{ url | fragment = Nothing }
|
||||
|
||||
else
|
||||
url
|
||||
|
||||
newModel =
|
||||
{ model | url = url }
|
||||
{ model | url = cleanUrl }
|
||||
|
||||
maybeRoute =
|
||||
Route.fromUrl url
|
||||
|
@ -196,7 +203,13 @@ changeRouteTo model url =
|
|||
in
|
||||
Page.Packages.init channel query show from size sort modelPage
|
||||
|> updateWith Packages PackagesMsg newModel
|
||||
|> submitQuery newModel
|
||||
|> (\x ->
|
||||
if url.fragment == Just "disabled" then
|
||||
( Tuple.first x, Cmd.none )
|
||||
|
||||
else
|
||||
submitQuery newModel x
|
||||
)
|
||||
|
||||
Just (Route.Options channel query show from size sort) ->
|
||||
let
|
||||
|
@ -210,7 +223,13 @@ changeRouteTo model url =
|
|||
in
|
||||
Page.Options.init channel query show from size sort modelPage
|
||||
|> updateWith Options OptionsMsg newModel
|
||||
|> submitQuery newModel
|
||||
|> (\x ->
|
||||
if url.fragment == Just "disabled" then
|
||||
( Tuple.first x, Cmd.none )
|
||||
|
||||
else
|
||||
submitQuery newModel x
|
||||
)
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||
|
|
|
@ -237,7 +237,12 @@ viewResultItemDetails channel item =
|
|||
wrapWith value
|
||||
in
|
||||
dl [ class "dl-horizontal" ]
|
||||
[ dt [] [ text "Description" ]
|
||||
[ dt [] [ text "Name" ]
|
||||
, dd []
|
||||
[ item.source.name
|
||||
|> asText
|
||||
]
|
||||
, dt [] [ text "Description" ]
|
||||
, dd []
|
||||
[ item.source.description
|
||||
|> Maybe.withDefault default
|
||||
|
|
|
@ -354,7 +354,11 @@ viewResultItemDetails channel item =
|
|||
]
|
||||
in
|
||||
dl [ class "dl-horizontal" ]
|
||||
[ dt [] [ text "Install command" ]
|
||||
[ dt [] [ text "Attribute Name" ]
|
||||
, dd [] [ asText item.source.attr_name ]
|
||||
, dt [] [ text "Name" ]
|
||||
, dd [] [ asText item.source.pname ]
|
||||
, dt [] [ text "Install command" ]
|
||||
, dd [] [ code [] [ text <| "nix-env -iA nixos." ++ item.source.attr_name ] ]
|
||||
, dt [] [ text <| "Nix expression" ]
|
||||
, dd [] [ withDefault asGithubLink item.source.position ]
|
||||
|
@ -366,6 +370,8 @@ viewResultItemDetails channel item =
|
|||
, dd [] [ ul [ class "inline" ] <| List.map showLicence item.source.licenses ]
|
||||
, dt [] [ text "Maintainers" ]
|
||||
, dd [] [ ul [ class "inline" ] <| List.map showMaintainer item.source.maintainers ]
|
||||
, dt [] [ text "Description" ]
|
||||
, dd [] [ withDefault asText item.source.description ]
|
||||
, dt [] [ text "Long description" ]
|
||||
, dd [] [ withDefault asText item.source.longDescription ]
|
||||
]
|
||||
|
|
|
@ -268,6 +268,7 @@ update path navKey msg model =
|
|||
model.from
|
||||
model.size
|
||||
model.sort
|
||||
|> (\x -> x ++ "#disabled")
|
||||
|> Browser.Navigation.pushUrl navKey
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue