From cbeeaa4d4d47b5118e6de21d180f221e04c0a9d5 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 14 Nov 2009 12:53:50 +0000 Subject: [PATCH] Refactoring ApplicationHelper#link_to_issue. Now displays issue subject by default. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3040 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 24 ++++++++++++++++++++++-- app/helpers/issues_helper.rb | 2 +- app/helpers/timelog_helper.rb | 2 +- app/views/common/_calendar.rhtml | 2 +- app/views/issues/_relations.rhtml | 5 +++-- app/views/issues/gantt.rhtml | 2 +- app/views/my/blocks/_timelog.rhtml | 2 +- app/views/projects/changelog.rhtml | 2 +- app/views/projects/roadmap.rhtml | 2 +- app/views/repositories/revision.rhtml | 2 +- app/views/timelog/_list.rhtml | 2 +- app/views/versions/show.rhtml | 2 +- 12 files changed, 35 insertions(+), 14 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6fca5ea7c..cfc7717d5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -58,9 +58,29 @@ module ApplicationHelper end end + # Displays a link to +issue+ with its subject. + # Examples: + # + # link_to_issue(issue) # => Defect #6: This is the subject + # link_to_issue(issue, :truncate => 6) # => Defect #6: This i... + # link_to_issue(issue, :subject => false) # => Defect #6 + # def link_to_issue(issue, options={}) - options[:class] ||= issue.css_classes - link_to "#{issue.tracker.name} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue}, options + title = nil + subject = nil + if options[:subject] == false + title = truncate(issue.subject, :length => 60) + else + subject = issue.subject + if options[:truncate] + subject = truncate(subject, :length => options[:truncate]) + end + end + s = link_to "#{issue.tracker} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue}, + :class => issue.css_classes, + :title => title + s << ": #{h subject}" if subject + s end # Generates a link to an attachment. diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index eb163e7c0..0f28cc064 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -24,7 +24,7 @@ module IssuesHelper @cached_label_assigned_to ||= l(:field_assigned_to) @cached_label_priority ||= l(:field_priority) - link_to_issue(issue) + ": #{h(issue.subject)}

" + + link_to_issue(issue) + "

" + "#{@cached_label_start_date}: #{format_date(issue.start_date)}
" + "#{@cached_label_due_date}: #{format_date(issue.due_date)}
" + "#{@cached_label_assigned_to}: #{issue.assigned_to}
" + diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index 01dcbb473..e8fff8cbd 100644 --- a/app/helpers/timelog_helper.rb +++ b/app/helpers/timelog_helper.rb @@ -22,7 +22,7 @@ module TimelogHelper links = [] links << link_to(l(:label_project_all), {:project_id => nil, :issue_id => nil}) links << link_to(h(@project), {:project_id => @project, :issue_id => nil}) if @project - links << link_to_issue(@issue) if @issue + links << link_to_issue(@issue, :subject => false) if @issue breadcrumb links end diff --git a/app/views/common/_calendar.rhtml b/app/views/common/_calendar.rhtml index d8a7f4088..af525c870 100644 --- a/app/views/common/_calendar.rhtml +++ b/app/views/common/_calendar.rhtml @@ -20,7 +20,7 @@ while day <= calendar.enddt %> image_tag('arrow_to.png') end %> <%= h("#{i.project} -") unless @project && @project == i.project %> - <%= link_to_issue i %>: <%= h(truncate(i.subject, :length => 30)) %> + <%= link_to_issue i, :truncate => 30 %> <%= render_issue_tooltip i %> <% else %> diff --git a/app/views/issues/_relations.rhtml b/app/views/issues/_relations.rhtml index 6f02d1937..135bfa681 100644 --- a/app/views/issues/_relations.rhtml +++ b/app/views/issues/_relations.rhtml @@ -11,8 +11,9 @@ <% @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| %> <%= l(relation.label_for(@issue)) %> <%= "(#{l('datetime.distance_in_words.x_days', :count => relation.delay)})" if relation.delay && relation.delay != 0 %> - <%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %> <%= link_to_issue relation.other_issue(@issue) %> -<%=h relation.other_issue(@issue).subject %> + <%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %> + <%= link_to_issue relation.other_issue(@issue) %> + <%= relation.other_issue(@issue).status.name %> <%= format_date(relation.other_issue(@issue).start_date) %> <%= format_date(relation.other_issue(@issue).due_date) %> diff --git a/app/views/issues/gantt.rhtml b/app/views/issues/gantt.rhtml index 6dc4e7a4b..ce317ea80 100644 --- a/app/views/issues/gantt.rhtml +++ b/app/views/issues/gantt.rhtml @@ -83,7 +83,7 @@ top = headers_height + 8
<% if i.is_a? Issue %> <%= h("#{i.project} -") unless @project && @project == i.project %> - <%= link_to_issue i %>: <%=h i.subject %> + <%= link_to_issue i %> <% else %> <%= h("#{i.project} -") unless @project && @project == i.project %> diff --git a/app/views/my/blocks/_timelog.rhtml b/app/views/my/blocks/_timelog.rhtml index ca66f7ee4..95679b207 100644 --- a/app/views/my/blocks/_timelog.rhtml +++ b/app/views/my/blocks/_timelog.rhtml @@ -31,7 +31,7 @@ entries_by_day = entries.group_by(&:spent_on) <% entries_by_day[day].each do |entry| -%> <%=h entry.activity %> - <%=h entry.project %> <%= ' - ' + link_to_issue(entry.issue, :title => h("#{entry.issue.subject} (#{entry.issue.status})")) if entry.issue %> + <%=h entry.project %> <%= ' - ' + link_to_issue(entry.issue, :truncate => 50) if entry.issue %> <%=h entry.comments %> <%= html_hours("%.2f" % entry.hours) %> diff --git a/app/views/projects/changelog.rhtml b/app/views/projects/changelog.rhtml index e44d1d1ee..355a3034a 100644 --- a/app/views/projects/changelog.rhtml +++ b/app/views/projects/changelog.rhtml @@ -19,7 +19,7 @@ <% if !issues.empty? %>
    <% issues.each do |issue| %> -
  • <%= link_to_issue(issue) %>: <%=h issue.subject %>
  • +
  • <%= link_to_issue(issue) %>
  • <% end %>
<% end %> diff --git a/app/views/projects/roadmap.rhtml b/app/views/projects/roadmap.rhtml index bcba13abd..cbad932df 100644 --- a/app/views/projects/roadmap.rhtml +++ b/app/views/projects/roadmap.rhtml @@ -20,7 +20,7 @@ diff --git a/app/views/repositories/revision.rhtml b/app/views/repositories/revision.rhtml index b7bda4530..b205be37c 100644 --- a/app/views/repositories/revision.rhtml +++ b/app/views/repositories/revision.rhtml @@ -30,7 +30,7 @@

<%= l(:label_related_issues) %>

    <% @changeset.issues.visible.each do |issue| %> -
  • <%= link_to_issue issue %>: <%=h issue.subject %>
  • +
  • <%= link_to_issue issue %>
  • <% end %>
<% end %> diff --git a/app/views/timelog/_list.rhtml b/app/views/timelog/_list.rhtml index 019eda2ec..f6a1268dc 100644 --- a/app/views/timelog/_list.rhtml +++ b/app/views/timelog/_list.rhtml @@ -20,7 +20,7 @@ <%=h entry.project %> <% if entry.issue -%> -<%= link_to_issue entry.issue %>: <%= h(truncate(entry.issue.subject, :length => 50)) -%> +<%= link_to_issue entry.issue, :truncate => 50 -%> <% end -%> <%=h entry.comments %> diff --git a/app/views/versions/show.rhtml b/app/views/versions/show.rhtml index c98d5424f..5cea1abcb 100644 --- a/app/views/versions/show.rhtml +++ b/app/views/versions/show.rhtml @@ -39,7 +39,7 @@ -- 2.39.5