diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-05-24 18:03:33 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-05-24 19:03:19 +0200 |
commit | 36297a74b2cf6982d126e009ba92c23025e04ba1 (patch) | |
tree | 7a707f2f3b96fee9c2971de03319f61c30afa81e /sonar-server | |
parent | 4b6fbec3e9fc12e5be02878c23b313c460a1266d (diff) | |
download | sonarqube-36297a74b2cf6982d126e009ba92c23025e04ba1.tar.gz sonarqube-36297a74b2cf6982d126e009ba92c23025e04ba1.zip |
SONAR-2443 Improve the assignee select-box in the resource viewer
For:
- creating a review
- assigning a review
Diffstat (limited to 'sonar-server')
7 files changed, 28 insertions, 30 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 8ab6f3a2f74..742b81c7d2f 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 @@ -61,7 +61,6 @@ class ReviewsController < ApplicationController # GET def assign_form - @user_options = options_for_users() render :partial => "assign_form" end @@ -163,7 +162,6 @@ class ReviewsController < ApplicationController # GET def violation_assign_form - @user_options = options_for_users() render :partial => "violation_assign_form" end @@ -220,7 +218,6 @@ class ReviewsController < ApplicationController if !params[:comment_id].blank? && @violation.review @comment = @violation.review.comments.find(params[:comment_id]) end - @user_options = [["Unassigned", ""]] + options_for_users render :partial => 'reviews/violation_comment_form' end @@ -269,7 +266,6 @@ class ReviewsController < ApplicationController private def init_params - @user_names = [["Any", ""]] + options_for_users default_user = (current_user ? current_user.id : '') @assignee_id = params[:assignee_id] || default_user @author_id = params[:author_id] || '' @@ -281,18 +277,6 @@ class ReviewsController < ApplicationController @asc = params[:asc] == "true" end - def options_for_users - options=[] - User.find( :all ).each do |user| - username = user.name - if current_user && current_user.id == user.id - username = "Me (" + user.name + ")" - end - options<<[username, user.id.to_s] - end - options - end - def filter_any(array) if array && array.size>1 && array.include?("") array=[""] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb index 393007219de..5f37632ba08 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/autocomplete/_text_field.html.erb @@ -1,4 +1,4 @@ - <input type="text" id="autocompleteText-<%= param_id_name -%>" value="<%= param_displayed_value -%>" onkeyup="if (this.value=='') $('<%= param_id_name -%>').value='';"/> + <input type="text" id="autocompleteText-<%= param_id_name -%>" value="<%= param_displayed_value -%>" onfocus="$('<%= param_id_name -%>').value=''; this.value=''"/> <input type="hidden" id="<%= param_id_name -%>" name="<%= param_id_name -%>" value="<%= param_id_value -%>"/> <span id="load-<%= param_id_name -%>" style="display: none"> <%= image_tag("loading.gif") -%> 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 25989a7b1e0..ef561c7e4a7 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 @@ -76,7 +76,6 @@ %> <div class="discussionComment"> <h4><%= image_tag("reviews/comment.png") -%> <b><%= review_comment.user.name -%></b> (<%= distance_of_time_in_words_to_now(review_comment.created_at) -%>) - <!-- && current_user.id == review_comment.user_id --> <% if is_last_comment && current_user %> <span class="actions" id="commentActions<%= violation.id -%>"> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb index 7aff44c3d4c..cd10d6b3691 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_assign_form.html.erb @@ -1,12 +1,17 @@ -<% form_tag :html => {:style => "display:inline"} do %> +<form method="post" + onsubmit="if ($('assignee_id').value != '') { new Ajax.Updater('review', '<%= url_for :action => 'assign' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); };return false;"> <%= hidden_field_tag :id, params[:review_id] -%> - <%= select_tag "assignee_id", options_for_select(@user_options, current_user.id.to_s) %> + <%= user_autocomplete_field "assignee_id", "" -%> <%= submit_to_remote "submit_btn", "Assign", :url => { :action => 'assign' }, - :update => "review" -%> + :update => "review", + :condition => "$('assignee_id').value != ''" -%> <%= link_to_remote 'Cancel', :url => { :action => 'show', :id => params[:review_id] }, :update => "review" %> -<% end %>
\ No newline at end of file + <script> + $('autocompleteText-assignee_id').focus() + </script> +</form>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb index 2b2b35030bb..039f66976c9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_assign_form.html.erb @@ -1,14 +1,19 @@ <%= image_tag("sep12.png") -%> -<% form_tag :html => {:style => "display:inline"} do %> +<form method="post" + onsubmit="if ($('assignee_id').value != '') { new Ajax.Updater('vId<%= params[:violation_id] -%>', '<%= url_for :action => 'violation_assign' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); };return false;"> <%= hidden_field_tag :id, params[:violation_id] -%> - <%= select_tag "assignee_id", options_for_select(@user_options, current_user.id.to_s) %> + <%= user_autocomplete_field "assignee_id", "" -%> <%= submit_to_remote "submit_btn", "Assign", :url => { :action => 'violation_assign' }, - :update => "vId" + params[:violation_id] -%> + :update => "vId" + params[:violation_id], + :condition => "$('assignee_id').value != ''" -%> <%= link_to_remote 'Cancel', :url => { :action => 'display_violation', :id => params[:violation_id] }, :update => "vId" + params[:violation_id] %> -<% end %>
\ No newline at end of file + <script> + $('autocompleteText-assignee_id').focus() + </script> +</form>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb index 7c6a8d24352..9072af34d4a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/reviews/_violation_comment_form.html.erb @@ -1,7 +1,8 @@ <% button=(@comment ? 'Update comment' : 'Add comment') %> -<form method="POST" action="violation_save_comment"> +<form method="POST" + onsubmit="new Ajax.Updater('vId<%= params[:id] -%>', '<%= url_for :action => 'violation_save_comment' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)});return false;"> <input type="hidden" name="id" value="<%= params[:id] -%>"/> <% if @comment %> <input type="hidden" name="comment_id" value="<%= @comment.id -%>"/> @@ -12,14 +13,17 @@ <td style="vertical-align:top"> <textarea id="commentText<%= params[:id] -%>" rows="8" name="text" style="width: 100%" onkeyup="if (this.value=='') $('submit_btn<%= params[:id] -%>').disabled='true'; else $('submit_btn<%= params[:id] -%>').disabled='';"><%= @comment.text if @comment -%></textarea> <br/> - <%= submit_to_remote "submit_btn"+params[:id] , button, :url => { :action => 'violation_save_comment'}, :html => { :id => "submit_btn"+params[:id], :disabled => "true" }, :update => 'vId'+params[:id] -%> + <%= submit_to_remote "submit_btn"+params[:id] , button, + :url => { :action => 'violation_save_comment'}, + :html => { :id => "submit_btn"+params[:id], :disabled => "true" }, + :update => 'vId'+params[:id] -%> <%= link_to_remote 'Cancel', :url => {:action => 'display_violation', :id => params[:id]}, :update => 'vId' + params[:id] -%> <% if @violation.review.nil? || @violation.review.comments.size==0 %> - <span>Assignee:</span> - <%= select_tag "assignee_id", options_for_select(@user_options, current_user.id.to_s) %> + <span>Assignee:</span> + <%= user_autocomplete_field "assignee_id", current_user.id -%> <% end %> </td> <td class="sep"></td> diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css index 6fa9beb0a19..958e9b6eb4e 100644 --- a/sonar-server/src/main/webapp/stylesheets/style.css +++ b/sonar-server/src/main/webapp/stylesheets/style.css @@ -916,6 +916,7 @@ div.autocomplete { padding:0; color: #111; line-height: 1em; + text-shadow: none; } div.autocomplete ul { list-style-type:none; |