start work on editing submissions

This commit is contained in:
Filip Gralinski 2017-02-19 22:26:01 +01:00
parent b6336a65af
commit b7fc462c14
8 changed files with 104 additions and 0 deletions

View File

@ -50,6 +50,7 @@ import Handler.YourAccount
import Handler.AccountReset import Handler.AccountReset
import Handler.Presentation import Handler.Presentation
import Handler.Tags import Handler.Tags
import Handler.EditSubmission
-- 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

31
Handler/EditSubmission.hs Normal file
View File

@ -0,0 +1,31 @@
{-# LANGUAGE TupleSections, OverloadedStrings, RankNTypes #-}
module Handler.EditSubmission where
import Import
import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3, bfs)
getEditSubmissionR :: SubmissionId -> Handler Html
getEditSubmissionR submissionId = do
(formWidget, formEnctype) <- generateFormPost editSubmissionForm
doEditSubmission formWidget formEnctype submissionId
postEditSubmissionR :: SubmissionId -> Handler Html
postEditSubmissionR submissionId = do
((result, formWidget), formEnctype) <- runFormPost editSubmissionForm
doEditSubmission formWidget formEnctype submissionId
doEditSubmission formWidget formEnctype submissionId = do
submission <- runDB $ get404 submissionId
defaultLayout $ do
setTitle "Edit a submission"
$(widgetFile "edit-submission")
editSubmissionForm :: Form (Text, Maybe Text)
editSubmissionForm = renderBootstrap3 BootstrapBasicForm $ (,)
<$> areq textField (bfs MsgSubmissionDescription) Nothing
<*> aopt textField (tagsfs MsgSubmissionTags) Nothing
tagsfs :: RenderMessage site msg => msg -> FieldSettings site
tagsfs msg = attrs { fsAttrs = ("data-role"::Text,"tagsinput"::Text):(fsAttrs attrs)}
where attrs = bfs msg

View File

@ -33,4 +33,6 @@
/tags TagsR GET POST /tags TagsR GET POST
/edit-submission/#SubmissionId EditSubmissionR GET POST
/presentation/4real Presentation4RealR GET /presentation/4real Presentation4RealR GET

View File

@ -46,6 +46,7 @@ library
Handler.AccountReset Handler.AccountReset
Handler.Presentation Handler.Presentation
Handler.Tags Handler.Tags
Handler.EditSubmission
if flag(dev) || flag(library-only) if flag(dev) || flag(library-only)
cpp-options: -DDEVELOPMENT cpp-options: -DDEVELOPMENT

View File

@ -13,6 +13,7 @@ Submit: Submit
SubmissionUrl: Submission repo URL SubmissionUrl: Submission repo URL
SubmissionBranch: Submission repo branch SubmissionBranch: Submission repo branch
SubmissionDescription: Submission description SubmissionDescription: Submission description
SubmissionTags: Submission tags
YourAccount: your account YourAccount: your account
AboutMe: about me AboutMe: about me
AccountName: name AccountName: name

55
static/css/bootstrap-tagsinput.css vendored Normal file
View File

@ -0,0 +1,55 @@
.bootstrap-tagsinput {
background-color: #fff;
border: 1px solid #ccc;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
display: inline-block;
padding: 4px 6px;
color: #555;
vertical-align: middle;
border-radius: 4px;
max-width: 100%;
line-height: 22px;
cursor: text;
}
.bootstrap-tagsinput input {
border: none;
box-shadow: none;
outline: none;
background-color: transparent;
padding: 0 6px;
margin: 0;
width: auto;
max-width: inherit;
}
.bootstrap-tagsinput.form-control input::-moz-placeholder {
color: #777;
opacity: 1;
}
.bootstrap-tagsinput.form-control input:-ms-input-placeholder {
color: #777;
}
.bootstrap-tagsinput.form-control input::-webkit-input-placeholder {
color: #777;
}
.bootstrap-tagsinput input:focus {
border: none;
box-shadow: none;
}
.bootstrap-tagsinput .tag {
margin-right: 2px;
color: white;
}
.bootstrap-tagsinput .tag [data-role="remove"] {
margin-left: 8px;
cursor: pointer;
}
.bootstrap-tagsinput .tag [data-role="remove"]:after {
content: "x";
padding: 0px 2px;
}
.bootstrap-tagsinput .tag [data-role="remove"]:hover {
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05);
}
.bootstrap-tagsinput .tag [data-role="remove"]:hover:active {
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
}

7
static/js/bootstrap-tagsinput.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,6 @@
<p>#{show $ submissionStamp $ submission}
<form method=post action=@{EditSubmissionR submissionId}#form enctype=#{formEnctype}>
^{formWidget}
<button .btn .btn-primary type="submit">
_{MsgSubmit} <span class="glyphicon glyphicon-upload"></span>