Module: BulkTimeEntriesHelper
- Included in:
- BulkTimeEntriesController
- Defined in:
- app/helpers/bulk_time_entries_helper.rb
Instance Method Summary collapse
- #get_issues(project_id) ⇒ Object
- #grouped_options_for_issues(issues) ⇒ Object
-
#label_for_field(field, rnd_id, options = { }) ⇒ Object
Cheap knock off of the tabular form builder’s labeling.
- #labeled_option_group_from_collection_for_select(label, collection) ⇒ Object
Instance Method Details
#get_issues(project_id) ⇒ Object
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 |
#grouped_options_for_issues(issues) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/bulk_time_entries_helper.rb', line 13 def (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 |
#label_for_field(field, rnd_id, options = { }) ⇒ Object
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, = { }) label_text = l([:label]) if [:label] label_text ||= l(("field_"+field.to_s.gsub(/\_id$/, "")).to_sym) label_text += @template.content_tag("span", " *", :class => "required") if .delete(:required) label = @template.content_tag("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 |
#labeled_option_group_from_collection_for_select(label, collection) ⇒ Object
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 << (collection, :id, :to_s) html << "</optgroup>" html end |