From: Fabrice Bellingard Date: Thu, 1 Sep 2011 13:52:34 +0000 (+0200) Subject: SONAR-2616 Improve the user auto-suggest box X-Git-Tag: 2.11^2~106 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f5d8b772ca1c4d656f81e0189c22582baa7b3f73;p=sonarqube.git SONAR-2616 Improve the user auto-suggest box Initial bug : when assigning a review, if assignee does not exist an error message should appear. --- diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index fa208995a46..5cc94c9fa92 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -380,6 +380,7 @@ reviews.without_false_positives=Without false positives reviews.showing_false_positives_only=Showing false positives only reviews.why_false_positive=Why is it a false-positive ? reviews.why_not_false_positive=Why is it not a false-positive anymore ? +reviews.user_does_not_exist=\ : user does not exist. \\nPlease select a valid user or leave the field blank. #------------------------------------------------------------------------------ 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 2e9b6f047e7..bd2913043b8 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,17 +1,22 @@ /> + value="<%= param_displayed_value -%>" + <%= "class=\"" + options[:class] + "\"" if options[:class] -%> + onKeyUp="if (this.value.length== 0 || this.value.length== 1) $('<%= param_id_name -%>').value = '';"/>
\ No newline at end of file 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 df4a07ab164..06cf4dadea1 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,11 +1,16 @@ +<% + assignee_check_script = "if ($('autocompleteText-assignee_login').value != '' && $('assignee_login').value == '') { alert($('autocompleteText-assignee_login').value + '" + message('reviews.user_does_not_exist') + "'); return false;}" +%> +
+ onsubmit="<%= assignee_check_script -%> 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] -%> <%= user_autocomplete_field "assignee_login", "" -%>    <%= submit_to_remote "submit_btn", message('assign'), :url => { :action => 'assign' }, - :update => "review" -%> + :update => "review", + :before => assignee_check_script -%>    <%= link_to_remote message('cancel'), :url => { :action => 'show', :id => params[:review_id] }, 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 5977b875884..3435a2f3da0 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,13 +1,18 @@ +<% + assignee_check_script = "if ($('autocompleteText-assignee_login').value != '' && $('assignee_login').value == '') { alert($('autocompleteText-assignee_login').value + '" + message('reviews.user_does_not_exist') + "'); return false;}" +%> + <%= image_tag("sep12.png") -%>    + onsubmit="<%= assignee_check_script -%> 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] -%> <%= user_autocomplete_field "assignee_login", "" -%>    <%= submit_to_remote "submit_btn", message('assign'), :url => { :action => 'violation_assign' }, - :update => "vId" + params[:violation_id] -%> + :update => "vId" + params[:violation_id], + :before => assignee_check_script -%>    <%= link_to_remote message('cancel'), :url => { :action => 'display_violation', :id => params[:violation_id] }, 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 20752d630fe..b9c5db8e5b4 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,8 +1,13 @@ <% button=(@comment ? message('update_comment') : message('add_comment')) + + if @violation.review.nil? || @violation.review.comments.size==0 + # This is the first comment, we must ask for the assignee + assignee_check_script = "if ($('autocompleteText-assignee_login').value != '' && $('assignee_login').value == '') { alert($('autocompleteText-assignee_login').value + '" + message('reviews.user_does_not_exist') + "'); return false;}" + end %> + onsubmit="<%= assignee_check_script if assignee_check_script -%> new Ajax.Updater('vId<%= params[:id] -%>', '<%= url_for :action => 'violation_save_comment' -%>', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)});return false;"> <% if @comment %> @@ -16,7 +21,8 @@ <%= 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] -%> + :update => 'vId'+params[:id], + :before => assignee_check_script ? assignee_check_script : "" -%>   <%= link_to_remote message('cancel'), :url => {:action => 'display_violation', :id => params[:id]}, :update => 'vId' + params[:id] -%>