Make part12 nicer
This commit is contained in:
@@ -37,7 +37,7 @@ type alias Model =
|
|||||||
type alias SearchOptions =
|
type alias SearchOptions =
|
||||||
{ minStars : Int
|
{ minStars : Int
|
||||||
, minStarsError : Maybe String
|
, minStarsError : Maybe String
|
||||||
, searchInDescription : Bool
|
, searchIn : String
|
||||||
, userFilter : String
|
, userFilter : String
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ initialModel =
|
|||||||
, options =
|
, options =
|
||||||
{ minStars = 0
|
{ minStars = 0
|
||||||
, minStarsError = Nothing
|
, minStarsError = Nothing
|
||||||
, searchInDescription = True
|
, searchIn = "name"
|
||||||
, userFilter = ""
|
, userFilter = ""
|
||||||
}
|
}
|
||||||
, tableState = Table.initialSort "Stars"
|
, tableState = Table.initialSort "Stars"
|
||||||
@@ -80,12 +80,12 @@ viewOptions opts =
|
|||||||
-- Debug.log "viewOptions was called" <|
|
-- Debug.log "viewOptions was called" <|
|
||||||
div [ class "search-options" ]
|
div [ class "search-options" ]
|
||||||
[ div [ class "search-option" ]
|
[ div [ class "search-option" ]
|
||||||
[ label [ class "top-label" ] [ text "Minimum Stars" ]
|
[ label [ class "top-label" ] [ text "Search in" ]
|
||||||
, input
|
, select [ onChange SetSearchIn, value opts.searchIn ]
|
||||||
[ onBlurWithTargetValue SetMinStars
|
[ option [ value "name" ] [ text "Name" ]
|
||||||
, defaultValue (toString opts.minStars)
|
, option [ value "description" ] [ text "Description" ]
|
||||||
|
, option [ value "name,description" ] [ text "Name and Description" ]
|
||||||
]
|
]
|
||||||
[]
|
|
||||||
]
|
]
|
||||||
, div [ class "search-option" ]
|
, div [ class "search-option" ]
|
||||||
[ label [ class "top-label" ] [ text "Owned by" ]
|
[ label [ class "top-label" ] [ text "Owned by" ]
|
||||||
@@ -98,10 +98,14 @@ viewOptions opts =
|
|||||||
[]
|
[]
|
||||||
]
|
]
|
||||||
, div [ class "search-option" ]
|
, div [ class "search-option" ]
|
||||||
[ viewMinStarsError opts.minStarsError ]
|
[ label [ class "top-label" ] [ text "Minimum Stars" ]
|
||||||
, label [ class "search-option" ]
|
, input
|
||||||
[ input [ type' "checkbox", checked opts.searchInDescription, onCheck SetSearchInDescription ] []
|
[ type' "text"
|
||||||
, text "Search in description"
|
, onBlurWithTargetValue SetMinStars
|
||||||
|
, defaultValue (toString opts.minStars)
|
||||||
|
]
|
||||||
|
[]
|
||||||
|
, viewMinStarsError opts.minStarsError
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -206,11 +210,11 @@ updateOptions optionsMsg options =
|
|||||||
Err _ ->
|
Err _ ->
|
||||||
{ options
|
{ options
|
||||||
| minStarsError =
|
| minStarsError =
|
||||||
Just "Please enter an integer!"
|
Just "Must be an integer!"
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSearchInDescription searchInDescription ->
|
SetSearchIn searchIn ->
|
||||||
{ options | searchInDescription = searchInDescription }
|
{ options | searchIn = searchIn }
|
||||||
|
|
||||||
SetUserFilter userFilter ->
|
SetUserFilter userFilter ->
|
||||||
{ options | userFilter = userFilter }
|
{ options | userFilter = userFilter }
|
||||||
@@ -269,7 +273,7 @@ viewSearchResult result =
|
|||||||
|
|
||||||
type OptionsMsg
|
type OptionsMsg
|
||||||
= SetMinStars String
|
= SetMinStars String
|
||||||
| SetSearchInDescription Bool
|
| SetSearchIn String
|
||||||
| SetUserFilter String
|
| SetUserFilter String
|
||||||
|
|
||||||
|
|
||||||
@@ -311,11 +315,8 @@ getQueryString model =
|
|||||||
++ Auth.token
|
++ Auth.token
|
||||||
++ "&q="
|
++ "&q="
|
||||||
++ model.query
|
++ model.query
|
||||||
++ (if model.options.searchInDescription then
|
++ "+in:"
|
||||||
"+in:name,description"
|
++ model.options.searchIn
|
||||||
else
|
|
||||||
"+in:name"
|
|
||||||
)
|
|
||||||
++ "+stars:>="
|
++ "+stars:>="
|
||||||
++ (toString model.options.minStars)
|
++ (toString model.options.minStars)
|
||||||
++ "+language:elm"
|
++ "+language:elm"
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ button:focus, input:focus {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin-right: 24px;
|
margin-right: 24px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
@@ -111,21 +112,22 @@ button:focus, input:focus {
|
|||||||
.search-input {
|
.search-input {
|
||||||
display: block;
|
display: block;
|
||||||
float: left;
|
float: left;
|
||||||
width: 50%;
|
width: 42%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-options {
|
.search-options {
|
||||||
position: relative;
|
position: relative;
|
||||||
float: right;
|
float: right;
|
||||||
width: 50%;
|
width: 58%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: 20px;
|
padding-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-option {
|
.search-option {
|
||||||
display: block;
|
display: block;
|
||||||
float: left;
|
float: left;
|
||||||
width: 50%;
|
width: 30%;
|
||||||
|
margin-left: 16px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user