# GET
def assign_form
- @user_options = options_for_users()
render :partial => "assign_form"
end
# GET
def violation_assign_form
- @user_options = options_for_users()
render :partial => "violation_assign_form"
end
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
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] || ''
@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=[""]
- <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") -%>
%>
<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 -%>">
-<% 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
<%= 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
<%
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 -%>"/>
<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>
padding:0;
color: #111;
line-height: 1em;
+ text-shadow: none;
}
div.autocomplete ul {
list-style-type:none;