Module: BulkTimeEntriesHelper

Included in:
BulkTimeEntriesController
Defined in:
app/helpers/bulk_time_entries_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) get_issues(project_id)



34
35
36
37
38
39
40
41
# File 'app/helpers/bulk_time_entries_helper.rb', line 34

def get_issues(project_id)
  project = BulkTimeEntriesController.allowed_project?(project_id)
  if project
    project.issues.all(:order => 'id ASC')
  else
    []
  end
end

- (Object) grouped_options_for_issues(issues)



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/bulk_time_entries_helper.rb', line 13

def grouped_options_for_issues(issues)
  closed_issues, open_issues = *issues.partition {|issue| issue.closed?}

  html = '<option></option>'
  unless open_issues.empty?
    html << labeled_option_group_from_collection_for_select(:label_open_issues, open_issues)
  end

  unless closed_issues.empty?
    html << labeled_option_group_from_collection_for_select(:label_closed_issues, closed_issues)
  end
  html
end

- (Object) label_for_field(field, rnd_id, options = { })

Cheap knock off of the tabular form builder's labeling



3
4
5
6
7
8
9
10
11
# File 'app/helpers/bulk_time_entries_helper.rb', line 3

def label_for_field(field, rnd_id, options = { })
  label_text = l(options[:label]) if options[:label]
  label_text ||= l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym)
  label_text += @template.("span", " *", :class => "required") if options.delete(:required)
  label = @template.("label", label_text, 
    :class => (@object && @object.errors.on(field) ? "error" : nil), 
    :for => (@object_name.to_s + "_" + rnd_id.to_s + "_" + field.to_s))
  label
end

- (Object) labeled_option_group_from_collection_for_select(label, collection)



27
28
29
30
31
32
# File 'app/helpers/bulk_time_entries_helper.rb', line 27

def labeled_option_group_from_collection_for_select(label, collection)
  html = "<optgroup label='#{l(label)}'>"
  html << options_from_collection_for_select(collection, :id, :to_s)
  html << "</optgroup>"
  html
end