Fix added issue comment layout.

This commit is contained in:
shimamoto
2013-06-24 21:29:20 +09:00
parent 9baa09d68b
commit 4000469152
3 changed files with 26 additions and 12 deletions

View File

@@ -69,10 +69,15 @@ trait IssuesControllerBase extends ControllerBase {
val issueId = params("issueId").toInt
val content = params("content") // TODO input check
saveComment(owner, repository, context.loginAccount.get.userName, issueId, content)
contentType = formats("json")
org.json4s.jackson.Serialization.write(Map("content" -> content))
saveComment(owner, repository, context.loginAccount.get.userName, issueId, content) map {
model => org.json4s.jackson.Serialization.write(
Map("commentedUserName" -> model.commentedUserName,
"registeredDate" -> view.helpers.datetime(model.registeredDate),
"content" -> view.Markdown.toHtml(
model.content, getRepository(owner, repository, baseUrl).get, false, true, true)
))
} getOrElse ""
})
}

View File

@@ -53,13 +53,15 @@ trait IssuesService {
def saveComment(owner: String, repository: String, loginUser: String,
issueId: Int, content: String) =
IssueComments.autoInc insert (
owner,
repository,
issueId,
loginUser,
content,
currentDate,
currentDate)
Query(IssueComments) filter {
_.commentId is ( IssueComments.autoInc insert (
owner,
repository,
issueId,
loginUser,
content,
currentDate,
currentDate) ).bind
} firstOption
}

View File

@@ -48,7 +48,14 @@ $(function(){
content : $('#content').val()
},
function(data){
$('#comment-area').html(data.content);
var div = $('<div>').addClass('box')
.append($('<div>').addClass('box-header-small')
.append($('<a>').attr('href', '@path/@repository.owner').text(data.commentedUserName))
.append(' commented')
.append($('<span>').addClass('pull-right').text(data.registeredDate)))
.append($('<div>').addClass('box-content').attr('style', 'background-color: #f5f5f5;').html(data.content));
$('#comment-area').append(div);
$('#content').val('');
});
});
});