name
end
- def link_class(type, object)
+ def element_class(type, object)
classes = [type]
if object.redacted?
<summary><%= t "browse.part_of_ways", :count => node.ways.uniq.count %></summary>
<ul class="list-unstyled">
<% node.ways.uniq.each do |way| %>
- <li><%= link_to printable_name(way), way_path(way), { :class => link_class("way", way), :title => link_title(way) } %></li>
+ <li><%= link_to printable_name(way), way_path(way), { :class => element_class("way", way), :title => link_title(way) } %></li>
<% end %>
</ul>
</details>
-<% member_class = link_class(relation_member.member_type.downcase, relation_member.member)
+<% member_class = element_class(relation_member.member_type.downcase, relation_member.member)
linked_name = link_to printable_name(relation_member.member), { :controller => :browse, :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, { :title => link_title(relation_member.member), :rel => link_follow(relation_member.member) }
type_str = t ".type.#{relation_member.member_type.downcase}" %>
<li class="<%= member_class %>">
<ul class="list-unstyled">
<% way.way_nodes.each do |wn| %>
<li>
- <%= link_to printable_name(wn.node), node_path(wn.node), { :class => link_class("node", wn.node), :title => link_title(wn.node), :rel => link_follow(wn.node) } %>
+ <%= link_to printable_name(wn.node), node_path(wn.node), { :class => element_class("node", wn.node), :title => link_title(wn.node), :rel => link_follow(wn.node) } %>
<% related_ways = wn.node.ways.reject { |w| w.id == wn.way_id } %>
<% if related_ways.size > 0 then %>
- (<%= t ".also_part_of_html", :count => related_ways.size, :related_ways => to_sentence(related_ways.map { |w| link_to(printable_name(w), way_path(w), { :class => link_class("way", w), :title => link_title(w) }) }) %>)
+ (<%= t ".also_part_of_html", :count => related_ways.size, :related_ways => to_sentence(related_ways.map { |w| link_to(printable_name(w), way_path(w), { :class => element_class("way", w), :title => link_title(w) }) }) %>)
<% end %>
</li>
<% end %>
<%= render :partial => "paging_nav", :locals => { :heading => type_and_paginated_count("way", @way_pages), :pages => @way_pages, :page_param => "way_page" } %>
<ul class="list-unstyled">
<% @ways.each do |way| %>
- <li><%= link_to printable_name(way, :version => true), { :action => "way", :id => way.way_id.to_s }, { :class => link_class("way", way), :title => link_title(way) } %></li>
+ <li class="<%= element_class("way", way) %>">
+ <%= link_to printable_name(way, :version => true), { :action => "way", :id => way.way_id.to_s }, { :title => link_title(way) } %>
+ </li>
<% end %>
</ul>
<% end %>
<%= render :partial => "paging_nav", :locals => { :heading => type_and_paginated_count("relation", @relation_pages), :pages => @relation_pages, :page_param => "relation_page" } %>
<ul class="list-unstyled">
<% @relations.each do |relation| %>
- <li><%= link_to printable_name(relation, :version => true), { :action => "relation", :id => relation.relation_id.to_s }, { :class => link_class("relation", relation), :title => link_title(relation) } %></li>
+ <li class="<%= element_class("relation", relation) %>">
+ <%= link_to printable_name(relation, :version => true), { :action => "relation", :id => relation.relation_id.to_s }, { :title => link_title(relation) } %>
+ </li>
<% end %>
</ul>
<% end %>
<%= render :partial => "paging_nav", :locals => { :heading => type_and_paginated_count("node", @node_pages), :pages => @node_pages, :page_param => "node_page" } %>
<ul class="list-unstyled">
<% @nodes.each do |node| %>
- <li><%= link_to printable_name(node, :version => true), { :action => "node", :id => node.node_id.to_s }, { :class => link_class("node", node), :title => link_title(node), :rel => link_follow(node) } %></li>
+ <li class="<%= element_class("node", node) %>">
+ <%= link_to printable_name(node, :version => true), { :action => "node", :id => node.node_id.to_s }, { :title => link_title(node), :rel => link_follow(node) } %>
+ </li>
<% end %>
</ul>
<% end %>
end
end
- def test_link_class
+ def test_element_class
node = create(:node, :with_history, :version => 2)
node_v1 = node.old_nodes.find_by(:version => 1)
node_v2 = node.old_nodes.find_by(:version => 2)
add_old_tags_selection(node_v2)
add_old_tags_selection(node_v1)
- assert_equal "node", link_class("node", create(:node))
- assert_equal "node deleted", link_class("node", create(:node, :deleted))
+ assert_equal "node", element_class("node", create(:node))
+ assert_equal "node deleted", element_class("node", create(:node, :deleted))
- assert_equal "node building yes shop gift tourism museum", link_class("node", node)
- assert_equal "node building yes shop gift tourism museum", link_class("node", node_v2)
- assert_equal "node deleted", link_class("node", node_v1)
+ assert_equal "node building yes shop gift tourism museum", element_class("node", node)
+ assert_equal "node building yes shop gift tourism museum", element_class("node", node_v2)
+ assert_equal "node deleted", element_class("node", node_v1)
end
def test_link_title