user attr_name and option_name for showDetailsFor (#83)

fixes #61

showDetailsFor -> show
This commit is contained in:
Rok Garbas 2020-06-10 14:15:54 +02:00 committed by GitHub
parent 6905ea40dd
commit 12bea73597
Failed to generate hash of commit
5 changed files with 34 additions and 35 deletions

View file

@ -177,13 +177,13 @@ changeRouteTo model url =
-- on the home page -- on the home page
( newModel, Browser.Navigation.pushUrl newModel.navKey "/packages" ) ( newModel, Browser.Navigation.pushUrl newModel.navKey "/packages" )
Just (Route.Packages channel query showDetailsFor from size) -> Just (Route.Packages channel query show from size) ->
Page.Packages.init channel query showDetailsFor from size Page.Packages.init channel query show from size
|> updateWith Packages PackagesMsg newModel |> updateWith Packages PackagesMsg newModel
|> submitQuery newModel |> submitQuery newModel
Just (Route.Options channel query showDetailsFor from size) -> Just (Route.Options channel query show from size) ->
Page.Options.init channel query showDetailsFor from size Page.Options.init channel query show from size
|> updateWith Options OptionsMsg newModel |> updateWith Options OptionsMsg newModel
|> submitQuery newModel |> submitQuery newModel

View file

@ -32,7 +32,6 @@ import Html.Attributes
( class ( class
, colspan , colspan
, href , href
, property
) )
import Html.Events import Html.Events
exposing exposing
@ -113,7 +112,7 @@ viewSuccess :
-> Maybe String -> Maybe String
-> Search.Result ResultItemSource -> Search.Result ResultItemSource
-> Html Msg -> Html Msg
viewSuccess channel showDetailsFor result = viewSuccess channel show result =
div [ class "search-result" ] div [ class "search-result" ]
[ table [ class "table table-hover" ] [ table [ class "table table-hover" ]
[ thead [] [ thead []
@ -124,7 +123,7 @@ viewSuccess channel showDetailsFor result =
, tbody , tbody
[] []
(List.concatMap (List.concatMap
(viewResultItem showDetailsFor) (viewResultItem show)
result.hits.hits result.hits.hits
) )
] ]
@ -135,17 +134,17 @@ viewResultItem :
Maybe String Maybe String
-> Search.ResultItem ResultItemSource -> Search.ResultItem ResultItemSource
-> List (Html Msg) -> List (Html Msg)
viewResultItem showDetailsFor item = viewResultItem show item =
let let
packageDetails = packageDetails =
if Just item.id == showDetailsFor then if Just item.source.name == show then
[ td [ colspan 1 ] [ viewResultItemDetails item ] [ td [ colspan 1 ] [ viewResultItemDetails item ]
] ]
else else
[] []
in in
tr [ onClick (SearchMsg (Search.ShowDetails item.id)) ] tr [ onClick (SearchMsg (Search.ShowDetails item.source.name)) ]
[ td [] [ text item.source.name ] [ td [] [ text item.source.name ]
] ]
:: packageDetails :: packageDetails

View file

@ -149,7 +149,7 @@ viewSuccess :
-> Maybe String -> Maybe String
-> Search.Result ResultItemSource -> Search.Result ResultItemSource
-> Html Msg -> Html Msg
viewSuccess channel showDetailsFor result = viewSuccess channel show result =
div [ class "search-result" ] div [ class "search-result" ]
[ table [ class "table table-hover" ] [ table [ class "table table-hover" ]
[ thead [] [ thead []
@ -163,7 +163,7 @@ viewSuccess channel showDetailsFor result =
, tbody , tbody
[] []
(List.concatMap (List.concatMap
(viewResultItem channel showDetailsFor) (viewResultItem channel show)
result.hits.hits result.hits.hits
) )
] ]
@ -175,17 +175,17 @@ viewResultItem :
-> Maybe String -> Maybe String
-> Search.ResultItem ResultItemSource -> Search.ResultItem ResultItemSource
-> List (Html Msg) -> List (Html Msg)
viewResultItem channel showDetailsFor item = viewResultItem channel show item =
let let
packageDetails = packageDetails =
if Just item.id == showDetailsFor then if Just item.source.attr_name == show then
[ td [ colspan 4 ] [ viewResultItemDetails channel item ] [ td [ colspan 4 ] [ viewResultItemDetails channel item ]
] ]
else else
[] []
in 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.attr_name ]
, td [] [ text item.source.pname ] , td [] [ text item.source.pname ]
, td [] [ text item.source.pversion ] , td [] [ text item.source.pversion ]

View file

@ -33,7 +33,7 @@ parser =
(Url.Parser.s "packages" (Url.Parser.s "packages"
<?> Url.Parser.Query.string "channel" <?> Url.Parser.Query.string "channel"
<?> Url.Parser.Query.string "query" <?> Url.Parser.Query.string "query"
<?> Url.Parser.Query.string "showDetailsFor" <?> Url.Parser.Query.string "show"
<?> Url.Parser.Query.int "from" <?> Url.Parser.Query.int "from"
<?> Url.Parser.Query.int "size" <?> Url.Parser.Query.int "size"
) )
@ -42,7 +42,7 @@ parser =
(Url.Parser.s "options" (Url.Parser.s "options"
<?> Url.Parser.Query.string "channel" <?> Url.Parser.Query.string "channel"
<?> Url.Parser.Query.string "query" <?> Url.Parser.Query.string "query"
<?> Url.Parser.Query.string "showDetailsFor" <?> Url.Parser.Query.string "show"
<?> Url.Parser.Query.int "from" <?> Url.Parser.Query.int "from"
<?> Url.Parser.Query.int "size" <?> Url.Parser.Query.int "size"
) )
@ -94,21 +94,21 @@ routeToPieces page =
NotFound -> NotFound ->
( [ "not-found" ], [] ) ( [ "not-found" ], [] )
Packages channel query showDetailsFor from size -> Packages channel query show from size ->
( [ "packages" ] ( [ "packages" ]
, [ channel , [ channel
, query , query
, showDetailsFor , show
, Maybe.map String.fromInt from , Maybe.map String.fromInt from
, Maybe.map String.fromInt size , Maybe.map String.fromInt size
] ]
) )
Options channel query showDetailsFor from size -> Options channel query show from size ->
( [ "options" ] ( [ "options" ]
, [ channel , [ channel
, query , query
, showDetailsFor , show
, Maybe.map String.fromInt from , Maybe.map String.fromInt from
, Maybe.map String.fromInt size , Maybe.map String.fromInt size
] ]

View file

@ -61,7 +61,7 @@ type alias Model a =
{ channel : String { channel : String
, query : Maybe String , query : Maybe String
, result : RemoteData.WebData (Result a) , result : RemoteData.WebData (Result a)
, showDetailsFor : Maybe String , show : Maybe String
, from : Int , from : Int
, size : Int , size : Int
} }
@ -100,11 +100,11 @@ init :
-> Maybe Int -> Maybe Int
-> Maybe Int -> Maybe Int
-> ( Model a, Cmd msg ) -> ( Model a, Cmd msg )
init channel query showDetailsFor from size = init channel query show from size =
( { channel = Maybe.withDefault "unstable" channel ( { channel = Maybe.withDefault "unstable" channel
, query = query , query = query
, result = RemoteData.NotAsked , result = RemoteData.NotAsked
, showDetailsFor = showDetailsFor , show = show
, from = Maybe.withDefault 0 from , from = Maybe.withDefault 0 from
, size = Maybe.withDefault 15 size , size = Maybe.withDefault 15 size
} }
@ -149,7 +149,7 @@ update path navKey msg model =
path path
channel channel
model.query model.query
model.showDetailsFor model.show
0 0
model.size model.size
|> Browser.Navigation.pushUrl navKey |> Browser.Navigation.pushUrl navKey
@ -166,7 +166,7 @@ update path navKey msg model =
path path
model.channel model.channel
model.query model.query
model.showDetailsFor model.show
0 0
model.size model.size
|> Browser.Navigation.pushUrl navKey |> Browser.Navigation.pushUrl navKey
@ -183,7 +183,7 @@ update path navKey msg model =
path path
model.channel model.channel
model.query model.query
(if model.showDetailsFor == Just selected then (if model.show == Just selected then
Nothing Nothing
else else
@ -203,7 +203,7 @@ createUrl :
-> Int -> Int
-> Int -> Int
-> String -> String
createUrl path channel query showDetailsFor from size = createUrl path channel query show from size =
[ Url.Builder.int "from" from [ Url.Builder.int "from" from
, Url.Builder.int "size" size , Url.Builder.int "size" size
, Url.Builder.string "channel" channel , Url.Builder.string "channel" channel
@ -217,10 +217,10 @@ createUrl path channel query showDetailsFor from size =
|> Maybe.withDefault [] |> Maybe.withDefault []
) )
|> List.append |> List.append
(showDetailsFor (show
|> Maybe.map |> Maybe.map
(\x -> (\x ->
[ Url.Builder.string "showDetailsFor" x [ Url.Builder.string "show" x
] ]
) )
|> Maybe.withDefault [] |> Maybe.withDefault []
@ -370,7 +370,7 @@ view path title model viewSuccess outMsg =
] ]
] ]
, viewPager outMsg model result path , viewPager outMsg model result path
, viewSuccess model.channel model.showDetailsFor result , viewSuccess model.channel model.show result
, viewPager outMsg model result path , viewPager outMsg model result path
] ]
@ -423,7 +423,7 @@ viewPager outMsg model result path =
path path
model.channel model.channel
model.query model.query
model.showDetailsFor model.show
0 0
model.size model.size
] ]
@ -444,7 +444,7 @@ viewPager outMsg model result path =
path path
model.channel model.channel
model.query model.query
model.showDetailsFor model.show
(model.from - model.size) (model.from - model.size)
model.size model.size
] ]
@ -465,7 +465,7 @@ viewPager outMsg model result path =
path path
model.channel model.channel
model.query model.query
model.showDetailsFor model.show
(model.from + model.size) (model.from + model.size)
model.size model.size
] ]
@ -486,7 +486,7 @@ viewPager outMsg model result path =
path path
model.channel model.channel
model.query model.query
model.showDetailsFor model.show
((result.hits.total.value // model.size) * model.size) ((result.hits.total.value // model.size) * model.size)
model.size model.size
] ]