diff options
-rw-r--r-- | app/controllers/issue_relations_controller.rb | 2 | ||||
-rw-r--r-- | app/helpers/issues_helper.rb | 31 | ||||
-rw-r--r-- | app/views/issues/_relations.html.erb | 23 |
3 files changed, 34 insertions, 22 deletions
diff --git a/app/controllers/issue_relations_controller.rb b/app/controllers/issue_relations_controller.rb index 9c8c2fe1d..7d37a3e20 100644 --- a/app/controllers/issue_relations_controller.rb +++ b/app/controllers/issue_relations_controller.rb @@ -16,6 +16,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class IssueRelationsController < ApplicationController + helper :issues + before_action :find_issue, :authorize, :only => [:index, :create] before_action :find_relation, :only => [:show, :destroy] diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 72f33da1d..eaa42f9de 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -106,6 +106,37 @@ module IssuesHelper s.html_safe end + # Renders the list of related issues on the issue details view + def render_issue_relations(issue, relations) + manage_relations = User.current.allowed_to?(:manage_issue_relations, issue.project) + + s = ''.html_safe + relations.each do |relation| + other_issue = relation.other_issue(issue) + css = "issue hascontextmenu #{other_issue.css_classes}" + link = manage_relations ? link_to(l(:label_relation_delete), + relation_path(relation), + :remote => true, + :method => :delete, + :data => {:confirm => l(:text_are_you_sure)}, + :title => l(:label_relation_delete), + :class => 'icon-only icon-link-break' + ) : nil + + s << content_tag('tr', + content_tag('td', check_box_tag("ids[]", other_issue.id, false, :id => nil), :class => 'checkbox') + + content_tag('td', relation.to_s(@issue) {|other| link_to_issue(other, :project => Setting.cross_project_issue_relations?)}.html_safe, :class => 'subject', :style => 'width: 50%') + + content_tag('td', other_issue.status, :class => 'status') + + content_tag('td', other_issue.start_date, :class => 'start_date') + + content_tag('td', other_issue.due_date, :class => 'due_date') + + content_tag('td', link, :class => 'buttons'), + :id => "relation-#{relation.id}", + :class => css) + end + + content_tag('table', s, :class => 'list issues') + end + def issue_estimated_hours_details(issue) if issue.total_estimated_hours.present? if issue.total_estimated_hours == issue.estimated_hours diff --git a/app/views/issues/_relations.html.erb b/app/views/issues/_relations.html.erb index cab1d0c1a..3825fe64f 100644 --- a/app/views/issues/_relations.html.erb +++ b/app/views/issues/_relations.html.erb @@ -8,28 +8,7 @@ <% if @relations.present? %> <%= form_tag({}, :data => {:cm_url => issues_context_menu_path}) do %> -<table class="list issues"> -<% @relations.each do |relation| %> - <% other_issue = relation.other_issue(@issue) -%> - <tr class="issue hascontextmenu <%= other_issue.css_classes %>" id="relation-<%= relation.id %>"> - <td class="checkbox"><%= check_box_tag("ids[]", other_issue.id, false, :id => nil) %></td> - <td class="subject" style="width: 50%"> - <%= relation.to_s(@issue) {|other| link_to_issue(other, :project => Setting.cross_project_issue_relations?)}.html_safe %> - </td> - <td class="status"><%= other_issue.status.name %></td> - <td class="start_date"><%= format_date(other_issue.start_date) %></td> - <td class="due_date"><%= format_date(other_issue.due_date) %></td> - <td class="buttons"><%= link_to(l(:label_relation_delete), - relation_path(relation), - :remote => true, - :method => :delete, - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:label_relation_delete), - :class => 'icon-only icon-link-break' - ) if User.current.allowed_to?(:manage_issue_relations, @project) %></td> - </tr> -<% end %> -</table> + <%= render_issue_relations(@issue, @relations) %> <% end %> <% end %> |