From cfa9a9337169f97a18e302c6037a01f86d41e2ed Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Fri, 8 Apr 2011 11:25:43 +0200 Subject: [PATCH] [SONAR-1973] Update correctly the "Add" button visibility --- .../app/controllers/reviews_controller.rb | 31 ++++++++++--------- .../WEB-INF/app/views/reviews/_form.html.erb | 4 +-- .../app/views/reviews/create_result.js.rjs | 6 ++++ 3 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create_result.js.rjs 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 91e0a489f6d..4be1371cf00 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 @@ -54,22 +54,19 @@ class ReviewsController < ApplicationController return end - review = Review.new(params[:review]) - review.user = current_user - review.status = "open" - review.review_type = "simple" - review_comment = ReviewComment.new(params[:review_comment]) - review_comment.user = current_user - review.review_comments << review_comment - if review.valid? - review.save - params[:rule_failure_id] = review.rule_failure_id - index - else - @review = review - @review_comment = review_comment - render :partial => "form" + @review = Review.new(params[:review]) + @review.user = current_user + @review.status = "open" + @review.review_type = "simple" + @review_comment = ReviewComment.new(params[:review_comment]) + @review_comment.user = current_user + @review.review_comments << @review_comment + if @review.valid? + @review.save + #@reviews = Review.find :all, :conditions => ['rule_failure_id=?', @review.rule_failure_id] + @reviews = findReviewsForRuleFailure @review.rule_failure_id end + render "create_result" end def create_comment @@ -93,6 +90,10 @@ class ReviewsController < ApplicationController private + def findReviewsForRuleFailure ( rule_failure_id ) + return Review.find :all, :conditions => ['rule_failure_id=?', rule_failure_id] + end + def hasRightsToCreate? ( rule_failure_id ) return false unless current_user 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 ffd94f09f46..49f229d9523 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 @@ -10,8 +10,8 @@
<%= text_area :review_comment, :review_text, :id => "reviewText", :rows => 10 %>
- + + <%= submit_to_remote "create_btn", "Create review", :url => { :action => 'create' } %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create_result.js.rjs b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create_result.js.rjs new file mode 100644 index 00000000000..bdf20061a89 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/create_result.js.rjs @@ -0,0 +1,6 @@ +if @reviews + page.hide "createReviewLink" + @review.rule_failure_id.to_s + page.replace_html "reviewFailure" + @review.rule_failure_id.to_s, :partial => "index", :locals => { :reviews => @reviews } +else + page.replace_html "reviewFailure" + @review.rule_failure_id.to_s, :partial => "form" +end \ No newline at end of file -- 2.39.5