Add some stuff to part10
This commit is contained in:
@@ -3,9 +3,11 @@ module ElmHub exposing (..)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (class, target, href, property, defaultValue)
|
||||
import Html.Events exposing (..)
|
||||
import Html.App as Html
|
||||
import Auth
|
||||
import Json.Decode exposing (Decoder)
|
||||
import Json.Decode.Pipeline exposing (..)
|
||||
import SearchOptions
|
||||
|
||||
|
||||
getQueryString : String -> String
|
||||
@@ -35,6 +37,7 @@ type alias Model =
|
||||
{ query : String
|
||||
, results : List SearchResult
|
||||
, errorMessage : Maybe String
|
||||
, searchOptions : SearchOptions.Model
|
||||
}
|
||||
|
||||
|
||||
@@ -50,9 +53,16 @@ initialModel =
|
||||
{ query = "tutorial"
|
||||
, results = []
|
||||
, errorMessage = Nothing
|
||||
, searchOptions = SearchOptions.initialModel
|
||||
}
|
||||
|
||||
|
||||
viewAdvancedSearch : Model -> Html Msg
|
||||
viewAdvancedSearch model =
|
||||
SearchOptions.view model.searchOptions
|
||||
|> Html.map SearchOptionsMsg
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div [ class "content" ]
|
||||
@@ -90,6 +100,7 @@ viewSearchResult result =
|
||||
|
||||
type Msg
|
||||
= Search
|
||||
| SearchOptionsMsg SearchOptions.Msg
|
||||
| SetQuery String
|
||||
| DeleteById Int
|
||||
| HandleSearchResponse (List SearchResult)
|
||||
@@ -103,6 +114,19 @@ update searchFeed msg model =
|
||||
Search ->
|
||||
( model, searchFeed (getQueryString model.query) )
|
||||
|
||||
SearchOptionsMsg advancedSearchMsg ->
|
||||
let
|
||||
newSearchOptions =
|
||||
-- TODO call SearchOptions.update
|
||||
-- to determine our new searchOptions value.
|
||||
--
|
||||
-- model.searchOptions
|
||||
SearchOptions.update advancedSearchMsg model.searchOptions
|
||||
in
|
||||
-- TODO update our model to use the newSearchOptions value above.
|
||||
-- ( model, Cmd.none )
|
||||
( { model | searchOptions = newSearchOptions }, Cmd.none )
|
||||
|
||||
SetQuery query ->
|
||||
( { model | query = query }, Cmd.none )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user