[#2279] Moved select_values_for_field to a helper.
This commit is contained in:
@@ -2,6 +2,8 @@ class OverheadTimeEntryActivityController < ApplicationController
|
||||
unloadable
|
||||
|
||||
before_filter :require_admin
|
||||
helper :overhead
|
||||
include OverheadHelper
|
||||
|
||||
def index
|
||||
if params[:custom_field]
|
||||
@@ -14,25 +16,4 @@ class OverheadTimeEntryActivityController < ApplicationController
|
||||
|
||||
render :partial => 'values'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def select_values_for_field(field)
|
||||
return [] if field.nil?
|
||||
|
||||
if field.field_format == 'list'
|
||||
returning [] do |r|
|
||||
field.possible_values.each do |item|
|
||||
if item == 'Nil'
|
||||
r << [l(:label_none), item] # Nil should use the none label
|
||||
else
|
||||
r << [item, item]
|
||||
end
|
||||
end
|
||||
r
|
||||
end
|
||||
elsif field.field_format == 'bool'
|
||||
return [[true,true],[false,false]]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
20
app/helpers/overhead_helper.rb
Normal file
20
app/helpers/overhead_helper.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
module OverheadHelper
|
||||
def select_values_for_field(field)
|
||||
return [] if field.nil?
|
||||
|
||||
if field.field_format == 'list'
|
||||
returning [] do |r|
|
||||
field.possible_values.each do |item|
|
||||
if item == 'Nil'
|
||||
r << [l(:label_none), item] # Nil should use the none label
|
||||
else
|
||||
r << [item, item]
|
||||
end
|
||||
end
|
||||
r
|
||||
end
|
||||
elsif field.field_format == 'bool'
|
||||
return [[true,true],[false,false]]
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user