add create-challenge form
This commit is contained in:
parent
765dddc644
commit
f00df0797f
@ -34,6 +34,7 @@ import Yesod.Fay (getFaySite)
|
|||||||
import Handler.Common
|
import Handler.Common
|
||||||
import Handler.Fay
|
import Handler.Fay
|
||||||
import Handler.Home
|
import Handler.Home
|
||||||
|
import Handler.CreateChallenge
|
||||||
|
|
||||||
-- This line actually creates our YesodDispatch instance. It is the second half
|
-- This line actually creates our YesodDispatch instance. It is the second half
|
||||||
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the
|
||||||
|
36
Handler/CreateChallenge.hs
Normal file
36
Handler/CreateChallenge.hs
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
module Handler.CreateChallenge where
|
||||||
|
|
||||||
|
import Import
|
||||||
|
import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
|
||||||
|
withSmallInput)
|
||||||
|
|
||||||
|
getCreateChallengeR :: Handler Html
|
||||||
|
getCreateChallengeR = do
|
||||||
|
(formWidget, formEnctype) <- generateFormPost sampleForm
|
||||||
|
let submission = Nothing :: Maybe (FileInfo, Text)
|
||||||
|
handlerName = "getCreateChallengeR" :: Text
|
||||||
|
defaultLayout $ do
|
||||||
|
aDomId <- newIdent
|
||||||
|
setTitle "Welcome To Yesod!"
|
||||||
|
$(widgetFile "create-challenge")
|
||||||
|
|
||||||
|
postCreateChallengeR :: Handler Html
|
||||||
|
postCreateChallengeR = do
|
||||||
|
((result, formWidget), formEnctype) <- runFormPost sampleForm
|
||||||
|
let handlerName = "postCreateChallengeR" :: Text
|
||||||
|
challengeData = case result of
|
||||||
|
FormSuccess res -> Just res
|
||||||
|
_ -> Nothing
|
||||||
|
|
||||||
|
defaultLayout $ do
|
||||||
|
aDomId <- newIdent
|
||||||
|
setTitle "Welcome To Yesod!"
|
||||||
|
$(widgetFile "creating-challenge")
|
||||||
|
|
||||||
|
sampleForm :: Form (Text, Text, Text, Text, Text)
|
||||||
|
sampleForm = renderBootstrap3 BootstrapBasicForm $ (,,,,)
|
||||||
|
<$> areq textField (fieldSettingsLabel MsgName) Nothing
|
||||||
|
<*> areq textField (fieldSettingsLabel MsgPublicUrl) Nothing
|
||||||
|
<*> areq textField (fieldSettingsLabel MsgBranch) Nothing
|
||||||
|
<*> areq textField (fieldSettingsLabel MsgPrivateUrl) Nothing
|
||||||
|
<*> areq textField (fieldSettingsLabel MsgBranch) Nothing
|
@ -6,3 +6,5 @@
|
|||||||
/robots.txt RobotsR GET
|
/robots.txt RobotsR GET
|
||||||
|
|
||||||
/ HomeR GET POST
|
/ HomeR GET POST
|
||||||
|
|
||||||
|
/create-challenge CreateChallengeR GET POST
|
||||||
|
@ -23,6 +23,7 @@ library
|
|||||||
Settings.StaticFiles
|
Settings.StaticFiles
|
||||||
SharedTypes
|
SharedTypes
|
||||||
Handler.Common
|
Handler.Common
|
||||||
|
Handler.CreateChallenge
|
||||||
Handler.Fay
|
Handler.Fay
|
||||||
Handler.Home
|
Handler.Home
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
LogIn: log in
|
LogIn: log in
|
||||||
LogOut: log out
|
LogOut: log out
|
||||||
LoggedAs: logged as
|
LoggedAs: logged as
|
||||||
|
CreateChallenge: add a challenge
|
||||||
|
Name: name
|
||||||
|
PublicUrl: public repo (URL)
|
||||||
|
PrivateUrl: private repo (URL)
|
||||||
|
Branch: branch
|
||||||
|
Add: Add!
|
||||||
|
7
templates/create-challenge.hamlet
Normal file
7
templates/create-challenge.hamlet
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<h2>Add a challenge!
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<form method=post action=@{CreateChallengeR}#form enctype=#{formEnctype}>
|
||||||
|
^{formWidget}
|
||||||
|
<button .btn .btn-primary type="submit">
|
||||||
|
_{MsgAdd} <span class="glyphicon glyphicon-upload"></span>
|
2
templates/creating-challenge.hamlet
Normal file
2
templates/creating-challenge.hamlet
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
$maybe (name, publicUrl, publicBranch, privateUrl, privateUrl) <- challengeData
|
||||||
|
<p>Cloning #{publicUrl}
|
@ -1,6 +1,7 @@
|
|||||||
<div id="heading">
|
<div id="heading">
|
||||||
$maybe user <- maybeUser
|
$maybe user <- maybeUser
|
||||||
_{MsgLoggedAs} #{userIdent $ entityVal user}
|
_{MsgLoggedAs} #{userIdent $ entityVal user}
|
||||||
|
\ | <a href="@{CreateChallengeR}">_{MsgCreateChallenge}</a>
|
||||||
\ | <a href="@{AuthR LogoutR}">_{MsgLogOut}</a>
|
\ | <a href="@{AuthR LogoutR}">_{MsgLogOut}</a>
|
||||||
$nothing
|
$nothing
|
||||||
<a href="@{AuthR LoginR}">_{MsgLogIn}</a>
|
<a href="@{AuthR LoginR}">_{MsgLogIn}</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user