]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4373 The confirmation of an issue comment 'Delete' action must not be done...
authorSimon Brandhof <simon.brandhof@gmail.com>
Tue, 16 Jul 2013 15:20:18 +0000 (17:20 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Tue, 16 Jul 2013 15:20:28 +0000 (17:20 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/issue_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/issue/_delete_comment_form.html.erb [deleted file]
sonar-server/src/main/webapp/WEB-INF/app/views/issue/_issue.html.erb
sonar-server/src/main/webapp/javascripts/issue.js

index ea985230a3faaefc7527b74726e2531be8fdcbb8..0695d27692f839a092b4c04a3d2ec19b0a244c3b 100644 (file)
@@ -124,13 +124,6 @@ class IssueController < ApplicationController
     render :partial => 'issue/issue', :locals => {:issue => @issue_results.issues.get(0)}
   end
 
-  # Form in a modal window to delete comment
-  def delete_comment_form
-    verify_ajax_request
-    require_parameters :id
-    render :partial => 'issue/delete_comment_form'
-  end
-
   # Delete an existing comment
   def delete_comment
     verify_post_request
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_delete_comment_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/issue/_delete_comment_form.html.erb
deleted file mode 100644 (file)
index 26b6e7d..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<form id="delete-comment-form" method="post" action="<%= ApplicationController.root_context -%>/issue/delete_comment">
-  <input type="hidden" name="id" value="<%= params[:id] -%>">
-  <fieldset>
-    <div class="modal-head">
-      <h2><%= message 'issue.comment.delete_confirm_title' -%></h2>
-    </div>
-    <div class="modal-body">
-      <div class="info">
-        <img src="<%= ApplicationController.root_context -%>/images/information.png" style="vertical-align: text-bottom"/>
-        <%= message 'issue.comment.delete_confirm_message' -%>
-      </div>
-    </div>
-    <div class="modal-foot">
-      <input type="submit" value="<%= message 'issue.comment.delete_confirm_button' -%>" id="confirm-submit"/>
-      <a href="#" onclick="return closeModalWindow()" id="confirm-cancel"><%= h message('cancel') -%></a>
-    </div>
-  </fieldset>
-</form>
-<script>
-  $j("#delete-comment-form").modalForm({
-    success: function (html) {
-      closeModalWindow();
-      var commentElt = $j('#<%= params[:htmlId] -%>');
-      var issueElt = commentElt.closest('[data-issue-key]');
-      var replaced = $j(html);
-      issueElt.replaceWith(replaced);
-
-      // re-enable the links opening modal popups
-      replaced.find('.open-modal').modal();
-    }});
-</script>
\ No newline at end of file
index 56e8e7dcc892924e05294b7901a939364d621d63..5b7cd5ff905618af0bc54ccd901f5e78886b3e51 100644 (file)
@@ -59,7 +59,7 @@
           <%= image_tag 'sep12.png' -%>
           &nbsp;
           <a class="link-action" href="#" onclick="return formEditIssueComment(this)"><%= message('edit') -%></a>
-          <a class="link-action spacer-right" href="#" onclick="return formDeleteIssueComment(this)"><%= message('delete') -%></a>
+          <a class="link-action spacer-right" href="#" onclick="return deleteIssueComment(this, '<%= escape_javascript(message('issue.comment.delete_confirm_message')) -%>')"><%= message('delete') -%></a>
         <% end %>
       </h4>
       <%= Internal.text.markdownToHtml(comment.markdownText) -%>
index 8ae078bdcda749a58c0087d8a86a1e2892bd52ac..d3ed8d9a43f368942c13c01db68509c65699392a 100644 (file)
@@ -100,11 +100,20 @@ function doIssueTransition(elt, transition) {
   return doIssueAction(elt, 'transition', parameters);
 }
 
-function formDeleteIssueComment(elt) {
+function deleteIssueComment(elt, confirmMsg) {
   var commentElt = $j(elt).closest("[data-comment-key]");
-  var htmlId = commentElt.attr('id');
   var commentKey = commentElt.attr('data-comment-key');
-  return openModalWindow(baseUrl + '/issue/delete_comment_form/' + commentKey + '?htmlId=' + htmlId, {});
+  var issueElt = commentElt.closest('[data-issue-key]');
+  if (confirm(confirmMsg)) {
+    $j.ajax({
+      type: "POST",
+      url: baseUrl + "/issue/delete_comment?id=" + commentKey,
+      success: function (htmlResponse) {
+        issueElt.replaceWith($j(htmlResponse));
+      }
+    });
+  }
+  return false;
 }
 
 function formEditIssueComment(elt) {