Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
List channel as button group
also fixes problem showing result when query is empty string

fixes #92
  • Loading branch information
garbas committed Jun 12, 2020
1 parent 9f3de34 commit ba33506
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/Main.elm
Expand Up @@ -114,7 +114,7 @@ submitQuery :
submitQuery old ( new, cmd ) =
let
triggerSearch _ newModel msg makeRequest =
if newModel.query /= Nothing then
if newModel.query /= Nothing && newModel.query /= Just "" then
( new
, Cmd.batch
[ cmd
Expand Down
76 changes: 47 additions & 29 deletions src/Search.elm
Expand Up @@ -36,7 +36,8 @@ import Html
)
import Html.Attributes
exposing
( class
( attribute
, class
, classList
, href
, type_
Expand Down Expand Up @@ -163,16 +164,25 @@ update path navKey msg model =
ChannelChange channel ->
( { model
| channel = channel
, result = RemoteData.Loading
, result =
if model.query == Nothing || model.query == Just "" then
RemoteData.NotAsked

else
RemoteData.Loading
}
, createUrl
path
channel
model.query
model.show
0
model.size
|> Browser.Navigation.pushUrl navKey
, if model.query == Nothing || model.query == Just "" then
Cmd.none

else
createUrl
path
channel
model.query
model.show
0
model.size
|> Browser.Navigation.pushUrl navKey
)

QueryInput query ->
Expand Down Expand Up @@ -321,37 +331,45 @@ view path title model viewSuccess outMsg =
[ h1 [ class "page-header" ] [ text title ]
, div [ class "search-input" ]
[ form [ onSubmit (outMsg QuerySubmit) ]
[ div [ class "input-append" ]
[ input
[ type_ "text"
, onInput (\x -> outMsg (QueryInput x))
, value <| Maybe.withDefault "" model.query
]
[]
, div [ class "btn-group" ]
[ button [ class "btn" ] [ text "Search" ]
]
]
, span []
[ p
[]
[ strong []
[ text " in " ]
, select
[ onInput (\x -> outMsg (ChannelChange x)) ]
[ text "Channel: " ]
, div
[ class "btn-group"
, attribute "data-toggle" "buttons-radio"
]
(List.filterMap
(\channel_id ->
channelDetailsFromId channel_id
|> Maybe.map
(\channel ->
option
[ value channel.id
button
[ type_ "button"
, classList
[ ( "btn", True )
, ( "active", channel.id == model.channel )
]
, onClick <| outMsg (ChannelChange channel.id)
]
[ text channel.title ]
)
)
channels
)
, strong []
[ text " channel." ]
]
, p
[ class "input-append"
]
[ input
[ type_ "text"
, onInput (\x -> outMsg (QueryInput x))
, value <| Maybe.withDefault "" model.query
]
[]
, div [ class "btn-group" ]
[ button [ class "btn" ] [ text "Search" ]
]
]
]
]
Expand Down
10 changes: 7 additions & 3 deletions src/index.scss
Expand Up @@ -35,14 +35,18 @@ header .navbar.navbar-static-top {
.input-append input {
font-size: 24px;
height: 40px;
width: 10em;
width: auto;
max-width: 15em;
}
.input-append button {
font-size: 24px;
height: 50px;
min-width: 4em;
}
select {
width: 100px;
form > p > strong {
vertical-align: middle;
font-size: 1.2em;
margin-left: 0.2em;
}
}
.search-result {
Expand Down

0 comments on commit ba33506

Please sign in to comment.