15 |
15 |
<% end %>
|
16 |
16 |
|
17 |
17 |
<% if @issue.safe_attribute? 'assigned_to_id' %>
|
18 |
|
<p><%= f.select :assigned_to_id, principals_options_for_select(@issue.assignable_users, @issue.assigned_to), :include_blank => true, :required => @issue.required_attribute?('assigned_to_id') %></p>
|
|
18 |
<p><label><%= l(:field_assigned_to) %></label> <%= text_field_tag :issue_assigned_to_autocomplete, @issue.assigned_to ? @issue.assigned_to.name : '' %><%= f.hidden_field :assigned_to_id %></p>
|
19 |
19 |
<% end %>
|
20 |
20 |
|
21 |
21 |
<% if @issue.safe_attribute?('category_id') && @issue.project.issue_categories.any? %>
|
... | ... | |
81 |
81 |
<% end %>
|
82 |
82 |
|
83 |
83 |
<% include_calendar_headers_tags %>
|
|
84 |
<% if @issue.safe_attribute? 'assigned_to_id' %>
|
|
85 |
<%= javascript_tag do %>
|
|
86 |
var assignner_list = <%= raw [{:id => User.current.id, :label => "<< #{l(:label_me)} >>", :category => 'User'}]
|
|
87 |
.concat(@issue.assignable_users.select{|u|u.is_a?(User)}.map{|u|{:id => u.id, :label => u.name, :category => 'User'}})
|
|
88 |
.concat(@issue.assignable_users.select{|u|u.is_a?(Group)}.map{|u|{:id => u.id, :label => u.name, :category => 'Group'}}).to_json %>;
|
|
89 |
observeAutocompleteField('issue_assigned_to_autocomplete', '', {
|
|
90 |
source: assignner_list,
|
|
91 |
minLength: 0,
|
|
92 |
select: function(event, ui){$('#issue_assigned_to_id').val(ui.item.id);},
|
|
93 |
change: function(event, ui){
|
|
94 |
var assigners = $.grep(assignner_list, function(item, i){return(item.label.toLowerCase()==$('#issue_assigned_to_autocomplete').val().toLowerCase());});
|
|
95 |
if(assigners.length==1){
|
|
96 |
$('#issue_assigned_to_autocomplete').val(assigners[0].label);
|
|
97 |
$('#issue_assigned_to_id').val(assigners[0].id);
|
|
98 |
}else{
|
|
99 |
$('#issue_assigned_to_autocomplete, #issue_assigned_to_id').val('');
|
|
100 |
}
|
|
101 |
},
|
|
102 |
create: function(){
|
|
103 |
$(this).data('ui-autocomplete')._renderMenu = function(ul, items){
|
|
104 |
var self = this, category = null;
|
|
105 |
$.each(items, function(index, item){
|
|
106 |
if(item.category!=category && item.category=='Group'){
|
|
107 |
ul.append("<li class='ui-autocomplete-group' style='padding-top:2px'>")
|
|
108 |
.append("<div> -- <i class='icon icon-group'></i><%= l(:label_group_plural) %> -- </div>");
|
|
109 |
}
|
|
110 |
category=item.category;
|
|
111 |
self._renderItemData(ul, item);
|
|
112 |
});
|
|
113 |
self.widget().menu( "option", "items", "> li:not(.ui-autocomplete-group)" );
|
|
114 |
};
|
|
115 |
$(this).data('ui-autocomplete')._renderItem = function(ul, item){
|
|
116 |
ul.css({'background':'#eee','overflow':'scroll'});
|
|
117 |
return $('<li style="white-space:nowrap">')
|
|
118 |
.append('<div>'+item.label+'</div>')
|
|
119 |
.appendTo(ul);
|
|
120 |
};
|
|
121 |
}
|
|
122 |
});
|
|
123 |
$('#issue_assigned_to_autocomplete').focus(function(){
|
|
124 |
$(this).data("uiAutocomplete").search($(this).val());
|
|
125 |
});
|
|
126 |
<% end %>
|
|
127 |
<% end %>
|