diff --git a/lib/details_issue_hooks.rb b/lib/details_issue_hooks.rb
index 9cf5fdc..4f2a211 100644
--- a/lib/details_issue_hooks.rb
+++ b/lib/details_issue_hooks.rb
@@ -1,203 +1,210 @@
class DetailsIssueHooks < Redmine::Hook::ViewListener
-
def protect_against_forgery?
false
- end
-
- def current_is_detail_page(context)
- # check if we see an issue but not creating a new one or on the specific edit page
- ret = context[:controller] && context[:controller].is_a?(IssuesController) && context[:request].original_url.rindex(/\/issues\/\S+/) && !context[:request].original_url.rindex(/\/issues\/new/) && !context[:request].original_url.rindex(/\/issues\/\d+\/edit/)
- end
-
- def view_layouts_base_html_head(context)
- if current_is_detail_page(context)
- stylesheet_link_tag('issue_dynamic_edit.css', :plugin => :redmine_issue_dynamic_edit)
- end
- end
-
- def view_layouts_base_body_bottom(context)
- if current_is_detail_page(context)
- javascript_include_tag('issue_dynamic_edit_configuration_file.js', 'issue_dynamic_edit.js', :plugin => :redmine_issue_dynamic_edit)
- end
end
- def view_issues_show_details_bottom(context = { })
+ def current_is_detail_page(context)
+ # check if we see an issue but not creating a new one or on the specific edit page
+ ret = context[:controller] && context[:controller].is_a?(IssuesController) && context[:request].original_url.rindex(/\/issues\/\S+/) && !context[:request].original_url.rindex(/\/issues\/new/) && !context[:request].original_url.rindex(/\/issues\/\d+\/edit/)
+ end
+
+ def view_layouts_base_html_head(context)
+ return unless current_is_detail_page(context)
+
+ stylesheet_link_tag('issue_dynamic_edit.css', :plugin => :redmine_issue_dynamic_edit)
+ end
+
+ def view_layouts_base_body_bottom(context)
+ return unless current_is_detail_page(context)
+
+ javascript_include_tag('issue_dynamic_edit_configuration_file.js', 'issue_dynamic_edit.js', :plugin => :redmine_issue_dynamic_edit)
+ end
+
+ def view_issues_show_details_bottom(context = {})
project = context[:project]
request = context[:request]
issue_id = request.path_parameters[:id]
- back = request.env['HTTP_REFERER']
+ back = request.env['HTTP_REFERER']
- o = ''
-
- if (issue_id)
+ o = ''
+
+ if issue_id
issue = Issue.find(issue_id)
- readOnlyAttributes = issue.read_only_attribute_names(User.current)
- requiredAttributes = issue.required_attribute_names(User.current)
-
- # o << requiredAttributes.to_json
-
- allRequiredFieldsFilled = true
- requiredAttributes.each do |attr|
- if(issue.read_attribute(attr).to_s.empty?)
- allRequiredFieldsFilled = false
- end
- end
-
- if (issue)
- if (User.current.allowed_to?(:edit_issues, project))
-
- # if there's a JS error, we hide the generated values
- o << '
'
-
- # Status dropdown
- statuses = issue.new_statuses_allowed_to(User.current)
- if (!statuses.empty? && !(readOnlyAttributes.include? 'status_id') && allRequiredFieldsFilled)
- o << ""
- o << " "
+ readOnlyAttributes = issue.read_only_attribute_names(User.current)
+ requiredAttributes = issue.required_attribute_names(User.current)
+
+ # o << requiredAttributes.to_json
+
+ allRequiredFieldsFilled = true
+ requiredAttributes.each do |attr|
+ if issue.read_attribute(attr).to_s.empty?
+ allRequiredFieldsFilled = false
+ end
+ end
+
+ if issue
+ if User.current.allowed_to?(:edit_issues, project)
+ # if there's a JS error, we hide the generated values
+ o << '
'
+
+ # Status dropdown
+ statuses = issue.new_statuses_allowed_to(User.current)
+ if (
+ !statuses.empty? &&
+ !readOnlyAttributes.include?('status_id') &&
+ allRequiredFieldsFilled
+ )
+ o << ""
+ o << " "
end
-
- # Users dropdown
- assignables = project.assignable_users
- if (!assignables.empty? && !(readOnlyAttributes.include? 'assigned_to_id'))
- o << ""
- o << " "
+
+ # Users dropdown
+ assignables = project.assignable_users
+ if (
+ !assignables.empty? &&
+ !readOnlyAttributes.include?('assigned_to_id')
+ )
+ o << ""
+ o << " "
end
-
- # Priorities dropdown
- priorities = IssuePriority.all
- if(!priorities.empty? && !(readOnlyAttributes.include? 'priority_id'))
- o << ""
- o << " "
- end
-
- # %done dropdown
- if(!(readOnlyAttributes.include? 'done_ratio'))
- percent = 0
- o << ""
- o << " "
- end
-
- # Estimated_time dropdown
- if(!(readOnlyAttributes.include? 'estimated_hours'))
- o << ""
- o << " "
- o << ""
- o << " "
- o << ""
- end
-
- # Start date
- if(!(readOnlyAttributes.include? 'start_date'))
- o << ""
- o << " "
- o << " "
- o << " "
- o << ""
- o << ""
- end
-
- # Due date
- if(!(readOnlyAttributes.include? 'due_date'))
- o << ""
- o << " "
- o << " "
- o << " "
- o << ""
- o << ""
- end
- # Title
- o << ""
- o << " "
- o << " "
- o << " "
- o << ""
+ # Priorities dropdown
+ priorities = IssuePriority.all
- # Description
- o << ""
- o << " "
- o << "
"
- o << "
"
- o << ""
-
- end
- end
-
- o << "\n"
-
-
-
- o << "
#{requiredAttributes.to_json}
\n"
-
+ o << " "
+ end
- # closing the display none div parent
- o << "
"
- return o
+ # %done dropdown
+ if ! readOnlyAttributes.include?('done_ratio')
+ percent = 0
+ o << ""
+ o << " "
+ end
+
+ # Estimated_time dropdown
+ if ! readOnlyAttributes.include?('estimated_hours')
+ o << ""
+ o << " "
+ o << ""
+ o << " "
+ o << ""
+ end
+
+ # Start date
+ if ! readOnlyAttributes.include?('start_date')
+ o << ""
+ o << " "
+ o << " "
+ o << " "
+ o << ""
+ o << ""
+ end
+
+ # Due date
+ if ! readOnlyAttributes.include?('due_date')
+ o << ""
+ o << " "
+ o << " "
+ o << " "
+ o << ""
+ o << ""
+ end
+
+ # Title
+ o << ""
+ o << " "
+ o << " "
+ o << " "
+ o << ""
+
+ # Description
+ o << ""
+ o << " "
+ o << "
"
+ o << "
"
+ o << ""
+ end
+ end
+
+ o << "\n"
+
+ o << "
#{requiredAttributes.to_json}
\n"
+
+ # closing the display none div parent
+ o << "