Patch #2560 » custom_filed_bulk_edit_trunk.diff
| app/helpers/custom_fields_helper.rb (working copy) | ||
|---|---|---|
| 49 | 49 |
end |
| 50 | 50 |
end |
| 51 | 51 |
|
| 52 |
# Return custom field html tag corresponding to its format fpr bulk edit page |
|
| 53 |
def custom_field_tag_bulk_edit(custom_field) |
|
| 54 |
field_name = "custom_fields[#{custom_field.id}]"
|
|
| 55 |
field_id = "custom_fields_#{custom_field.id}"
|
|
| 56 |
case custom_field.field_format |
|
| 57 |
when "list" |
|
| 58 |
blank_option = "<option value=\"\">#{l(:label_no_change_option)}</option>"
|
|
| 59 |
select_tag(field_name, blank_option + options_for_select(custom_field.possible_values), :id => field_id) |
|
| 60 |
|
|
| 61 |
end |
|
| 62 |
end |
|
| 52 | 63 |
# Return custom field label tag |
| 53 | 64 |
def custom_field_label_tag(name, custom_value) |
| 54 | 65 |
content_tag "label", custom_value.custom_field.name + |
| app/controllers/issues_controller.rb (working copy) | ||
|---|---|---|
| 235 | 235 |
|
| 236 | 236 |
unsaved_issue_ids = [] |
| 237 | 237 |
@issues.each do |issue| |
| 238 |
# load custom field values |
|
| 239 |
@custom_values = issue.available_custom_fields.collect { |x|
|
|
| 240 |
CustomValue.new(:custom_field => x, |
|
| 241 |
:value => (params[:custom_fields] ? params[:custom_fields][x.id.to_s] : nil)) } |
|
| 242 |
if @custom_values |
|
| 243 |
# reject the empty values |
|
| 244 |
@custom_values = @custom_values.reject { |v| v.value.nil? || v.value.blank? }
|
|
| 245 |
# update custom field value if exist |
|
| 246 |
issue.custom_values = issue.custom_values.clone.collect {|v|
|
|
| 247 |
newValue=@custom_values.detect{|c|c.custom_field.id==v.custom_field.id}
|
|
| 248 |
newValue =v.clone if newValue.nil? |
|
| 249 |
newValue |
|
| 250 |
} |
|
| 251 |
# add custom value if currently not exist |
|
| 252 |
@custom_values.each {|c|
|
|
| 253 |
issue.custom_values<<c if(issue.custom_values.detect{|v|(c.custom_field.id==v.custom_field.id)}.nil?)
|
|
| 254 |
} |
|
| 255 |
end |
|
| 238 | 256 |
journal = issue.init_journal(User.current, params[:notes]) |
| 239 | 257 |
issue.priority = priority if priority |
| 240 | 258 |
issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none' |
| ... | ... | |
| 264 | 282 |
# Find potential statuses the user could be allowed to switch issues to |
| 265 | 283 |
@available_statuses = Workflow.find(:all, :include => :new_status, |
| 266 | 284 |
:conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq.sort
|
| 285 |
# find custom fields for current project, sort by field_format |
|
| 286 |
@custom_fields = @project.all_issue_custom_fields(). |
|
| 287 |
reject{|c| c.field_format!="list"}
|
|
| 267 | 288 |
end |
| 268 | 289 | |
| 269 | 290 |
def move |
| app/views/issues/bulk_edit.rhtml (working copy) | ||
|---|---|---|
| 38 | 38 |
<label><%= l(:field_done_ratio) %>: |
| 39 | 39 |
<%= select_tag 'done_ratio', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></label>
|
| 40 | 40 |
</p> |
| 41 |
<p> |
|
| 42 |
<% @custom_fields.each do | field | %> |
|
| 43 |
<%=content_tag "label", field.name,:for => "custom_fields_#{field.id}" %>: <%= custom_field_tag_bulk_edit field%>
|
|
| 44 |
<% end %> |
|
| 45 |
</p> |
|
| 41 | 46 |
<%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %>
|
| 42 | 47 |
</fieldset> |
| 43 | 48 | |