Logged in as makepeace

custom_filed_in_bulk_edit.patch

Deger Rongde, 01/21/2009 02:42 PM

Download (3.4 KB)

 
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
63 52
  # Return custom field label tag
64 53
  def custom_field_label_tag(name, custom_value)
65 54
    content_tag "label", custom_value.custom_field.name +
app/controllers/issues_controller.rb (working copy)
225 225
      
226 226
      unsaved_issue_ids = []      
227 227
      @issues.each do |issue|
228
        # load custom field values
229
        @custom_values = issue.available_custom_fields.collect { |x|
230
           CustomValue.new(:custom_field => x, 
231
           :value => (params[:custom_fields] ? params[:custom_fields][x.id.to_s] : nil)) }
232
        if  @custom_values
233
          # reject the empty values
234
          @custom_values = @custom_values.reject { |v| v.value.nil? || v.value.blank? }
235
          # update custom field value if exist
236
          issue.custom_values = issue.custom_values.clone.collect {|v|  
237
            newValue=@custom_values.detect{|c|c.custom_field.id==v.custom_field.id}
238
            newValue =v.clone if newValue.nil?
239
            newValue
240
           }
241
          # add custom value if currently not exist
242
          @custom_values.each {|c|
243
            issue.custom_values<<c if(issue.custom_values.detect{|v|(c.custom_field.id==v.custom_field.id)}.nil?)
244
          }
245
        end
246 228
        journal = issue.init_journal(User.current, params[:notes])
247 229
        issue.priority = priority if priority
248 230
        issue.assigned_to = assigned_to if assigned_to || params[:assigned_to_id] == 'none'
......
271 253
    # Find potential statuses the user could be allowed to switch issues to
272 254
    @available_statuses = Workflow.find(:all, :include => :new_status,
273 255
                                              :conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq
274
    # find custom fields for current project, sort by field_format
275
    @custom_fields = @project.all_issue_custom_fields().
276
        reject{|c| c.field_format!="list"}
277 256
  end
278 257

  
279 258
  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>
46 41
</fieldset>
47 42

  
48 43
<fieldset><legend><%= l(:field_notes) %></legend>