diff --git a/src/Main.elm b/src/Main.elm index 56c2a89..685908f 100644 --- a/src/Main.elm +++ b/src/Main.elm @@ -177,13 +177,13 @@ changeRouteTo model url = -- on the home page ( newModel, Browser.Navigation.pushUrl newModel.navKey "/packages" ) - Just (Route.Packages channel query showDetailsFor from size) -> - Page.Packages.init channel query showDetailsFor from size + Just (Route.Packages channel query show from size) -> + Page.Packages.init channel query show from size |> updateWith Packages PackagesMsg newModel |> submitQuery newModel - Just (Route.Options channel query showDetailsFor from size) -> - Page.Options.init channel query showDetailsFor from size + Just (Route.Options channel query show from size) -> + Page.Options.init channel query show from size |> updateWith Options OptionsMsg newModel |> submitQuery newModel diff --git a/src/Page/Options.elm b/src/Page/Options.elm index dfa4d5f..c62d637 100644 --- a/src/Page/Options.elm +++ b/src/Page/Options.elm @@ -32,7 +32,6 @@ import Html.Attributes ( class , colspan , href - , property ) import Html.Events exposing @@ -113,7 +112,7 @@ viewSuccess : -> Maybe String -> Search.Result ResultItemSource -> Html Msg -viewSuccess channel showDetailsFor result = +viewSuccess channel show result = div [ class "search-result" ] [ table [ class "table table-hover" ] [ thead [] @@ -124,7 +123,7 @@ viewSuccess channel showDetailsFor result = , tbody [] (List.concatMap - (viewResultItem showDetailsFor) + (viewResultItem show) result.hits.hits ) ] @@ -135,17 +134,17 @@ viewResultItem : Maybe String -> Search.ResultItem ResultItemSource -> List (Html Msg) -viewResultItem showDetailsFor item = +viewResultItem show item = let packageDetails = - if Just item.id == showDetailsFor then + if Just item.source.name == show then [ td [ colspan 1 ] [ viewResultItemDetails item ] ] else [] in - tr [ onClick (SearchMsg (Search.ShowDetails item.id)) ] + tr [ onClick (SearchMsg (Search.ShowDetails item.source.name)) ] [ td [] [ text item.source.name ] ] :: packageDetails diff --git a/src/Page/Packages.elm b/src/Page/Packages.elm index 356914d..de0edc9 100644 --- a/src/Page/Packages.elm +++ b/src/Page/Packages.elm @@ -149,7 +149,7 @@ viewSuccess : -> Maybe String -> Search.Result ResultItemSource -> Html Msg -viewSuccess channel showDetailsFor result = +viewSuccess channel show result = div [ class "search-result" ] [ table [ class "table table-hover" ] [ thead [] @@ -163,7 +163,7 @@ viewSuccess channel showDetailsFor result = , tbody [] (List.concatMap - (viewResultItem channel showDetailsFor) + (viewResultItem channel show) result.hits.hits ) ] @@ -175,17 +175,17 @@ viewResultItem : -> Maybe String -> Search.ResultItem ResultItemSource -> List (Html Msg) -viewResultItem channel showDetailsFor item = +viewResultItem channel show item = let packageDetails = - if Just item.id == showDetailsFor then + if Just item.source.attr_name == show then [ td [ colspan 4 ] [ viewResultItemDetails channel item ] ] else [] in - tr [ onClick (SearchMsg (Search.ShowDetails item.id)) ] + tr [ onClick (SearchMsg (Search.ShowDetails item.source.attr_name)) ] [ td [] [ text item.source.attr_name ] , td [] [ text item.source.pname ] , td [] [ text item.source.pversion ] diff --git a/src/Route.elm b/src/Route.elm index 2fd44e8..b790d1a 100644 --- a/src/Route.elm +++ b/src/Route.elm @@ -33,7 +33,7 @@ parser = (Url.Parser.s "packages" Url.Parser.Query.string "channel" Url.Parser.Query.string "query" - Url.Parser.Query.string "showDetailsFor" + Url.Parser.Query.string "show" Url.Parser.Query.int "from" Url.Parser.Query.int "size" ) @@ -42,7 +42,7 @@ parser = (Url.Parser.s "options" Url.Parser.Query.string "channel" Url.Parser.Query.string "query" - Url.Parser.Query.string "showDetailsFor" + Url.Parser.Query.string "show" Url.Parser.Query.int "from" Url.Parser.Query.int "size" ) @@ -94,21 +94,21 @@ routeToPieces page = NotFound -> ( [ "not-found" ], [] ) - Packages channel query showDetailsFor from size -> + Packages channel query show from size -> ( [ "packages" ] , [ channel , query - , showDetailsFor + , show , Maybe.map String.fromInt from , Maybe.map String.fromInt size ] ) - Options channel query showDetailsFor from size -> + Options channel query show from size -> ( [ "options" ] , [ channel , query - , showDetailsFor + , show , Maybe.map String.fromInt from , Maybe.map String.fromInt size ] diff --git a/src/Search.elm b/src/Search.elm index d194040..d3b7fc5 100644 --- a/src/Search.elm +++ b/src/Search.elm @@ -61,7 +61,7 @@ type alias Model a = { channel : String , query : Maybe String , result : RemoteData.WebData (Result a) - , showDetailsFor : Maybe String + , show : Maybe String , from : Int , size : Int } @@ -100,11 +100,11 @@ init : -> Maybe Int -> Maybe Int -> ( Model a, Cmd msg ) -init channel query showDetailsFor from size = +init channel query show from size = ( { channel = Maybe.withDefault "unstable" channel , query = query , result = RemoteData.NotAsked - , showDetailsFor = showDetailsFor + , show = show , from = Maybe.withDefault 0 from , size = Maybe.withDefault 15 size } @@ -149,7 +149,7 @@ update path navKey msg model = path channel model.query - model.showDetailsFor + model.show 0 model.size |> Browser.Navigation.pushUrl navKey @@ -166,7 +166,7 @@ update path navKey msg model = path model.channel model.query - model.showDetailsFor + model.show 0 model.size |> Browser.Navigation.pushUrl navKey @@ -183,7 +183,7 @@ update path navKey msg model = path model.channel model.query - (if model.showDetailsFor == Just selected then + (if model.show == Just selected then Nothing else @@ -203,7 +203,7 @@ createUrl : -> Int -> Int -> String -createUrl path channel query showDetailsFor from size = +createUrl path channel query show from size = [ Url.Builder.int "from" from , Url.Builder.int "size" size , Url.Builder.string "channel" channel @@ -217,10 +217,10 @@ createUrl path channel query showDetailsFor from size = |> Maybe.withDefault [] ) |> List.append - (showDetailsFor + (show |> Maybe.map (\x -> - [ Url.Builder.string "showDetailsFor" x + [ Url.Builder.string "show" x ] ) |> Maybe.withDefault [] @@ -370,7 +370,7 @@ view path title model viewSuccess outMsg = ] ] , viewPager outMsg model result path - , viewSuccess model.channel model.showDetailsFor result + , viewSuccess model.channel model.show result , viewPager outMsg model result path ] @@ -423,7 +423,7 @@ viewPager outMsg model result path = path model.channel model.query - model.showDetailsFor + model.show 0 model.size ] @@ -444,7 +444,7 @@ viewPager outMsg model result path = path model.channel model.query - model.showDetailsFor + model.show (model.from - model.size) model.size ] @@ -465,7 +465,7 @@ viewPager outMsg model result path = path model.channel model.query - model.showDetailsFor + model.show (model.from + model.size) model.size ] @@ -486,7 +486,7 @@ viewPager outMsg model result path = path model.channel model.query - model.showDetailsFor + model.show ((result.hits.total.value // model.size) * model.size) model.size ]