diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/custom_field.rb | 5 | ||||
-rw-r--r-- | app/models/project.rb | 8 |
2 files changed, 12 insertions, 1 deletions
diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 81c8aae06..c3b5f2a9f 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -17,6 +17,7 @@ class CustomField < ActiveRecord::Base has_many :custom_values, :dependent => :delete_all + acts_as_list :scope => 'type = \'#{self.class}\'' serialize :possible_values FIELD_FORMATS = { "string" => { :name => :label_string, :order => 1 }, @@ -51,6 +52,10 @@ class CustomField < ActiveRecord::Base end end + def <=>(field) + position <=> field.position + end + # to move in project_custom_field def self.for_all find(:all, :conditions => ["is_for_all=?", true]) diff --git a/app/models/project.rb b/app/models/project.rb index 152808c14..1fbab2e4d 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -36,7 +36,13 @@ class Project < ActiveRecord::Base has_one :repository, :dependent => :destroy has_many :changesets, :through => :repository has_one :wiki, :dependent => :destroy - has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :association_foreign_key => 'custom_field_id' + # Custom field for the project issues + has_and_belongs_to_many :custom_fields, + :class_name => 'IssueCustomField', + :order => "#{CustomField.table_name}.position", + :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", + :association_foreign_key => 'custom_field_id' + acts_as_tree :order => "name", :counter_cache => true acts_as_searchable :columns => ['name', 'description'], :project_key => 'id' |