margin-left: 25px;
}
- /* Deleted objects */
-
- .deleted { text-decoration: line-through; }
-
/* Nodes (and ways as areas) */
.aeroway.aerodrome::before { content: image-url('browse/aerodrome.p.16.png'); }
module BrowseHelper
+ def element_single_current_link(type, object, url)
+ link_to url, { :class => element_class(type, object), :title => link_title(object), :rel => (link_follow(object) if type == "node") } do
+ element_strikethrough object do
+ printable_name object
+ end
+ end
+ end
+
def printable_name(object, version: false)
id = if object.id.is_a?(Array)
object.id[0]
name
end
- def element_class(type, object)
- classes = [type]
-
- if object.redacted?
- classes << "deleted"
+ def element_strikethrough(object, &block)
+ if object.redacted? || !object.visible?
+ tag.s(&block)
else
- classes += icon_tags(object).flatten.map { |t| h(t) }
- classes << "deleted" unless object.visible?
+ yield
end
+ end
+ def element_class(type, object)
+ classes = [type]
+ classes += icon_tags(object).flatten.map { |t| h(t) } unless object.redacted?
classes.join(" ")
end
<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 => element_class("way", way), :title => link_title(way) } %></li>
+ <li><%= element_single_current_link "way", way, way_path(way) %></li>
<% end %>
</ul>
</details>
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 %>">
- <%= if relation_member.member_role.blank?
- t ".entry_html", :type => type_str, :name => linked_name
- else
- t ".entry_role_html", :type => type_str, :name => linked_name, :role => relation_member.member_role
- end %>
+ <%= element_strikethrough relation_member.member do %>
+ <%= if relation_member.member_role.blank?
+ t ".entry_html", :type => type_str, :name => linked_name
+ else
+ t ".entry_role_html", :type => type_str, :name => linked_name, :role => relation_member.member_role
+ end %>
+ <% end %>
</li>
<ul class="list-unstyled">
<% way.way_nodes.each do |wn| %>
<li>
- <%= 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) } %>
+ <%= element_single_current_link "node", wn.node, node_path(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 => element_class("way", w), :title => link_title(w) }) }) %>)
+ (<%= t ".also_part_of_html",
+ :count => related_ways.size,
+ :related_ways => to_sentence(related_ways.map { |w| element_single_current_link "way", w, way_path(w) }) %>)
<% end %>
</li>
<% end %>
<ul class="list-unstyled">
<% @ways.each do |way| %>
<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) } %>
+ <%= element_strikethrough way do %>
+ <%= link_to printable_name(way, :version => true), { :action => "way", :id => way.way_id.to_s }, { :title => link_title(way) } %>
+ <% end %>
</li>
<% end %>
</ul>
<ul class="list-unstyled">
<% @relations.each do |relation| %>
<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) } %>
+ <%= element_strikethrough relation do %>
+ <%= link_to printable_name(relation, :version => true), { :action => "relation", :id => relation.relation_id.to_s }, { :title => link_title(relation) } %>
+ <% end %>
</li>
<% end %>
</ul>
<ul class="list-unstyled">
<% @nodes.each do |node| %>
<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) } %>
+ <%= element_strikethrough node do %>
+ <%= link_to printable_name(node, :version => true), { :action => "node", :id => node.node_id.to_s }, { :title => link_title(node), :rel => link_follow(node) } %>
+ <% end %>
</li>
<% end %>
</ul>
end
end
+ def test_element_strikethrough
+ 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)
+ node_v1.redact!(create(:redaction))
+
+ normal_output = element_strikethrough(node_v2) { "test" }
+ assert_equal "test", normal_output
+
+ redacted_output = element_strikethrough(node_v1) { "test" }
+ assert_equal "<s>test</s>", redacted_output
+
+ deleted_output = element_strikethrough(create(:node, :deleted)) { "test" }
+ assert_equal "<s>test</s>", deleted_output
+ end
+
def test_element_class
node = create(:node, :with_history, :version => 2)
node_v1 = node.old_nodes.find_by(:version => 1)
add_old_tags_selection(node_v1)
assert_equal "node", element_class("node", create(:node))
- assert_equal "node deleted", element_class("node", create(:node, :deleted))
+ assert_equal "node", element_class("node", create(:node, :deleted))
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)
+ assert_equal "node", element_class("node", node_v1)
end
def test_link_title