summaryrefslogtreecommitdiffstats
path: root/vendor
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-10 10:48:16 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-10 10:48:16 +0000
commit3e3315c103f232655ac8553fcd476792f7d24691 (patch)
treeeb8eb970f48425895296f1ed74107d022422ddeb /vendor
parent0e19aa4362a0524d900044fc9dc69e177337eca0 (diff)
downloadredmine-3e3315c103f232655ac8553fcd476792f7d24691.tar.gz
redmine-3e3315c103f232655ac8553fcd476792f7d24691.zip
Support for updating custom fields using the received custom_fields array (#6345, #6403).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4481 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'vendor')
-rw-r--r--vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb15
1 files changed, 15 insertions, 0 deletions
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 03b36f698..9ed9fe376 100644
--- a/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb
+++ b/vendor/plugins/acts_as_customizable/lib/acts_as_customizable.rb
@@ -50,6 +50,21 @@ module Redmine
: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)
+ values_to_hash = values.inject({}) do |hash, v|
+ v = v.stringify_keys
+ if v['id'] && v.has_key?('value')
+ hash[v['id']] = v['value']
+ end
+ hash
+ end
+ self.custom_field_values = values_to_hash
+ end
+
+ # Sets the values of the object's custom fields
+ # values is a hash like {'1' => 'foo', 2 => 'bar'}
def custom_field_values=(values)
@custom_field_values_changed = true
values = values.stringify_keys