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 )
|
-> ( Model, Cmd Msg )
|
||||||
changeRouteTo model url =
|
changeRouteTo model url =
|
||||||
let
|
let
|
||||||
|
cleanUrl =
|
||||||
|
if url.fragment == Just "disabled" then
|
||||||
|
{ url | fragment = Nothing }
|
||||||
|
|
||||||
|
else
|
||||||
|
url
|
||||||
|
|
||||||
newModel =
|
newModel =
|
||||||
{ model | url = url }
|
{ model | url = cleanUrl }
|
||||||
|
|
||||||
maybeRoute =
|
maybeRoute =
|
||||||
Route.fromUrl url
|
Route.fromUrl url
|
||||||
|
@ -196,7 +203,13 @@ changeRouteTo model url =
|
||||||
in
|
in
|
||||||
Page.Packages.init channel query show from size sort modelPage
|
Page.Packages.init channel query show from size sort modelPage
|
||||||
|> updateWith Packages PackagesMsg newModel
|
|> 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) ->
|
Just (Route.Options channel query show from size sort) ->
|
||||||
let
|
let
|
||||||
|
@ -210,7 +223,13 @@ changeRouteTo model url =
|
||||||
in
|
in
|
||||||
Page.Options.init channel query show from size sort modelPage
|
Page.Options.init channel query show from size sort modelPage
|
||||||
|> updateWith Options OptionsMsg newModel
|
|> 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 )
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
|
|
|
@ -237,7 +237,12 @@ viewResultItemDetails channel item =
|
||||||
wrapWith value
|
wrapWith value
|
||||||
in
|
in
|
||||||
dl [ class "dl-horizontal" ]
|
dl [ class "dl-horizontal" ]
|
||||||
[ dt [] [ text "Description" ]
|
[ dt [] [ text "Name" ]
|
||||||
|
, dd []
|
||||||
|
[ item.source.name
|
||||||
|
|> asText
|
||||||
|
]
|
||||||
|
, dt [] [ text "Description" ]
|
||||||
, dd []
|
, dd []
|
||||||
[ item.source.description
|
[ item.source.description
|
||||||
|> Maybe.withDefault default
|
|> Maybe.withDefault default
|
||||||
|
|
|
@ -354,7 +354,11 @@ viewResultItemDetails channel item =
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
dl [ class "dl-horizontal" ]
|
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 ] ]
|
, dd [] [ code [] [ text <| "nix-env -iA nixos." ++ item.source.attr_name ] ]
|
||||||
, dt [] [ text <| "Nix expression" ]
|
, dt [] [ text <| "Nix expression" ]
|
||||||
, dd [] [ withDefault asGithubLink item.source.position ]
|
, dd [] [ withDefault asGithubLink item.source.position ]
|
||||||
|
@ -366,6 +370,8 @@ viewResultItemDetails channel item =
|
||||||
, dd [] [ ul [ class "inline" ] <| List.map showLicence item.source.licenses ]
|
, dd [] [ ul [ class "inline" ] <| List.map showLicence item.source.licenses ]
|
||||||
, dt [] [ text "Maintainers" ]
|
, dt [] [ text "Maintainers" ]
|
||||||
, dd [] [ ul [ class "inline" ] <| List.map showMaintainer item.source.maintainers ]
|
, dd [] [ ul [ class "inline" ] <| List.map showMaintainer item.source.maintainers ]
|
||||||
|
, dt [] [ text "Description" ]
|
||||||
|
, dd [] [ withDefault asText item.source.description ]
|
||||||
, dt [] [ text "Long description" ]
|
, dt [] [ text "Long description" ]
|
||||||
, dd [] [ withDefault asText item.source.longDescription ]
|
, dd [] [ withDefault asText item.source.longDescription ]
|
||||||
]
|
]
|
||||||
|
|
|
@ -268,6 +268,7 @@ update path navKey msg model =
|
||||||
model.from
|
model.from
|
||||||
model.size
|
model.size
|
||||||
model.sort
|
model.sort
|
||||||
|
|> (\x -> x ++ "#disabled")
|
||||||
|> Browser.Navigation.pushUrl navKey
|
|> Browser.Navigation.pushUrl navKey
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue