Skip to content

Commit

Permalink
added comment preview
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismelman committed Jan 3, 2013
1 parent 8f8f08b commit 72d5a2f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
7 changes: 7 additions & 0 deletions comment/ac.app
Expand Up @@ -20,6 +20,9 @@ access control rules
rule ajaxtemplate commentAdditionInput(i : Issue) {
loggedIn

rule action updateCommentPreview(d : WikiText) {
loggedIn
}
rule action comment(text : WikiText, issue : Issue) {
loggedIn &&
mayAccess(issue.project)
Expand All @@ -40,4 +43,8 @@ access control rules
!im.target.project.private ||
principal in im.target.project.members
}

rule ajaxtemplate commentPreview(d : WikiText) {
loggedIn
}

18 changes: 17 additions & 1 deletion comment/comment.app
Expand Up @@ -84,13 +84,22 @@ section view
}

ajax template commentAdditionInput(i : Issue) {

action ignore-validation updateCommentPreview(d : WikiText) {
replace(commentPreview, commentPreview(d));
}

var newCommentText : WikiText := "";
pageHeader3 { "New Comment" }
horizontalForm {
par { input(newCommentText) }
par { input(newCommentText)[onkeyup := updateCommentPreview(newCommentText)] }
if(!i.open) {
par { "This issue is closed! Are you sure you want to add a comment?" }
}

div [class="Block"] {
placeholder commentPreview {}
}
formActions {
submitlink comment(newCommentText, i) [class="btn"] { "Post Comment" }
" "
Expand All @@ -110,6 +119,13 @@ section view
}
}

ajax template commentPreview(d : WikiText) {
group("Preview") {
block { // Needed to work around placeholder content displacement
output(d)
}
}
}
template noCommentAddition() {
par { <i> "Log in to post comments" </i> }
}
Expand Down

0 comments on commit 72d5a2f

Please sign in to comment.