when wrong channel is selected (via url) show error (#178)
This commit is contained in:
parent
c12f4dfb6c
commit
2a441c95d9
|
@ -117,7 +117,11 @@ submitQuery :
|
||||||
submitQuery old ( new, cmd ) =
|
submitQuery old ( new, cmd ) =
|
||||||
let
|
let
|
||||||
triggerSearch _ newModel msg makeRequest =
|
triggerSearch _ newModel msg makeRequest =
|
||||||
if newModel.query /= Nothing && newModel.query /= Just "" then
|
if
|
||||||
|
(newModel.query /= Nothing)
|
||||||
|
&& (newModel.query /= Just "")
|
||||||
|
&& List.member newModel.channel Search.channels
|
||||||
|
then
|
||||||
( new
|
( new
|
||||||
, Cmd.batch
|
, Cmd.batch
|
||||||
[ cmd
|
[ cmd
|
||||||
|
|
|
@ -6,6 +6,7 @@ module Search exposing
|
||||||
, SearchResult
|
, SearchResult
|
||||||
, Sort(..)
|
, Sort(..)
|
||||||
, channelDetailsFromId
|
, channelDetailsFromId
|
||||||
|
, channels
|
||||||
, decodeResult
|
, decodeResult
|
||||||
, fromSortId
|
, fromSortId
|
||||||
, init
|
, init
|
||||||
|
@ -463,31 +464,47 @@ view path title model viewSuccess outMsg =
|
||||||
[ form [ onSubmit (outMsg QueryInputSubmit) ]
|
[ form [ onSubmit (outMsg QueryInputSubmit) ]
|
||||||
[ p
|
[ p
|
||||||
[]
|
[]
|
||||||
[ strong []
|
([]
|
||||||
[ text "Channel: " ]
|
|> List.append
|
||||||
, div
|
(if List.member model.channel channels then
|
||||||
[ class "btn-group"
|
[]
|
||||||
, attribute "data-toggle" "buttons-radio"
|
|
||||||
]
|
else
|
||||||
(List.filterMap
|
[ p [ class "alert alert-error" ]
|
||||||
(\channel_id ->
|
[ h4 [] [ text "Wrong channel selected!" ]
|
||||||
channelDetailsFromId channel_id
|
, text <| "Please select one of the channels above!"
|
||||||
|> Maybe.map
|
]
|
||||||
(\channel ->
|
]
|
||||||
button
|
|
||||||
[ type_ "button"
|
|
||||||
, classList
|
|
||||||
[ ( "btn", True )
|
|
||||||
, ( "active", channel.id == model.channel )
|
|
||||||
]
|
|
||||||
, onClick <| outMsg (ChannelChange channel.id)
|
|
||||||
]
|
|
||||||
[ text channel.title ]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
channels
|
|> List.append
|
||||||
)
|
[ p []
|
||||||
]
|
[ strong []
|
||||||
|
[ text "Channel: " ]
|
||||||
|
, div
|
||||||
|
[ class "btn-group"
|
||||||
|
, attribute "data-toggle" "buttons-radio"
|
||||||
|
]
|
||||||
|
(List.filterMap
|
||||||
|
(\channel_id ->
|
||||||
|
channelDetailsFromId channel_id
|
||||||
|
|> Maybe.map
|
||||||
|
(\channel ->
|
||||||
|
button
|
||||||
|
[ type_ "button"
|
||||||
|
, classList
|
||||||
|
[ ( "btn", True )
|
||||||
|
, ( "active", channel.id == model.channel )
|
||||||
|
]
|
||||||
|
, onClick <| outMsg (ChannelChange channel.id)
|
||||||
|
]
|
||||||
|
[ text channel.title ]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
channels
|
||||||
|
)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
)
|
||||||
, p
|
, p
|
||||||
[ class "input-append"
|
[ class "input-append"
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue