diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 96a2fc921..4b2ec8317 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -25,7 +25,7 @@ class AccountController < ApplicationController # Show user's account def show @user = User.find_active(params[:id]) - @custom_values = @user.custom_values.find(:all, :include => :custom_field) + @custom_values = @user.custom_values # show only public projects and private projects that the logged in user is also a member of @memberships = @user.memberships.select do |membership| diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 7ad19437f..704fbe010 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -66,7 +66,7 @@ class CustomField < ActiveRecord::Base # to move in project_custom_field def self.for_all - find(:all, :conditions => ["is_for_all=?", true]) + find(:all, :conditions => ["is_for_all=?", true], :order => 'position') end def type_name diff --git a/app/models/project.rb b/app/models/project.rb index 5679344bc..9e4bd6971 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -198,7 +198,7 @@ class Project < ActiveRecord::Base # Returns an array of all custom fields enabled for project issues # (explictly associated custom fields and custom fields enabled for all projects) def all_issue_custom_fields - @all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq + @all_issue_custom_fields ||= (IssueCustomField.for_all + issue_custom_fields).uniq.sort end def project diff --git a/app/views/issues/_form.rhtml b/app/views/issues/_form.rhtml index 9bb74fd34..4eca3cb4a 100644 --- a/app/views/issues/_form.rhtml +++ b/app/views/issues/_form.rhtml @@ -42,7 +42,7 @@
<%= render :partial => 'attachments/form' %>
diff --git a/app/views/issues/_form_custom_fields.rhtml b/app/views/issues/_form_custom_fields.rhtml index ebd4c3219..752fb4d37 100644 --- a/app/views/issues/_form_custom_fields.rhtml +++ b/app/views/issues/_form_custom_fields.rhtml @@ -1,5 +1,5 @@<%= custom_field_tag_with_label :issue, value %>
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index 22f9a3baf..005542f81 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -212,7 +212,7 @@ class IssuesControllerTest < Test::Unit::TestCase assert_equal 2, issue.author_id assert_equal 3, issue.tracker_id assert_nil issue.estimated_hours - v = issue.custom_values.find_by_custom_field_id(2) + v = issue.custom_values.find(:first, :conditions => {:custom_field_id => 2}) assert_not_nil v assert_equal 'Value for field 2', v.value end diff --git a/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb b/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb index 05857d0a0..a5598dbd2 100644 --- a/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb +++ b/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb @@ -27,7 +27,10 @@ module Redmine return if self.included_modules.include?(Redmine::Acts::Customizable::InstanceMethods) cattr_accessor :customizable_options self.customizable_options = options - has_many :custom_values, :dependent => :delete_all, :as => :customized + has_many :custom_values, :as => :customized, + :include => :custom_field, + :order => "#{CustomField.table_name}.position", + :dependent => :delete_all before_validation_on_create { |customized| customized.custom_field_values } # Trigger validation only if custom values were changed validates_associated :custom_values, :on => :update, :if => Proc.new { |customized| customized.custom_field_values_changed? }