first pass at alert buttons
They work fine. But I had to go to a lot of trouble to get Yesod to render routes in a pure function. It may instead make more sense to have each alert have an assocated IO action, and a single route that runs the IO action of a given alert id. I just wish I'd realized that before the past several hours of struggling with something Yesod really doesn't want to allow.
This commit is contained in:
parent
e6e0877378
commit
e59b0a1c88
9 changed files with 100 additions and 41 deletions
|
@ -20,6 +20,7 @@ import Yesod
|
|||
import Text.Hamlet
|
||||
import Data.Text (Text)
|
||||
import Control.Concurrent.STM
|
||||
import Control.Concurrent
|
||||
|
||||
data NavBarItem = DashBoard | Config | About
|
||||
deriving (Eq)
|
||||
|
@ -116,3 +117,18 @@ webAppFormAuthToken = do
|
|||
- With noscript, clicking it GETs the Route. -}
|
||||
actionButton :: Route WebApp -> (Maybe String) -> String -> String -> Widget
|
||||
actionButton route label buttonclass iconclass = $(widgetFile "actionbutton")
|
||||
|
||||
type UrlRenderFunc = Route WebApp -> [(Text, Text)] -> Text
|
||||
type UrlRenderer = MVar (UrlRenderFunc)
|
||||
|
||||
newUrlRenderer :: IO UrlRenderer
|
||||
newUrlRenderer = newEmptyMVar
|
||||
|
||||
setUrlRenderer :: UrlRenderer -> (UrlRenderFunc) -> IO ()
|
||||
setUrlRenderer = putMVar
|
||||
|
||||
{- Blocks until the webapp is running and has called setUrlRenderer. -}
|
||||
renderUrl :: UrlRenderer -> Route WebApp -> [(Text, Text)] -> IO Text
|
||||
renderUrl urlrenderer route params = do
|
||||
r <- readMVar urlrenderer
|
||||
return $ r route params
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue