]> source.dussan.org Git - redmine.git/commitdiff
Fixes custom fields display order at several places (#1768).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 11 Aug 2008 18:24:39 +0000 (18:24 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 11 Aug 2008 18:24:39 +0000 (18:24 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1731 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/account_controller.rb
app/models/custom_field.rb
app/models/project.rb
app/views/issues/_form.rhtml
app/views/issues/_form_custom_fields.rhtml
test/functional/issues_controller_test.rb
vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb

index 96a2fc9218d5d096b6de1e8cbdf77cf5ffe90844..4b2ec8317284948495eb9abed6f46ca580a08425 100644 (file)
@@ -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|
index 7ad19437f0e7aa32ba4d14407d748d208acb9783..704fbe010048b220fdcfb8e45cf700feaa68dc95 100644 (file)
@@ -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
index 5679344bc7063dde68d849e75ee7ab070dd9343c..9e4bd6971c631668a4d9aa41a68de070119220ce 100644 (file)
@@ -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
index 9bb74fd34748b8dab51c4b5d2e929e319de450d6..4eca3cb4a4d15ac13c00778445a67c67c12ec61c 100644 (file)
@@ -42,7 +42,7 @@
 </div>
 
 <div style="clear:both;"> </div>
-<%= render :partial => 'form_custom_fields', :locals => {:values => @custom_values} %>
+<%= render :partial => 'form_custom_fields' %>
 
 <% if @issue.new_record? %>
 <p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
index ebd4c3219a944ae4a004d29cc72e8a8f4dca4d39..752fb4d372c20916cdf407a6a32aa67a65053bce 100644 (file)
@@ -1,5 +1,5 @@
 <div class="splitcontentleft">
-<% i = 1 %>
+<% i = 0 %>
 <% split_on = @issue.custom_field_values.size / 2 %>
 <% @issue.custom_field_values.each do |value| %>
        <p><%= custom_field_tag_with_label :issue, value %></p>
index 22f9a3bafe732f1d0b9d08dff193ca9b97c5f2e0..005542f81361ff302746cd5f6330a671570ac7a1 100644 (file)
@@ -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
index 05857d0a0d304923b43de98c886bf1bace13257a..a5598dbd262f795ddf52327643f560d222df879a 100644 (file)
@@ -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? }