From b4b59df75e4048eaebff7c7efeeee66aa3bfa5a3 Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 16 Sep 2020 15:25:27 +0200 Subject: [PATCH] Show linked features as collapsable detail panels on feature browse pages Fixes #2823 The panels are collapsed by default, when there is a long list of features, but open on short lists to save on clicks. 10 items is arbitrary but seemed reasonable. --- app/views/browse/_node.html.erb | 24 +++++++++++++++----- app/views/browse/_relation.html.erb | 14 ++++++++++-- app/views/browse/_way.html.erb | 34 +++++++++++++++++------------ config/locales/en.yml | 11 ++++++++++ 4 files changed, 61 insertions(+), 22 deletions(-) diff --git a/app/views/browse/_node.html.erb b/app/views/browse/_node.html.erb index 6acc5e01e..ab91a9728 100644 --- a/app/views/browse/_node.html.erb +++ b/app/views/browse/_node.html.erb @@ -12,12 +12,24 @@ <% unless node.ways.empty? and node.containing_relation_members.empty? %>

<%= t "browse.part_of" %>

- + <% unless node.ways.empty? %> +
> + <%= t 'browse.part_of_ways', :count => node.ways.count %> + +
+ <% end %> + <% unless node.containing_relation_members.empty? %> +
> + <%= t 'browse.part_of_relations', :count => node.containing_relation_members.count %> + +
+ <% end %> <% end %> <% end %> diff --git a/app/views/browse/_relation.html.erb b/app/views/browse/_relation.html.erb index b54581b8b..1dc78afba 100644 --- a/app/views/browse/_relation.html.erb +++ b/app/views/browse/_relation.html.erb @@ -12,12 +12,22 @@ <% unless relation.containing_relation_members.empty? %>

<%= t "browse.part_of" %>

- +
> + <%= t 'browse.part_of_relations', :count => relation.containing_relation_members.count %> + +
<% end %> <% unless relation.relation_members.empty? %>

<%= t ".members" %>

- +
> + <%= t '.members_count', :count => relation.relation_members.count %> + +
<% end %> <% end %> diff --git a/app/views/browse/_way.html.erb b/app/views/browse/_way.html.erb index 137d529ff..2788fdea9 100644 --- a/app/views/browse/_way.html.erb +++ b/app/views/browse/_way.html.erb @@ -12,24 +12,30 @@ <% unless way.containing_relation_members.empty? %>

<%= t "browse.part_of" %>

- +
> + <%= t 'browse.part_of_relations', :count => way.containing_relation_members.count %> + +
<% end %> <% unless way.way_nodes.empty? %>

<%= t ".nodes" %>

- +
> + <%= t '.nodes_count', :count => way.way_nodes.count %> + +
<% end %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 997500b3d..ec08012fe 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -232,6 +232,12 @@ en: anonymous: "anonymous" no_comment: "(no comment)" part_of: "Part of" + part_of_relations: + one: 1 relation + other: "%{count} relations" + part_of_ways: + one: 1 way + other: "%{count} ways" download_xml: "Download XML" view_history: "View History" view_details: "View Details" @@ -265,6 +271,8 @@ en: title_html: "Way: %{name}" history_title_html: "Way History: %{name}" nodes: "Nodes" + nodes_count: + other: "%{count} nodes" also_part_of_html: one: "part of way %{related_ways}" other: "part of ways %{related_ways}" @@ -272,6 +280,9 @@ en: title_html: "Relation: %{name}" history_title_html: "Relation History: %{name}" members: "Members" + members_count: + one: 1 member + other: "%{count} members" relation_member: entry_html: "%{type} %{name}" entry_role_html: "%{type} %{name} as %{role}" -- 2.45.1