Add some stuff to part10

This commit is contained in:
Richard Feldman
2016-09-04 23:27:11 -07:00
parent 073bd8c93a
commit 5f75c624b3
2 changed files with 87 additions and 0 deletions

63
part10/SearchOptions.elm Normal file
View File

@@ -0,0 +1,63 @@
module SearchOptions exposing (..)
import Html exposing (..)
import Html.Attributes exposing (class, checked, type', defaultValue)
import Html.Events exposing (..)
import String
view : Model -> Html Msg
view model =
div []
[ input [ type' "text", defaultValue model.sort, onInput SetSort ] []
, input [ type' "text", defaultValue model.order, onInput SetOrder ] []
, input [ type' "text", defaultValue (String.join " " model.searchIn) ] []
, input [ type' "checkbox", checked model.includeForks ] []
, input [ type' "text", defaultValue model.userFilter, onInput SetUserFilter ] []
]
type alias Model =
{ sort : String
, order : String
, searchIn : List String
, includeForks : Bool
, userFilter : String
}
type Msg
= SetSort String
| SetOrder String
| SetSearchIn (List String)
| SetIncludeForks Bool
| SetUserFilter String
update : Msg -> Model -> Model
update msg model =
case msg of
SetSort sort ->
{ model | sort = sort }
SetOrder order ->
{ model | order = order }
SetSearchIn searchIn ->
{ model | searchIn = searchIn }
SetIncludeForks includeForks ->
{ model | includeForks = includeForks }
SetUserFilter userFilter ->
{ model | userFilter = userFilter }
initialModel : Model
initialModel =
{ sort = ""
, order = ""
, searchIn = []
, includeForks = True
, userFilter = ""
}