Permalink
Browse files

fix: Workaround for custom fields with type Date

  • Loading branch information...
1 parent d495db0 commit 6dff0aaedfeeec815b4a8417250cbf5745487b23 Sven Krzyzak committed Jul 19, 2011
Showing with 56 additions and 1 deletion.
  1. +7 −1 init.rb
  2. +7 −0 lib/mylyn_connector/patches.rb
  3. +41 −0 lib/mylyn_connector/patches/custom_value_patch.rb
  4. +1 −0 release-note.txt
View
@@ -11,4 +11,10 @@
Redmine::Plugin.find(:redmine_mylyn_connector).requires_redmine(:version_or_higher=>'1.0.0')
-require_dependency 'mylyn_connector/hooks/controller_issues_edit_after_save'
+require_dependency 'mylyn_connector/hooks/controller_issues_edit_after_save'
+
+require 'dispatcher'
+require 'mylyn_connector/patches/custom_value_patch'
+Dispatcher.to_prepare do
+ CustomValue.send(:include, MylynConnector::Patches::CustomValuePatch) unless CustomValue.included_modules.include?(MylynConnector::Patches::CustomValuePatch)
+end
@@ -0,0 +1,7 @@
+module MylynConnector
+
+ module Patches
+
+ end
+
+end
@@ -0,0 +1,41 @@
+module MylynConnector
+
+ module Patches
+
+ module CustomValuePatch
+
+ def self.included(base) # :nodoc:
+ base.extend(ClassMethods)
+
+ base.send(:include, InstanceMethods)
+
+ # Same as typing in the class
+ base.class_eval do
+ unloadable # Send unloadable so it will not be unloaded in development
+
+ before_validation :convert_date_values
+
+ end
+
+ end
+
+ module ClassMethods
+ end
+
+ module InstanceMethods
+
+ #this will convert ...
+ def convert_date_values
+ unless self.value.blank?
+ self.value = self.value.to_s if self.custom_field.field_format=='date' && self.value.instance_of?(Date)
+ end
+
+ end
+
+ end
+
+ end
+
+ end
+
+end
View
@@ -1,6 +1,7 @@
Version 2.7.3
chg : Fixtures adapted for Redmine 1.2
add : Support for accept_api_auth (new in Redmine 1.2)
+ fix : Workaround for custom fields with type 'Date'
Version 2.7.2
bugfix: Missing support for manipulation of issue watchers

0 comments on commit 6dff0aa

Please sign in to comment.