whitespace fixes

pull/17/head
Jens Ulferts 12 years ago
parent f1ae269f45
commit 8bfc52ad29
  1. 22
      vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb

@ -6,12 +6,12 @@
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -45,12 +45,12 @@ module Redmine
def self.included(base)
base.extend ClassMethods
end
def available_custom_fields
CustomField.find(:all, :conditions => "type = '#{self.class.name}CustomField'",
:order => 'position')
end
# Sets the values of the object's custom fields
# values is an array like [{'id' => 1, 'value' => 'foo'}, {'id' => 2, 'value' => 'bar'}]
def custom_fields=(values)
@ -74,37 +74,37 @@ module Redmine
end if values.is_a?(Hash)
self.custom_values = custom_field_values
end
def custom_field_values
@custom_field_values ||= available_custom_fields.collect { |x| custom_values.detect { |v| v.custom_field == x } || custom_values.build(:customized => self, :custom_field => x, :value => nil) }
end
def visible_custom_field_values
custom_field_values.select(&:visible?)
end
def custom_field_values_changed?
@custom_field_values_changed == true
end
def custom_value_for(c)
field_id = (c.is_a?(CustomField) ? c.id : c.to_i)
custom_values.detect {|v| v.custom_field_id == field_id }
end
def save_custom_field_values
custom_field_values.each(&:save)
@custom_field_values_changed = false
@custom_field_values = nil
end
def reset_custom_values!
@custom_field_values = nil
@custom_field_values_changed = true
values = custom_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
custom_values.each {|cv| cv.destroy unless custom_field_values.include?(cv)}
end
module ClassMethods
end
end

Loading…
Cancel
Save