##// END OF EJS Templates
Refactoring ApplicationHelper#link_to_issue....
Jean-Philippe Lang -
r2926:cbeeaa4d4d47
parent child
Show More
@@ -58,9 +58,29 module ApplicationHelper
58 end
58 end
59 end
59 end
60
60
61 # Displays a link to +issue+ with its subject.
62 # Examples:
63 #
64 # link_to_issue(issue) # => Defect #6: This is the subject
65 # link_to_issue(issue, :truncate => 6) # => Defect #6: This i...
66 # link_to_issue(issue, :subject => false) # => Defect #6
67 #
61 def link_to_issue(issue, options={})
68 def link_to_issue(issue, options={})
62 options[:class] ||= issue.css_classes
69 title = nil
63 link_to "#{issue.tracker.name} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue}, options
70 subject = nil
71 if options[:subject] == false
72 title = truncate(issue.subject, :length => 60)
73 else
74 subject = issue.subject
75 if options[:truncate]
76 subject = truncate(subject, :length => options[:truncate])
77 end
78 end
79 s = link_to "#{issue.tracker} ##{issue.id}", {:controller => "issues", :action => "show", :id => issue},
80 :class => issue.css_classes,
81 :title => title
82 s << ": #{h subject}" if subject
83 s
64 end
84 end
65
85
66 # Generates a link to an attachment.
86 # Generates a link to an attachment.
@@ -24,7 +24,7 module IssuesHelper
24 @cached_label_assigned_to ||= l(:field_assigned_to)
24 @cached_label_assigned_to ||= l(:field_assigned_to)
25 @cached_label_priority ||= l(:field_priority)
25 @cached_label_priority ||= l(:field_priority)
26
26
27 link_to_issue(issue) + ": #{h(issue.subject)}<br /><br />" +
27 link_to_issue(issue) + "<br /><br />" +
28 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />" +
28 "<strong>#{@cached_label_start_date}</strong>: #{format_date(issue.start_date)}<br />" +
29 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />" +
29 "<strong>#{@cached_label_due_date}</strong>: #{format_date(issue.due_date)}<br />" +
30 "<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" +
30 "<strong>#{@cached_label_assigned_to}</strong>: #{issue.assigned_to}<br />" +
@@ -22,7 +22,7 module TimelogHelper
22 links = []
22 links = []
23 links << link_to(l(:label_project_all), {:project_id => nil, :issue_id => nil})
23 links << link_to(l(:label_project_all), {:project_id => nil, :issue_id => nil})
24 links << link_to(h(@project), {:project_id => @project, :issue_id => nil}) if @project
24 links << link_to(h(@project), {:project_id => @project, :issue_id => nil}) if @project
25 links << link_to_issue(@issue) if @issue
25 links << link_to_issue(@issue, :subject => false) if @issue
26 breadcrumb links
26 breadcrumb links
27 end
27 end
28
28
@@ -20,7 +20,7 while day <= calendar.enddt %>
20 image_tag('arrow_to.png')
20 image_tag('arrow_to.png')
21 end %>
21 end %>
22 <%= h("#{i.project} -") unless @project && @project == i.project %>
22 <%= h("#{i.project} -") unless @project && @project == i.project %>
23 <%= link_to_issue i %>: <%= h(truncate(i.subject, :length => 30)) %>
23 <%= link_to_issue i, :truncate => 30 %>
24 <span class="tip"><%= render_issue_tooltip i %></span>
24 <span class="tip"><%= render_issue_tooltip i %></span>
25 </div>
25 </div>
26 <% else %>
26 <% else %>
@@ -11,8 +11,9
11 <% @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| %>
11 <% @issue.relations.select {|r| r.other_issue(@issue).visible? }.each do |relation| %>
12 <tr>
12 <tr>
13 <td><%= l(relation.label_for(@issue)) %> <%= "(#{l('datetime.distance_in_words.x_days', :count => relation.delay)})" if relation.delay && relation.delay != 0 %>
13 <td><%= l(relation.label_for(@issue)) %> <%= "(#{l('datetime.distance_in_words.x_days', :count => relation.delay)})" if relation.delay && relation.delay != 0 %>
14 <%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %> <%= link_to_issue relation.other_issue(@issue) %></td>
14 <%= h(relation.other_issue(@issue).project) + ' - ' if Setting.cross_project_issue_relations? %>
15 <td><%=h relation.other_issue(@issue).subject %></td>
15 <%= link_to_issue relation.other_issue(@issue) %>
16 </td>
16 <td><%= relation.other_issue(@issue).status.name %></td>
17 <td><%= relation.other_issue(@issue).status.name %></td>
17 <td><%= format_date(relation.other_issue(@issue).start_date) %></td>
18 <td><%= format_date(relation.other_issue(@issue).start_date) %></td>
18 <td><%= format_date(relation.other_issue(@issue).due_date) %></td>
19 <td><%= format_date(relation.other_issue(@issue).due_date) %></td>
@@ -83,7 +83,7 top = headers_height + 8
83 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
83 <div style="position: absolute;line-height:1.2em;height:16px;top:<%= top %>px;left:4px;overflow:hidden;"><small>
84 <% if i.is_a? Issue %>
84 <% if i.is_a? Issue %>
85 <%= h("#{i.project} -") unless @project && @project == i.project %>
85 <%= h("#{i.project} -") unless @project && @project == i.project %>
86 <%= link_to_issue i %>: <%=h i.subject %>
86 <%= link_to_issue i %>
87 <% else %>
87 <% else %>
88 <span class="icon icon-package">
88 <span class="icon icon-package">
89 <%= h("#{i.project} -") unless @project && @project == i.project %>
89 <%= h("#{i.project} -") unless @project && @project == i.project %>
@@ -31,7 +31,7 entries_by_day = entries.group_by(&:spent_on)
31 <% entries_by_day[day].each do |entry| -%>
31 <% entries_by_day[day].each do |entry| -%>
32 <tr class="time-entry" style="border-bottom: 1px solid #f5f5f5;">
32 <tr class="time-entry" style="border-bottom: 1px solid #f5f5f5;">
33 <td class="activity"><%=h entry.activity %></td>
33 <td class="activity"><%=h entry.activity %></td>
34 <td class="subject"><%=h entry.project %> <%= ' - ' + link_to_issue(entry.issue, :title => h("#{entry.issue.subject} (#{entry.issue.status})")) if entry.issue %></td>
34 <td class="subject"><%=h entry.project %> <%= ' - ' + link_to_issue(entry.issue, :truncate => 50) if entry.issue %></td>
35 <td class="comments"><%=h entry.comments %></td>
35 <td class="comments"><%=h entry.comments %></td>
36 <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
36 <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
37 <td align="center">
37 <td align="center">
@@ -19,7 +19,7
19 <% if !issues.empty? %>
19 <% if !issues.empty? %>
20 <ul>
20 <ul>
21 <% issues.each do |issue| %>
21 <% issues.each do |issue| %>
22 <li><%= link_to_issue(issue) %>: <%=h issue.subject %></li>
22 <li><%= link_to_issue(issue) %></li>
23 <% end %>
23 <% end %>
24 </ul>
24 </ul>
25 <% end %>
25 <% end %>
@@ -20,7 +20,7
20 <fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
20 <fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
21 <ul>
21 <ul>
22 <%- issues.each do |issue| -%>
22 <%- issues.each do |issue| -%>
23 <li><%= link_to_issue(issue) %>: <%=h issue.subject %></li>
23 <li><%= link_to_issue(issue) %></li>
24 <%- end -%>
24 <%- end -%>
25 </ul>
25 </ul>
26 </fieldset>
26 </fieldset>
@@ -30,7 +30,7
30 <h3><%= l(:label_related_issues) %></h3>
30 <h3><%= l(:label_related_issues) %></h3>
31 <ul>
31 <ul>
32 <% @changeset.issues.visible.each do |issue| %>
32 <% @changeset.issues.visible.each do |issue| %>
33 <li><%= link_to_issue issue %>: <%=h issue.subject %></li>
33 <li><%= link_to_issue issue %></li>
34 <% end %>
34 <% end %>
35 </ul>
35 </ul>
36 <% end %>
36 <% end %>
@@ -20,7 +20,7
20 <td class="project"><%=h entry.project %></td>
20 <td class="project"><%=h entry.project %></td>
21 <td class="subject">
21 <td class="subject">
22 <% if entry.issue -%>
22 <% if entry.issue -%>
23 <%= link_to_issue entry.issue %>: <%= h(truncate(entry.issue.subject, :length => 50)) -%>
23 <%= link_to_issue entry.issue, :truncate => 50 -%>
24 <% end -%>
24 <% end -%>
25 </td>
25 </td>
26 <td class="comments"><%=h entry.comments %></td>
26 <td class="comments"><%=h entry.comments %></td>
@@ -39,7 +39,7
39 <fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
39 <fieldset class="related-issues"><legend><%= l(:label_related_issues) %></legend>
40 <ul>
40 <ul>
41 <% issues.each do |issue| -%>
41 <% issues.each do |issue| -%>
42 <li><%= link_to_issue(issue) %>: <%=h issue.subject %></li>
42 <li><%= link_to_issue(issue) %></li>
43 <% end -%>
43 <% end -%>
44 </ul>
44 </ul>
45 </fieldset>
45 </fieldset>
General Comments 0
You need to be logged in to leave comments. Login now