From 3a567cb4a7b4b80719e0b5800ae43667e13c954e Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Mon, 17 Jul 2017 21:58:26 +0900 Subject: [PATCH 1/2] Make preview-able comment editing form --- .../gitbucket/core/helper/preview.scala.html | 4 ++-- .../core/issues/editcomment.scala.html | 19 +++++++++++++---- .../core/issues/editissue.scala.html | 21 +++++++++++++------ .../core/repo/editcomment.scala.html | 19 +++++++++++++---- 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/main/twirl/gitbucket/core/helper/preview.scala.html b/src/main/twirl/gitbucket/core/helper/preview.scala.html index 4ec4b0913..7bfe6832a 100644 --- a/src/main/twirl/gitbucket/core/helper/preview.scala.html +++ b/src/main/twirl/gitbucket/core/helper/preview.scala.html @@ -16,7 +16,7 @@
@@ -32,7 +32,7 @@ generateScript = !enableWikiLink )(textarea)
-
+
diff --git a/src/main/twirl/gitbucket/core/issues/editcomment.scala.html b/src/main/twirl/gitbucket/core/issues/editcomment.scala.html index 87a2a6b54..2ba354514 100644 --- a/src/main/twirl/gitbucket/core/issues/editcomment.scala.html +++ b/src/main/twirl/gitbucket/core/issues/editcomment.scala.html @@ -1,9 +1,19 @@ @(content: String, commentId: Int, repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context) -@gitbucket.core.helper.html.attached(repository, "issues"){ - -} +@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 +)
@@ -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 diff --git a/src/main/twirl/gitbucket/core/issues/editissue.scala.html b/src/main/twirl/gitbucket/core/issues/editissue.scala.html index 1fab57c8b..75ec49edc 100644 --- a/src/main/twirl/gitbucket/core/issues/editissue.scala.html +++ b/src/main/twirl/gitbucket/core/issues/editissue.scala.html @@ -1,8 +1,18 @@ @(content: Option[String], issueId: Int, repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context) -@gitbucket.core.helper.html.attached(repository, "issues"){ - -} +@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 +)
@@ -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) { diff --git a/src/main/twirl/gitbucket/core/repo/editcomment.scala.html b/src/main/twirl/gitbucket/core/repo/editcomment.scala.html index 88e740ecf..f00b111c6 100644 --- a/src/main/twirl/gitbucket/core/repo/editcomment.scala.html +++ b/src/main/twirl/gitbucket/core/repo/editcomment.scala.html @@ -1,9 +1,19 @@ @(content: String, commentId: Int, repository: gitbucket.core.service.RepositoryService.RepositoryInfo)(implicit context: gitbucket.core.controller.Context) -@gitbucket.core.helper.html.attached(repository, "issues"){ - -} +@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 +)
@@ -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) From 8505d8ae0ee77255d3f288b6a0c503faac2b1b00 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Mon, 17 Jul 2017 22:44:53 +0900 Subject: [PATCH 2/2] Change position of buttons in comment editing forms --- src/main/twirl/gitbucket/core/issues/editcomment.scala.html | 6 +++--- src/main/twirl/gitbucket/core/issues/editissue.scala.html | 6 +++--- src/main/twirl/gitbucket/core/repo/editcomment.scala.html | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/twirl/gitbucket/core/issues/editcomment.scala.html b/src/main/twirl/gitbucket/core/issues/editcomment.scala.html index 2ba354514..6a75dece9 100644 --- a/src/main/twirl/gitbucket/core/issues/editcomment.scala.html +++ b/src/main/twirl/gitbucket/core/issues/editcomment.scala.html @@ -14,9 +14,9 @@ elastic = true, tabIndex = 1 ) -
- - +
+ +