-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from southbridgeio/redmine_5.1_compatibility
add compatibility with Redmine 5.1
- Loading branch information
Showing
5 changed files
with
64 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
# 0.3.1 | ||
|
||
* Add compatibility with Redmine 5.1 | ||
|
||
# 0.3.0 | ||
|
||
* Add support for bulk-edit | ||
|
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,27 +1,29 @@ | ||
class IssueOpenDateHookListener < Redmine::Hook::ViewListener | ||
render_on :view_issues_form_details_bottom, partial: 'issues/open_date_field' | ||
render_on :view_issues_bulk_edit_details_bottom, partial: 'issues/open_date_field_bulk' | ||
render_on :view_issues_show_details_bottom, partial: 'issues/open_date' | ||
render_on :view_my_account, partial: 'my/open_date' | ||
module IssueOpenDate | ||
class HookListener < Redmine::Hook::ViewListener | ||
render_on :view_issues_form_details_bottom, partial: 'issues/open_date_field' | ||
render_on :view_issues_bulk_edit_details_bottom, partial: 'issues/open_date_field_bulk' | ||
render_on :view_issues_show_details_bottom, partial: 'issues/open_date' | ||
render_on :view_my_account, partial: 'my/open_date' | ||
|
||
def controller_issues_edit_before_save(context = {}) | ||
assign_issue_attributes(context) | ||
end | ||
def controller_issues_edit_before_save(context = {}) | ||
assign_issue_attributes(context) | ||
end | ||
|
||
def controller_issues_bulk_edit_before_save(context = {}) | ||
assign_issue_attributes(context) | ||
end | ||
def controller_issues_bulk_edit_before_save(context = {}) | ||
assign_issue_attributes(context) | ||
end | ||
|
||
def controller_issues_new_before_save(context = {}) | ||
assign_issue_attributes(context) | ||
end | ||
def controller_issues_new_before_save(context = {}) | ||
assign_issue_attributes(context) | ||
end | ||
|
||
private | ||
private | ||
|
||
def assign_issue_attributes(context) | ||
params, issue = context[:params].to_unsafe_h, context[:issue] | ||
Time.use_zone(User.current.time_zone || Time.now.localtime.utc_offset / 3600) do | ||
issue.assign_attributes(params[:issue].slice(*(1..5).map { |i| "open_date(#{i}i)" })) | ||
def assign_issue_attributes(context) | ||
params, issue = context[:params].to_unsafe_h, context[:issue] | ||
Time.use_zone(User.current.time_zone || Time.now.localtime.utc_offset / 3600) do | ||
issue.assign_attributes(params[:issue].slice(*(1..5).map { |i| "open_date(#{i}i)" })) | ||
end | ||
end | ||
end | ||
end |
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,26 +1,27 @@ | ||
module IssueOpenDate | ||
module IssuePatch | ||
def self.included(base) # :nodoc: | ||
base.class_eval do | ||
unloadable | ||
module Patches | ||
module IssuePatch | ||
def self.included(base) | ||
# :nodoc: | ||
base.class_eval do | ||
unloadable | ||
|
||
before_save :clear_open_date | ||
before_save :clear_open_date | ||
|
||
def open_date | ||
super.in_time_zone(User.current.time_zone) if super | ||
end | ||
def open_date | ||
super.in_time_zone(User.current.time_zone) if super | ||
end | ||
|
||
private | ||
private | ||
|
||
def clear_open_date | ||
if self.open_date.present? and !self.closed? | ||
self.open_date = nil | ||
def clear_open_date | ||
if self.open_date.present? and !self.closed? | ||
self.open_date = nil | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
end | ||
end | ||
Issue.send(:include, IssueOpenDate::IssuePatch) | ||
Issue.send(:include, IssueOpenDate::Patches::IssuePatch) |
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,20 +1,26 @@ | ||
User.send(:include, | ||
Module.new do | ||
def self.included(base) | ||
(1..5).each { |i| base.send(:safe_attributes, "issue_open_time(#{i}i)") } | ||
module IssueOpenDate | ||
module Patches | ||
module UserPatch | ||
end | ||
end | ||
end | ||
User.send(:include, | ||
Module.new do | ||
def self.included(base) | ||
(1..5).each { |i| base.send(:safe_attributes, "issue_open_time(#{i}i)") } | ||
end | ||
end | ||
) | ||
|
||
User.send(:prepend, | ||
Module.new do | ||
def issue_open_time | ||
time = | ||
begin | ||
tomorrow = Date.tomorrow | ||
super ? super.change(year: tomorrow.year, month: tomorrow.month, day: tomorrow.day) : tomorrow.to_time | ||
end | ||
time_zone ? time.to_datetime.change(offset: time_zone.formatted_offset) : time.to_datetime | ||
end | ||
end | ||
Module.new do | ||
def issue_open_time | ||
time = | ||
begin | ||
tomorrow = Date.tomorrow | ||
super ? super.change(year: tomorrow.year, month: tomorrow.month, day: tomorrow.day) : tomorrow.to_time | ||
end | ||
time_zone ? time.to_datetime.change(offset: time_zone.formatted_offset) : time.to_datetime | ||
end | ||
end | ||
) |