diff options
author | Eric Davis <edavis@littlestreamsoftware.com> | 2010-04-16 15:33:49 +0000 |
---|---|---|
committer | Eric Davis <edavis@littlestreamsoftware.com> | 2010-04-16 15:33:49 +0000 |
commit | 88db9d0bdc9b3b91766582e40c4b44627f594f07 (patch) | |
tree | 7cc01664f60d1771b9aa8b0c37fedccaf529d4b6 /app | |
parent | 0e1595ad561ab1d534f0d97f745ea555666abf21 (diff) | |
download | redmine-88db9d0bdc9b3b91766582e40c4b44627f594f07.tar.gz redmine-88db9d0bdc9b3b91766582e40c4b44627f594f07.zip |
Replace the hardcoded CustomField::FIELD_FORMATS with a class.
Custom Field Formats are now full objects and can be registered with
Redmine::CustomFieldFormat to add new formats.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3672 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/custom_fields_helper.rb | 2 | ||||
-rw-r--r-- | app/models/custom_field.rb | 11 | ||||
-rw-r--r-- | app/views/custom_fields/_index.rhtml | 2 |
3 files changed, 3 insertions, 12 deletions
diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 40a4c7855..f3fcc1fc5 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -108,6 +108,6 @@ module CustomFieldsHelper # Return an array of custom field formats which can be used in select_tag def custom_field_formats_for_select - CustomField::FIELD_FORMATS.sort {|a,b| a[1][:order]<=>b[1][:order]}.collect { |k| [ l(k[1][:name]), k[0] ] } + Redmine::CustomFieldFormat.as_select end end diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index c7031afea..7cc6e865d 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -20,20 +20,11 @@ class CustomField < ActiveRecord::Base acts_as_list :scope => 'type = \'#{self.class}\'' serialize :possible_values - FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 }, - "text" => { :name => :label_text, :order => 2 }, - "int" => { :name => :label_integer, :order => 3 }, - "float" => { :name => :label_float, :order => 4 }, - "list" => { :name => :label_list, :order => 5 }, - "date" => { :name => :label_date, :order => 6 }, - "bool" => { :name => :label_boolean, :order => 7 } - }.freeze - validates_presence_of :name, :field_format validates_uniqueness_of :name, :scope => :type validates_length_of :name, :maximum => 30 validates_format_of :name, :with => /^[\w\s\.\'\-]*$/i - validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys + validates_inclusion_of :field_format, :in => Redmine::CustomFieldFormat.available_formats def initialize(attributes = nil) super diff --git a/app/views/custom_fields/_index.rhtml b/app/views/custom_fields/_index.rhtml index 8ef7dcba2..21ae01bef 100644 --- a/app/views/custom_fields/_index.rhtml +++ b/app/views/custom_fields/_index.rhtml @@ -14,7 +14,7 @@ <% (@custom_fields_by_type[tab[:name]] || []).sort.each do |custom_field| -%> <tr class="<%= cycle("odd", "even") %>"> <td><%= link_to custom_field.name, :action => 'edit', :id => custom_field %></td> - <td align="center"><%= l(CustomField::FIELD_FORMATS[custom_field.field_format][:name]) %></td> + <td align="center"><%= l(Redmine::CustomFieldFormat.label_for(custom_field.field_format)) %></td> <td align="center"><%= checked_image custom_field.is_required? %></td> <% if tab[:name] == 'IssueCustomField' %> <td align="center"><%= checked_image custom_field.is_for_all? %></td> |