Refactor reportable_url to just return the url
Allows removal of the largely duplicate instance_url helper (which returned the same urls, but with a hard-coded title).
This commit is contained in:
parent
2a89bf2e6c
commit
3bd06529c7
5 changed files with 15 additions and 31 deletions
|
@ -1,17 +1,16 @@
|
|||
module IssuesHelper
|
||||
def reportable_url(reportable)
|
||||
class_name = reportable.class.name
|
||||
case class_name
|
||||
when "DiaryEntry"
|
||||
link_to reportable.title, :controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.user.display_name, :id => reportable.id
|
||||
when "User"
|
||||
link_to reportable.display_name.to_s, :controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.display_name
|
||||
when "DiaryComment"
|
||||
link_to "#{reportable.diary_entry.title}, Comment id ##{reportable.id}", :controller => reportable.diary_entry.class.name.underscore, :action => :view, :display_name => reportable.diary_entry.user.display_name, :id => reportable.diary_entry.id, :anchor => "comment#{reportable.id}"
|
||||
when "Changeset"
|
||||
link_to "Changeset ##{reportable.id}", :controller => :browse, :action => :changeset, :id => reportable.id
|
||||
when "Note"
|
||||
link_to "Note ##{reportable.id}", :controller => :browse, :action => :note, :id => reportable.id
|
||||
case reportable
|
||||
when DiaryEntry
|
||||
url_for(:controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.user.display_name, :id => reportable.id)
|
||||
when User
|
||||
url_for(:controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.display_name)
|
||||
when DiaryComment
|
||||
url_for(:controller => reportable.diary_entry.class.name.underscore, :action => :view, :display_name => reportable.diary_entry.user.display_name, :id => reportable.diary_entry.id, :anchor => "comment#{reportable.id}")
|
||||
when Changeset
|
||||
url_for(:controller => :browse, :action => :changeset, :id => reportable.id)
|
||||
when Note
|
||||
url_for(:controller => :browse, :action => :note, :id => reportable.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,20 +28,4 @@ module IssuesHelper
|
|||
"Note ##{reportable.id}"
|
||||
end
|
||||
end
|
||||
|
||||
def instance_url(reportable)
|
||||
class_name = reportable.class.name
|
||||
case class_name
|
||||
when "DiaryEntry"
|
||||
link_to "Show Instance", :controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.user.display_name, :id => reportable.id
|
||||
when "User"
|
||||
link_to "Show Instance", :controller => reportable.class.name.underscore, :action => :view, :display_name => reportable.display_name
|
||||
when "DiaryComment"
|
||||
link_to "Show Instance", :controller => reportable.diary_entry.class.name.underscore, :action => :view, :display_name => reportable.diary_entry.user.display_name, :id => reportable.diary_entry.id, :anchor => "comment#{reportable.id}"
|
||||
when "Changeset"
|
||||
link_to "Show Instance", :controller => :browse, :action => :changeset, :id => reportable.id
|
||||
when "Note"
|
||||
link_to "Show Instance", :controller => :browse, :action => :note, :id => reportable.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<td><% if issue.user_updated %> <%= issue.user_updated.display_name %> <% else %> - <% end %></td>
|
||||
<td><%= link_to reportable_title(issue.reportable), issue %></td>
|
||||
<td><%= link_to issue.reported_user.display_name , :controller => :user, :action => :view, :display_name => issue.reported_user.display_name %></td>
|
||||
<td><%= instance_url(issue.reportable) %></td>
|
||||
<td><%= link_to t(".show_instance"), reportable_url(issue.reportable) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% content_for :heading do %>
|
||||
<h2><%= t ".title", :status => @issue.status.humanize, :issue_id => @issue.id %></h2>
|
||||
<p><%= @issue.reportable.model_name.human %> : <%= reportable_url(@issue.reportable) %></p>
|
||||
<p><%= @issue.reportable.model_name.human %> : <%= link_to reportable_title(@issue.reportable), reportable_url(@issue.reportable) %></p>
|
||||
<p class="deemphasize">
|
||||
<small>
|
||||
<%= @issue.assigned_role %>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<% content_for :heading do %>
|
||||
<h1><%= t ".title_html", :link => reportable_url(@report.issue.reportable) %></h1>
|
||||
<h1><%= t ".title_html", :link => link_to(reportable_title(@report.issue.reportable), reportable_url(@report.issue.reportable)) %></h1>
|
||||
<% end %>
|
||||
|
||||
<div class="disclaimer">
|
||||
|
|
|
@ -925,6 +925,7 @@ en:
|
|||
user_not_found: User does not exist
|
||||
issues_not_found: No such issues found
|
||||
status: Status
|
||||
show_instance: Show Instance
|
||||
number_of_reports: Number of Reports
|
||||
last_updated_at: Last Updated At
|
||||
last_updated_by: Last Updated By
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue