Feature #16045 » previous-assignee-v1.0.patch
app/helpers/application_helper.rb (working copy) | ||
---|---|---|
324 | 324 |
end |
325 | 325 | |
326 | 326 |
# Returns a string for users/groups option tags |
327 |
def principals_options_for_select(collection, selected=nil) |
|
327 |
def principals_options_for_select(collection, selected=nil, previous=nil)
|
|
328 | 328 |
s = '' |
329 | 329 |
if collection.include?(User.current) |
330 | 330 |
s << content_tag('option', "<< #{l(:label_me)} >>", :value => User.current.id) |
331 | 331 |
end |
332 |
if previous!=nil && collection.include?(User.find_by_id(previous)) |
|
333 |
p = User.find_by_id(previous) |
|
334 |
s << content_tag('option', "<< #{l(:label_previous)}: #{h p.name} >>", :value => p.id) |
|
335 |
end |
|
332 | 336 |
groups = '' |
333 | 337 |
collection.sort.each do |element| |
334 | 338 |
selected_attribute = ' selected="selected"' if option_value_selected?(element, selected) || element.id.to_s == selected |
app/helpers/issues_helper.rb (working copy) | ||
---|---|---|
260 | 260 |
strings = [] |
261 | 261 |
values_by_field = {} |
262 | 262 |
details.each do |detail| |
263 |
if detail.property == 'cf' |
|
264 |
field = detail.custom_field |
|
265 |
if field && field.multiple? |
|
266 |
values_by_field[field] ||= {:added => [], :deleted => []} |
|
267 |
if detail.old_value |
|
268 |
values_by_field[field][:deleted] << detail.old_value |
|
269 |
end |
|
270 |
if detail.value |
|
271 |
values_by_field[field][:added] << detail.value |
|
272 |
end |
|
273 |
next |
|
274 |
end |
|
263 |
unless detail.prop_key == "previous_assigned_to_id" |
|
264 |
if detail.property == 'cf' |
|
265 |
field = detail.custom_field |
|
266 |
if field && field.multiple? |
|
267 |
values_by_field[field] ||= {:added => [], :deleted => []} |
|
268 |
if detail.old_value |
|
269 |
values_by_field[field][:deleted] << detail.old_value |
|
270 |
end |
|
271 |
if detail.value |
|
272 |
values_by_field[field][:added] << detail.value |
|
273 |
end |
|
274 |
next |
|
275 |
end |
|
276 |
end |
|
277 |
strings << show_detail(detail, no_html, options) |
|
278 |
end |
|
275 | 279 |
end |
276 |
strings << show_detail(detail, no_html, options) |
|
277 |
end |
|
278 | 280 |
values_by_field.each do |field, changes| |
279 | 281 |
detail = JournalDetail.new(:property => 'cf', :prop_key => field.id.to_s) |
280 | 282 |
detail.instance_variable_set "@custom_field", field |
281 |
if changes[:added].any? |
|
282 |
detail.value = changes[:added] |
|
283 |
strings << show_detail(detail, no_html, options) |
|
284 |
elsif changes[:deleted].any? |
|
285 |
detail.old_value = changes[:deleted] |
|
286 |
strings << show_detail(detail, no_html, options) |
|
283 |
if changes[:added].any?
|
|
284 |
detail.value = changes[:added]
|
|
285 |
strings << show_detail(detail, no_html, options)
|
|
286 |
elsif changes[:deleted].any?
|
|
287 |
detail.old_value = changes[:deleted]
|
|
288 |
strings << show_detail(detail, no_html, options)
|
|
287 | 289 |
end |
288 | 290 |
end |
289 | 291 |
strings |
app/models/issue.rb (working copy) | ||
---|---|---|
93 | 93 | |
94 | 94 |
before_create :default_assign |
95 | 95 |
before_save :close_duplicates, :update_done_ratio_from_issue_status, |
96 |
:force_updated_on_change, :update_closed_on, :set_assigned_to_was |
|
96 |
:force_updated_on_change, :update_closed_on, :set_assigned_to_was, :update_previous_assignee
|
|
97 | 97 |
after_save {|issue| issue.send :after_project_change if !issue.id_changed? && issue.project_id_changed?} |
98 | 98 |
after_save :reschedule_following_issues, :update_nested_set_attributes, |
99 | 99 |
:update_parent_attributes, :create_journal |
100 | 100 | |
... | ... | |
1459 | 1459 |
end |
1460 | 1460 |
end |
1461 | 1461 | |
1462 | ||
1463 |
def update_previous_assignee |
|
1464 |
if assigned_to_id? |
|
1465 |
#self.previous_assigned_to = User.find_by_id(assigned_to_id_was) |
|
1466 |
self.previous_assigned_to_id = assigned_to_id_was |
|
1467 |
end |
|
1468 |
end |
|
1469 | ||
1470 | ||
1462 | 1471 |
# Saves the changes in a Journal |
1463 | 1472 |
# Called after_save |
1464 | 1473 |
def create_journal |
app/views/issues/_attributes.html.erb (working copy) | ||
---|---|---|
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><%= f.select :assigned_to_id, principals_options_for_select(@issue.assignable_users, @issue.assigned_to, @issue.previous_assigned_to_id ), :include_blank => true, :required => @issue.required_attribute?('assigned_to_id') %></p>
|
|
19 | 19 |
<% end %> |
20 | 20 | |
21 | 21 |
<% if @issue.safe_attribute?('category_id') && @issue.project.issue_categories.any? %> |