summaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-04-07 13:51:00 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-04-20 08:49:56 +0200
commit82ff6127624f08ccec0d6bed2471cc67540c6acd (patch)
tree6794db8c36041820bea3a51e94f4c9fd76f41dfe /sonar-server/src/main
parentdcba2ad8611d097d182d97b064dd8a0195e4f3a6 (diff)
downloadsonarqube-82ff6127624f08ccec0d6bed2471cc67540c6acd.tar.gz
sonarqube-82ff6127624f08ccec0d6bed2471cc67540c6acd.zip
[SONAR-1973] Improve review&comment forms
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb14
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb18
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb12
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_comment.html.erb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb11
5 files changed, 35 insertions, 22 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
index 5c1eb333c9a..fba4a4b3e0b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/reviews_controller.rb
@@ -20,14 +20,16 @@
class ReviewsController < ApplicationController
- SECTION=Navigation::SECTION_CONFIGURATION
+ SECTION=Navigation::SECTION_RESOURCE
+
+ #verify :method => :post, :only => [ :create, :...... ], :redirect_to => { :action => :index }
def index
end
def list
reviews = Review.find :all, :conditions => ['rule_failure_id=?', params[:rule_failure_id]]
- render :partial => "list", :locals => { :reviews => reviews }, :layout => false
+ render :partial => "list", :locals => { :reviews => reviews }
end
def form
@@ -38,7 +40,7 @@ class ReviewsController < ApplicationController
@review_comment.user = current_user
@review_comment.review = @review
@review_comment.review_text = "Enter your review here"
- render "_form", :layout => false
+ render :partial => "form"
end
def formComment
@@ -47,13 +49,15 @@ class ReviewsController < ApplicationController
@review_comment.review_id = params[:review_id]
@review_comment.review_text = ""
@rule_failure_id = params[:rule_failure_id]
- render "_form_comment", :layout => false
+ render :partial => "form_comment"
end
def create
review = Review.new(params[:review])
review.user = current_user
+ # save!
review.save
+ # --> Build?
#review.review_comments.create(params[:review_comment])
review_comment = ReviewComment.new(params[:review_comment])
review_comment.user = current_user
@@ -65,6 +69,8 @@ class ReviewsController < ApplicationController
end
def createComment
+ #return access_denied unless has_role?(:user, @project)
+
review_comment = ReviewComment.new(params[:review_comment])
review_comment.user = current_user
review_comment.save
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb
index 5353f9b7dc1..6ac4247163f 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/resource/_violation.html.erb
@@ -1,12 +1,20 @@
+<%
+ displayReviewFailureDiv = 'block'
+ if violation.reviews.blank?
+ displayReviewFailureDiv = 'none'
+ end
+%>
<div class="violation">
<table>
<tr>
<td width="30px" valign="top">
- <% if current_user %>
- <%= link_to_remote(image_tag("add.png"),
- :update => "reviewFailure" + violation.id.to_s,
- :url => { :controller => "reviews", :action => "form", :violation_id => violation.id }) -%>
+ <% if current_user && violation.reviews.blank? %>
+ <%= link_to_remote image_tag("add.png"),
+ :url => { :controller => "reviews", :action => "form", :violation_id => violation.id },
+ :update => "reviewFailure" + violation.id.to_s,
+ :html => { :id => "createReviewLink" + violation.id.to_s },
+ :complete => "$('reviewFailure" + violation.id.to_s + "').style.display='';$('reviewText').focus();" -%>
<% end %>
</td>
@@ -23,7 +31,7 @@
<span class="violation_date"><%= duration==0 ? 'today' : "#{duration} days ago" -%></span>
<% end %>
- <div id="reviewFailure<%= violation.id -%>" style="padding:5px; background:white">
+ <div id="reviewFailure<%= violation.id -%>" style="padding:5px; background:white; display:<%= displayReviewFailureDiv -%>">
<%= render :partial => "reviews/list", :locals => { :reviews => violation.reviews } %>
</div>
</td>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb
index 66539b0c43e..eb62f5a4f48 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form.html.erb
@@ -13,12 +13,10 @@
<br/>
Comment:
<br/>
- <%= text_area :review_comment, :review_text, :rows => 10 %>
+ <%= text_area :review_comment, :review_text, :id => "reviewText", :rows => 10 %>
<br/>
- <%= submit_to_remote 'create_btn', 'Create review',
- :url => { :action => 'create' },
- :update => { :success => "reviewFailure" + @review.rule_failure_id.to_s, :failure => "fail" } %>
- <%= submit_to_remote 'cancel_btn', 'Cancel',
- :url => { :action => 'list', :rule_failure_id => @review.rule_failure_id.to_s },
- :update => { :success => "reviewFailure" + @review.rule_failure_id.to_s } %>
+ <input type="button" name="create_btn" value="Create review"
+ onclick="new Ajax.Updater({success:'reviewFailure<%= @review.rule_failure_id.to_s -%>'}, '<%= ApplicationController.root_context -%>/reviews/create?rule_failure_id=<%= @review.rule_failure_id.to_s -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form), onSuccess:function(request){$('createReviewLink<%= @review.rule_failure_id.to_s -%>').style.display='none';} });">
+ <input type="button" name="cancel_btn" value="Cancel"
+ onclick="new Ajax.Updater({success:'reviewFailure<%= @review.rule_failure_id.to_s -%>'}, '<%= ApplicationController.root_context -%>/reviews/list?rule_failure_id=<%= @review.rule_failure_id.to_s -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form), }); $('reviewFailure<%= @review.rule_failure_id.to_s -%>').style.display='none';">
<% end %> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_comment.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_comment.html.erb
index b2ed06f0555..50c9a9e6b09 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_comment.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_form_comment.html.erb
@@ -4,7 +4,7 @@
<br/>
Comment:
<br/>
- <%= f.text_area :review_text, :rows => 10 %>
+ <%= f.text_area :review_text, :rows => 10, :id => "commentText" + @review_comment.review_id.to_s %>
<br/>
<%= submit_to_remote 'create_btn', 'Add comment',
:url => { :action => 'createComment', :rule_failure_id => @rule_failure_id },
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb
index 29c96225414..bc1b5bc3133 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_view.html.erb
@@ -24,10 +24,11 @@
%>
</div>
- <%= link_to_remote("Add a comment",
+ <%= link_to_remote "Add a comment",
+ :url => { :controller => "reviews", :action => "formComment", :review_id => review.id, :rule_failure_id => review.rule_failure_id },
:update => "createComment" + review.id.to_s,
- :url => { :controller => "reviews", :action => "formComment", :review_id => review.id, :rule_failure_id => review.rule_failure_id }) -%>
- <div id="createComment<%= review.id -%>">
-
- </div>
+ :complete => "$('commentText" + review.id.to_s + "').focus()" -%>
+
+ <div id="createComment<%= review.id -%>"></div>
+
</div>