Save search results inside the Search component
- still not displaying results - still need to change url - fails because mainUpdate doesn't handle search result action (event)
This commit is contained in:
parent
cd01e255b3
commit
24640dda7f
|
@ -34,5 +34,5 @@ data Action
|
||||||
| SearchAction Search.Action
|
| SearchAction Search.Action
|
||||||
| GoToTime UTCTime
|
| GoToTime UTCTime
|
||||||
| ChangeURI URI
|
| ChangeURI URI
|
||||||
| SearchResults [ CatalogPost ]
|
| SearchResults
|
||||||
| NoAction
|
| NoAction
|
||||||
|
|
|
@ -25,6 +25,7 @@ import Miso
|
||||||
, (<#)
|
, (<#)
|
||||||
, consoleLog
|
, consoleLog
|
||||||
, noEff
|
, noEff
|
||||||
|
, batchEff
|
||||||
)
|
)
|
||||||
import Data.JSString (pack)
|
import Data.JSString (pack)
|
||||||
import qualified Network.Client as Client
|
import qualified Network.Client as Client
|
||||||
|
@ -53,8 +54,11 @@ update iface (SearchResult result) model = model <# do
|
||||||
consoleLog $ (pack $ show $ body)
|
consoleLog $ (pack $ show $ body)
|
||||||
|
|
||||||
case body of
|
case body of
|
||||||
Just b -> return $ (searchResults iface) b
|
Just catlg_posts -> return $ passAction iface $ PassPostsToSelf catlg_posts
|
||||||
Nothing -> return $ (searchResults iface) []
|
Nothing -> return $ passAction iface $ PassPostsToSelf []
|
||||||
|
|
||||||
|
update iface (PassPostsToSelf search_results) model = model { displayResults = search_results } <#
|
||||||
|
return (searchResults iface)
|
||||||
|
|
||||||
update _ NoAction m = noEff m
|
update _ NoAction m = noEff m
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,17 @@ data Action
|
||||||
= SearchChange JSString
|
= SearchChange JSString
|
||||||
| OnSubmit
|
| OnSubmit
|
||||||
| SearchResult (HttpResult [ CatalogPost ])
|
| SearchResult (HttpResult [ CatalogPost ])
|
||||||
| DisplayResults [ CatalogPost ]
|
| PassPostsToSelf [ CatalogPost ] -- I think I don't understand something about the update type but I had to add this...
|
||||||
| NoAction
|
| NoAction
|
||||||
|
|
||||||
data Model = Model
|
data Model = Model
|
||||||
{ searchTerm :: JSString
|
{ searchTerm :: JSString
|
||||||
, clientModel :: Client.Model
|
, clientModel :: Client.Model
|
||||||
|
, displayResults :: [ CatalogPost ]
|
||||||
} deriving Eq
|
} deriving Eq
|
||||||
|
|
||||||
data Interface a = Interface
|
data Interface a = Interface
|
||||||
{ passAction :: Action -> a
|
{ passAction :: Action -> a
|
||||||
, clientIface :: Client.Interface a [ CatalogPost ]
|
, clientIface :: Client.Interface a [ CatalogPost ]
|
||||||
, searchResults :: [ CatalogPost ] -> a
|
, searchResults :: a
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,7 @@ initialModel pgroot client_fetch_count media_root u t = Model
|
||||||
, search_model = Search.Model
|
, search_model = Search.Model
|
||||||
{ Search.searchTerm = ""
|
{ Search.searchTerm = ""
|
||||||
, Search.clientModel = client_model_
|
, Search.clientModel = client_model_
|
||||||
|
, Search.displayResults = []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue