mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
Merge pull request #1647 from gitbucket/feature/preview-comment-edit
Make preview-able comment editing forms
This commit is contained in:
@@ -1,12 +1,22 @@
|
|||||||
@(content: String, commentId: Int,
|
@(content: String, commentId: Int,
|
||||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
||||||
<span id="error-edit-content-@commentId" class="error"></span>
|
<span id="error-edit-content-@commentId" class="error"></span>
|
||||||
@gitbucket.core.helper.html.attached(repository, "issues"){
|
@gitbucket.core.helper.html.preview(
|
||||||
<textarea id="edit-content-@commentId" class="form-control">@content</textarea>
|
repository = repository,
|
||||||
}
|
content = content,
|
||||||
<div>
|
enableWikiLink = false,
|
||||||
<input type="button" id="cancel-comment-@commentId" class="btn btn-danger" value="Cancel"/>
|
enableRefsLink = true,
|
||||||
<input type="button" id="update-comment-@commentId" class="btn btn-default pull-right" value="Update comment"/>
|
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>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
@@ -17,13 +27,14 @@ $(function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
$('#update-comment-@commentId').click(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');
|
$('#update-comment-@commentId, #cancel-comment-@commentId').attr('disabled', 'disabled');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '@context.path/@repository.owner/@repository.name/issue_comments/edit/@commentId',
|
url: '@context.path/@repository.owner/@repository.name/issue_comments/edit/@commentId',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: {
|
||||||
issueId : 0, // TODO
|
issueId : 0, // TODO
|
||||||
content : $('#edit-content-@commentId').val()
|
content : content
|
||||||
}
|
}
|
||||||
}).done(
|
}).done(
|
||||||
callback
|
callback
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
@(content: Option[String], issueId: Int,
|
@(content: Option[String], issueId: Int,
|
||||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
||||||
@gitbucket.core.helper.html.attached(repository, "issues"){
|
@gitbucket.core.helper.html.preview(
|
||||||
<textarea id="edit-content" class="form-control">@content.getOrElse("")</textarea>
|
repository = repository,
|
||||||
}
|
content = content.getOrElse(""),
|
||||||
<div>
|
enableWikiLink = false,
|
||||||
<input type="button" id="cancel-issue" class="btn btn-danger" value="Cancel"/>
|
enableRefsLink = true,
|
||||||
<input type="button" id="update-issue" class="btn btn-default pull-right" value="Update comment"/>
|
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>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
@@ -16,13 +26,12 @@ $(function(){
|
|||||||
};
|
};
|
||||||
|
|
||||||
$('#update-issue').click(function(){
|
$('#update-issue').click(function(){
|
||||||
|
var content = $(this).parent().parent().find('textarea[name=content]').val();
|
||||||
$('#update, #cancel').attr('disabled', 'disabled');
|
$('#update, #cancel').attr('disabled', 'disabled');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '@context.path/@repository.owner/@repository.name/issues/edit/@issueId',
|
url: '@context.path/@repository.owner/@repository.name/issues/edit/@issueId',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: { content : content }
|
||||||
content : $('#edit-content').val()
|
|
||||||
}
|
|
||||||
}).done(
|
}).done(
|
||||||
callback
|
callback
|
||||||
).fail(function(req) {
|
).fail(function(req) {
|
||||||
|
|||||||
@@ -1,12 +1,22 @@
|
|||||||
@(content: String, commentId: Int,
|
@(content: String, commentId: Int,
|
||||||
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context)
|
||||||
<span class="error-edit-content-@commentId error"></span>
|
<span class="error-edit-content-@commentId error"></span>
|
||||||
@gitbucket.core.helper.html.attached(repository, "issues"){
|
@gitbucket.core.helper.html.preview(
|
||||||
<textarea style="height: 100px;" id="edit-content-@commentId" class="form-control">@content</textarea>
|
repository = repository,
|
||||||
}
|
content = content,
|
||||||
<div>
|
enableWikiLink = false,
|
||||||
<input type="button" class="cancel-comment-@commentId btn btn-small btn-danger" value="Cancel"/>
|
enableRefsLink = true,
|
||||||
<input type="button" class="update-comment-@commentId btn btn-small btn-default pull-right" value="Update comment"/>
|
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>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
@@ -19,13 +29,14 @@ $(function(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('click', '.update-comment-@commentId', function(){
|
$(document).on('click', '.update-comment-@commentId', function(){
|
||||||
|
var content = $(this).parent().parent().find('textarea[name=content]').val();
|
||||||
$box = $(this).closest('.commit-comment-box');
|
$box = $(this).closest('.commit-comment-box');
|
||||||
$('.update-comment-@commentId, .cancel-comment-@commentId', $box).attr('disabled', 'disabled');
|
$('.update-comment-@commentId, .cancel-comment-@commentId', $box).attr('disabled', 'disabled');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '@context.path/@repository.owner/@repository.name/commit_comments/edit/@commentId',
|
url: '@context.path/@repository.owner/@repository.name/commit_comments/edit/@commentId',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {
|
data: {
|
||||||
content : $('#edit-content-@commentId', $box).val()
|
content : content
|
||||||
}
|
}
|
||||||
}).done(
|
}).done(
|
||||||
curriedCallback($box)
|
curriedCallback($box)
|
||||||
|
|||||||
Reference in New Issue
Block a user