Revision 1298:4f746d8966dd lib/plugins/acts_as_customizable/lib

View differences:

lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
2
# Copyright (C) 2006-2013  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
......
32 32
                                   :order => "#{CustomField.table_name}.position",
33 33
                                   :dependent => :delete_all,
34 34
                                   :validate => false
35

  
35 36
          send :include, Redmine::Acts::Customizable::InstanceMethods
36 37
          validate :validate_custom_field_values
37 38
          after_save :save_custom_field_values
......
41 42
      module InstanceMethods
42 43
        def self.included(base)
43 44
          base.extend ClassMethods
45
          base.send :alias_method_chain, :reload, :custom_fields
44 46
        end
45 47

  
46 48
        def available_custom_fields
47
          CustomField.find(:all, :conditions => "type = '#{self.class.name}CustomField'",
48
                                 :order => 'position')
49
          CustomField.where("type = '#{self.class.name}CustomField'").sorted.all
49 50
        end
50 51

  
51 52
        # Sets the values of the object's custom fields
......
153 154
          @custom_field_values_changed = true
154 155
        end
155 156

  
157
        def reload_with_custom_fields(*args)
158
          @custom_field_values = nil
159
          @custom_field_values_changed = false
160
          reload_without_custom_fields(*args)
161
        end
162

  
156 163
        module ClassMethods
157 164
        end
158 165
      end

Also available in: Unified diff