remove trailing white-spaces from vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9303 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f9d123c08f
commit
dd5c702e11
@ -5,12 +5,12 @@
|
|||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
@ -42,12 +42,12 @@ module Redmine
|
|||||||
def self.included(base)
|
def self.included(base)
|
||||||
base.extend ClassMethods
|
base.extend ClassMethods
|
||||||
end
|
end
|
||||||
|
|
||||||
def available_custom_fields
|
def available_custom_fields
|
||||||
CustomField.find(:all, :conditions => "type = '#{self.class.name}CustomField'",
|
CustomField.find(:all, :conditions => "type = '#{self.class.name}CustomField'",
|
||||||
:order => 'position')
|
:order => 'position')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets the values of the object's custom fields
|
# Sets the values of the object's custom fields
|
||||||
# values is an array like [{'id' => 1, 'value' => 'foo'}, {'id' => 2, 'value' => 'bar'}]
|
# values is an array like [{'id' => 1, 'value' => 'foo'}, {'id' => 2, 'value' => 'bar'}]
|
||||||
def custom_fields=(values)
|
def custom_fields=(values)
|
||||||
@ -65,7 +65,7 @@ module Redmine
|
|||||||
# values is a hash like {'1' => 'foo', 2 => 'bar'}
|
# values is a hash like {'1' => 'foo', 2 => 'bar'}
|
||||||
def custom_field_values=(values)
|
def custom_field_values=(values)
|
||||||
values = values.stringify_keys
|
values = values.stringify_keys
|
||||||
|
|
||||||
custom_field_values.each do |custom_field_value|
|
custom_field_values.each do |custom_field_value|
|
||||||
key = custom_field_value.custom_field_id.to_s
|
key = custom_field_value.custom_field_id.to_s
|
||||||
if values.has_key?(key)
|
if values.has_key?(key)
|
||||||
@ -81,7 +81,7 @@ module Redmine
|
|||||||
end
|
end
|
||||||
@custom_field_values_changed = true
|
@custom_field_values_changed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_field_values
|
def custom_field_values
|
||||||
@custom_field_values ||= available_custom_fields.collect do |field|
|
@custom_field_values ||= available_custom_fields.collect do |field|
|
||||||
x = CustomFieldValue.new
|
x = CustomFieldValue.new
|
||||||
@ -101,31 +101,31 @@ module Redmine
|
|||||||
x
|
x
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_custom_field_values
|
def visible_custom_field_values
|
||||||
custom_field_values.select(&:visible?)
|
custom_field_values.select(&:visible?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_field_values_changed?
|
def custom_field_values_changed?
|
||||||
@custom_field_values_changed == true
|
@custom_field_values_changed == true
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_value_for(c)
|
def custom_value_for(c)
|
||||||
field_id = (c.is_a?(CustomField) ? c.id : c.to_i)
|
field_id = (c.is_a?(CustomField) ? c.id : c.to_i)
|
||||||
custom_values.detect {|v| v.custom_field_id == field_id }
|
custom_values.detect {|v| v.custom_field_id == field_id }
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_field_value(c)
|
def custom_field_value(c)
|
||||||
field_id = (c.is_a?(CustomField) ? c.id : c.to_i)
|
field_id = (c.is_a?(CustomField) ? c.id : c.to_i)
|
||||||
custom_field_values.detect {|v| v.custom_field_id == field_id }.try(:value)
|
custom_field_values.detect {|v| v.custom_field_id == field_id }.try(:value)
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_custom_field_values
|
def validate_custom_field_values
|
||||||
if new_record? || custom_field_values_changed?
|
if new_record? || custom_field_values_changed?
|
||||||
custom_field_values.each(&:validate_value)
|
custom_field_values.each(&:validate_value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def save_custom_field_values
|
def save_custom_field_values
|
||||||
target_custom_values = []
|
target_custom_values = []
|
||||||
custom_field_values.each do |custom_field_value|
|
custom_field_values.each do |custom_field_value|
|
||||||
@ -147,12 +147,12 @@ module Redmine
|
|||||||
@custom_field_values_changed = false
|
@custom_field_values_changed = false
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
def reset_custom_values!
|
def reset_custom_values!
|
||||||
@custom_field_values = nil
|
@custom_field_values = nil
|
||||||
@custom_field_values_changed = true
|
@custom_field_values_changed = true
|
||||||
end
|
end
|
||||||
|
|
||||||
module ClassMethods
|
module ClassMethods
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user