Skip to content

Commit

Permalink
Merge pull request #17 from centosadmin/develop
Browse files Browse the repository at this point in the history
Release 0.3.0
  • Loading branch information
vladislav-yashin authored Dec 26, 2018
2 parents 42214b2 + 62e5c9f commit c0b6029
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 0.3.0

* Add support for bulk-edit
* Fix worker autoload
* Fix date save for new issue
* Don't show open date field if issue.open_date is empty
* Adapt for Redmine 4

# 0.2.0

* Add issue open time to user account options
Expand Down
6 changes: 4 additions & 2 deletions app/views/issues/_open_date.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= issue_fields_rows do |rows|
<% if issue.open_date %>
<%= issue_fields_rows do |rows|
rows.right l(:field_open_date), format_time(issue.open_date), :class => 'due-date'
end %>
end %>
<% end %>
19 changes: 19 additions & 0 deletions app/views/issues/_open_date_field_bulk.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<% if @projects.all? { |project| User.current.allowed_to?(:edit_issues, project) } &&
Setting.plugin_redmine_issue_open_date['freezed_statuses'].include?(@issue_params[:status_id]) %>
<style type="text/css">
#open_date_area select {
width: auto;
}
</style>

<p id="open_date_area">
<%= label_tag t('field_open_date') %>
<span style="display: inline-block;">
<%= date_select :issue, :open_date, default: User.current.issue_open_time , minute_step: 5 %>
</span>
<span style="display: inline-block;">
<%= time_select :issue, :open_date, default: User.current.issue_open_time , minute_step: 5, ignore_date: true %>
</span>
</p>

<% end %>
2 changes: 1 addition & 1 deletion db/migrate/001_add_open_date_to_issues.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddOpenDateToIssues < ActiveRecord::Migration
class AddOpenDateToIssues < Rails.version < '5.0' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
def change
add_column :issues, :open_date, :date
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/002_convert_date_to_datetime.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ConvertDateToDatetime < ActiveRecord::Migration
class ConvertDateToDatetime < Rails.version < '5.0' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
def change
change_column :issues, :open_date, :datetime
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/003_add_issue_open_time_to_users.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class AddIssueOpenTimeToUsers < ActiveRecord::Migration
class AddIssueOpenTimeToUsers < Rails.version < '5.0' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
def change
add_column :users, :issue_open_time, :time
end
Expand Down
6 changes: 5 additions & 1 deletion init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
require_dependency 'issue_open_date/patches/issue_patch'
require_dependency 'issue_open_date/patches/user_patch'

workers_path = File.dirname(__FILE__) + "/app/workers"
ActiveSupport::Dependencies.autoload_paths += [workers_path]
Rails.application.config.eager_load_paths += [workers_path]

Redmine::Plugin.register :redmine_issue_open_date do
name 'Redmine Issue Open Date plugin'
url 'https://github.com/centosadmin/redmine_issue_open_date'
description 'This is a plugin for Redmine which open freezed issues with specified oped date'
version '0.2.0'
version '0.3.0'
author 'Southbridge'
author_url 'https://southbridge.io'
settings(default: {
Expand Down
18 changes: 16 additions & 2 deletions lib/issue_open_date/hook_listener.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
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'

def controller_issues_edit_before_save(context = {})
return unless User.current.allowed_to?(:edit_issues, context[:issue].project)
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

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
context[:issue].assign_attributes(context[:params][:issue].slice(*(1..5).map { |i| "open_date(#{i}i)" }))
issue.assign_attributes(params[:issue].slice(*(1..5).map { |i| "open_date(#{i}i)" }))
end
end
end

0 comments on commit c0b6029

Please sign in to comment.