Change url to search query
This commit is contained in:
parent
24640dda7f
commit
6d17cefabe
|
@ -6,6 +6,7 @@ import Data.Text (Text)
|
|||
import Data.Aeson (FromJSON)
|
||||
import Data.Int (Int64)
|
||||
import Data.Time.Clock (UTCTime)
|
||||
import Data.JSString (JSString)
|
||||
import Miso (URI)
|
||||
|
||||
import qualified Component.CatalogGrid as Grid
|
||||
|
@ -34,5 +35,5 @@ data Action
|
|||
| SearchAction Search.Action
|
||||
| GoToTime UTCTime
|
||||
| ChangeURI URI
|
||||
| SearchResults
|
||||
| SearchResults JSString
|
||||
| NoAction
|
||||
|
|
|
@ -58,7 +58,7 @@ update iface (SearchResult result) model = model <# do
|
|||
Nothing -> return $ passAction iface $ PassPostsToSelf []
|
||||
|
||||
update iface (PassPostsToSelf search_results) model = model { displayResults = search_results } <#
|
||||
return (searchResults iface)
|
||||
(return $ (searchResults iface) (searchTerm model))
|
||||
|
||||
update _ NoAction m = noEff m
|
||||
|
||||
|
|
|
@ -22,5 +22,5 @@ data Model = Model
|
|||
data Interface a = Interface
|
||||
{ passAction :: Action -> a
|
||||
, clientIface :: Client.Interface a [ CatalogPost ]
|
||||
, searchResults :: a
|
||||
, searchResults :: JSString -> a
|
||||
}
|
||||
|
|
15
src/Main.hs
15
src/Main.hs
|
@ -9,12 +9,12 @@ import Data.Proxy
|
|||
import Data.Maybe (maybe, fromJust)
|
||||
import Data.Text (Text)
|
||||
import qualified Data.Text as T
|
||||
import Network.URI (uriPath)
|
||||
import Network.URI (uriPath, uriQuery, escapeURIString, isAllowedInURI)
|
||||
import System.FilePath ((</>))
|
||||
import Data.Time.Clock (UTCTime, getCurrentTime)
|
||||
|
||||
import Data.Aeson (FromJSON)
|
||||
import Data.JSString (pack, append)
|
||||
import Data.JSString (pack, append, unpack)
|
||||
import Miso
|
||||
( View
|
||||
, startApp
|
||||
|
@ -271,7 +271,16 @@ mainUpdate (SearchAction sa) m =
|
|||
Search.update iSearch sa (search_model m)
|
||||
>>= \sm -> noEff m { search_model = sm }
|
||||
|
||||
-- mainUpdate (SearchResults result_posts) m = -- TODO
|
||||
mainUpdate (SearchResults query) m = m { current_uri = new_current_uri } <# do
|
||||
pushURI new_current_uri
|
||||
return NoAction
|
||||
|
||||
where
|
||||
new_current_uri :: URI
|
||||
new_current_uri = (current_uri m)
|
||||
{ uriPath = "/search"
|
||||
, uriQuery = "?search=" ++ (escapeURIString isAllowedInURI $ unpack query)
|
||||
}
|
||||
|
||||
iGrid :: Grid.Interface Action
|
||||
iGrid = Grid.Interface
|
||||
|
|
Loading…
Reference in New Issue