Merge pull request #1647 from gitbucket/feature/preview-comment-edit

Make preview-able comment editing forms
This commit is contained in:
Naoki Takezoe
2017-07-17 23:15:13 +09:00
committed by GitHub
4 changed files with 56 additions and 25 deletions

View File

@@ -1,12 +1,22 @@
@(content: String, commentId: Int,
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
<span id="error-edit-content-@commentId" class="error"></span>
@gitbucket.core.helper.html.attached(repository, "issues"){
<textarea id="edit-content-@commentId" class="form-control">@content</textarea>
}
<div>
<input type="button" id="cancel-comment-@commentId" class="btn btn-danger" value="Cancel"/>
<input type="button" id="update-comment-@commentId" class="btn btn-default pull-right" value="Update comment"/>
@gitbucket.core.helper.html.preview(
repository = repository,
content = content,
enableWikiLink = false,
enableRefsLink = true,
enableLineBreaks = true,
enableTaskList = true,
hasWritePermission = true,
completionContext = "issues",
style = "",
elastic = true,
tabIndex = 1
)
<div class="pull-right">
<input type="button" id="cancel-comment-@commentId" class="btn btn-default" value="Cancel"/>
<input type="button" id="update-comment-@commentId" class="btn btn-success" value="Update comment"/>
</div>
<script>
$(function(){
@@ -17,13 +27,14 @@ $(function(){
};
$('#update-comment-@commentId').click(function(){
var content = $(this).parent().parent().find('textarea[name=content]').val();
$('#update-comment-@commentId, #cancel-comment-@commentId').attr('disabled', 'disabled');
$.ajax({
url: '@context.path/@repository.owner/@repository.name/issue_comments/edit/@commentId',
type: 'POST',
data: {
issueId : 0, // TODO
content : $('#edit-content-@commentId').val()
content : content
}
}).done(
callback

View File

@@ -1,11 +1,21 @@
@(content: Option[String], issueId: Int,
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
@gitbucket.core.helper.html.attached(repository, "issues"){
<textarea id="edit-content" class="form-control">@content.getOrElse("")</textarea>
}
<div>
<input type="button" id="cancel-issue" class="btn btn-danger" value="Cancel"/>
<input type="button" id="update-issue" class="btn btn-default pull-right" value="Update comment"/>
@gitbucket.core.helper.html.preview(
repository = repository,
content = content.getOrElse(""),
enableWikiLink = false,
enableRefsLink = true,
enableLineBreaks = true,
enableTaskList = true,
hasWritePermission = true,
completionContext = "issues",
style = "",
elastic = true,
tabIndex = 1
)
<div class="pull-right">
<input type="button" id="cancel-issue" class="btn btn-default" value="Cancel"/>
<input type="button" id="update-issue" class="btn btn-success" value="Update comment"/>
</div>
<script>
$(function(){
@@ -16,13 +26,12 @@ $(function(){
};
$('#update-issue').click(function(){
var content = $(this).parent().parent().find('textarea[name=content]').val();
$('#update, #cancel').attr('disabled', 'disabled');
$.ajax({
url: '@context.path/@repository.owner/@repository.name/issues/edit/@issueId',
type: 'POST',
data: {
content : $('#edit-content').val()
}
data: { content : content }
}).done(
callback
).fail(function(req) {

View File

@@ -1,12 +1,22 @@
@(content: String, commentId: Int,
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
<span class="error-edit-content-@commentId error"></span>
@gitbucket.core.helper.html.attached(repository, "issues"){
<textarea style="height: 100px;" id="edit-content-@commentId" class="form-control">@content</textarea>
}
<div>
<input type="button" class="cancel-comment-@commentId btn btn-small btn-danger" value="Cancel"/>
<input type="button" class="update-comment-@commentId btn btn-small btn-default pull-right" value="Update comment"/>
@gitbucket.core.helper.html.preview(
repository = repository,
content = content,
enableWikiLink = false,
enableRefsLink = true,
enableLineBreaks = true,
enableTaskList = true,
hasWritePermission = true,
completionContext = "issues",
style = "",
elastic = true,
tabIndex = 1
)
<div class="pull-right">
<input type="button" class="cancel-comment-@commentId btn btn-small btn-default" value="Cancel"/>
<input type="button" class="update-comment-@commentId btn btn-small btn-success" value="Update comment"/>
</div>
<script>
$(function(){
@@ -19,13 +29,14 @@ $(function(){
}
$(document).on('click', '.update-comment-@commentId', function(){
var content = $(this).parent().parent().find('textarea[name=content]').val();
$box = $(this).closest('.commit-comment-box');
$('.update-comment-@commentId, .cancel-comment-@commentId', $box).attr('disabled', 'disabled');
$.ajax({
url: '@context.path/@repository.owner/@repository.name/commit_comments/edit/@commentId',
type: 'POST',
data: {
content : $('#edit-content-@commentId', $box).val()
content : content
}
}).done(
curriedCallback($box)