Project

General

Profile

Patch #2560 » custom_filed_bulk_edit_trunk.diff

Ewan Makepeace, 2009-01-28 05:37

View differences:

app/helpers/custom_fields_helper.rb (working copy)
end
end
# Return custom field html tag corresponding to its format fpr bulk edit page
def custom_field_tag_bulk_edit(custom_field)
field_name = "custom_fields[#{custom_field.id}]"
field_id = "custom_fields_#{custom_field.id}"
case custom_field.field_format
when "list"
blank_option = "<option value=\"\">#{l(:label_no_change_option)}</option>"
select_tag(field_name, blank_option + options_for_select(custom_field.possible_values), :id => field_id)
end
end
# Return custom field label tag
def custom_field_label_tag(name, custom_value)
content_tag "label", custom_value.custom_field.name +
app/controllers/issues_controller.rb (working copy)
unsaved_issue_ids = []
@issues.each do |issue|
# load custom field values
@custom_values = issue.available_custom_fields.collect { |x|
CustomValue.new(:custom_field => x,
:value => (params[:custom_fields] ? params[:custom_fields][x.id.to_s] : nil)) }
if @custom_values
# reject the empty values
@custom_values = @custom_values.reject { |v| v.value.nil? || v.value.blank? }
# update custom field value if exist
issue.custom_values = issue.custom_values.clone.collect {|v|
newValue=@custom_values.detect{|c|c.custom_field.id==v.custom_field.id}
newValue =v.clone if newValue.nil?
newValue
}
# add custom value if currently not exist
@custom_values.each {|c|
issue.custom_values<<c if(issue.custom_values.detect{|v|(c.custom_field.id==v.custom_field.id)}.nil?)
}
end
journal = issue.init_journal(User.current, params[:notes])
issue.priority = priority if priority
issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none'
......
# Find potential statuses the user could be allowed to switch issues to
@available_statuses = Workflow.find(:all, :include => :new_status,
:conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq.sort
# find custom fields for current project, sort by field_format
@custom_fields = @project.all_issue_custom_fields().
reject{|c| c.field_format!="list"}
end
def move
app/views/issues/bulk_edit.rhtml (working copy)
<label><%= l(:field_done_ratio) %>:
<%= select_tag 'done_ratio', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></label>
</p>
<p>
<% @custom_fields.each do | field | %>
<%=content_tag "label", field.name,:for => "custom_fields_#{field.id}" %>: <%= custom_field_tag_bulk_edit field%>
<% end %>
</p>
<%= call_hook(:view_issues_bulk_edit_details_bottom, { :issues => @issues }) %>
</fieldset>
(3-3/4)