-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve compatibility with Redmine 5
- Loading branch information
Showing
10 changed files
with
175 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
require_dependency 'custom_field' | ||
|
||
class CustomField < ActiveRecord::Base | ||
safe_attributes 'show_hours', 'show_shortcut' | ||
module RedmineDatetimeCustomField | ||
module CustomFieldPatch | ||
def self.included(base) | ||
base.send(:include, InstanceMethods) | ||
base.class_eval do | ||
unloadable | ||
safe_attributes 'show_hours', 'show_shortcut' | ||
end | ||
end | ||
|
||
module InstanceMethods | ||
end | ||
end | ||
end | ||
|
||
unless CustomField.included_modules.include?(RedmineDatetimeCustomField::CustomFieldPatch) | ||
CustomField.send(:include, RedmineDatetimeCustomField::CustomFieldPatch) | ||
end |
25 changes: 15 additions & 10 deletions
25
lib/redmine_datetime_custom_field/custom_fields_helper_patch.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
require_dependency 'custom_fields_helper' | ||
|
||
module CustomFieldsHelper | ||
|
||
# Return a string used to display a custom value | ||
def format_value(value, custom_field) | ||
formatted_value = custom_field.format.formatted_value(self, custom_field, value, false) | ||
if formatted_value.class.name == 'Time' | ||
format_time_without_zone(formatted_value, true) | ||
else | ||
format_object(formatted_value, false) | ||
module RedmineDatetimeCustomField | ||
module CustomFieldsHelperPatch | ||
|
||
# Return a string used to display a custom value | ||
def format_value(value, custom_field) | ||
formatted_value = custom_field.format.formatted_value(self, custom_field, value, false) | ||
if formatted_value.class.name == 'Time' | ||
format_time_without_zone(formatted_value, true) | ||
else | ||
format_object(formatted_value, false) | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
ApplicationHelper.prepend RedmineDatetimeCustomField::CustomFieldsHelperPatch | ||
ActionView::Base.prepend ApplicationHelper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.