Skip to content

Show changeset element counts using badges #4872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 25, 2025

Conversation

AntonKhorev
Copy link
Collaborator

@AntonKhorev AntonKhorev commented Jun 3, 2024

We use counter badges in other places. We can use them on changeset pages in element headings instead of numbers in ().

Before/after:
image image

@AntonKhorev AntonKhorev added the changesets Related to the Changesets feature label Jul 3, 2024
Copy link
Contributor

@nenad-vujicic nenad-vujicic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks and works great, thanks for it! Requires updating with the latest changes of _paging_nav.html.erb / en.yml.

@AntonKhorev AntonKhorev force-pushed the element-count-badge branch 2 times, most recently from 4b59d74 to 30d7f92 Compare August 29, 2024 14:01
@AntonKhorev
Copy link
Collaborator Author

rebased

Copy link
Contributor

@nenad-vujicic nenad-vujicic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks and works perfectly now, thank you very much!

Comment on lines +1 to +17
<% if pages.page_count == 1 %>
<h4 class="fs-5">
<%= t ".#{type.pluralize}_title" %>
<span class="badge count-number">
<%= pages.item_count %>
</span>
</h4>
<% elsif pages.page_count > 1 %>
<h4 class="fs-5">
<%= t ".#{type.pluralize}_title" %>
<span class="badge count-number">
<%= t ".range", :x => pages.current_page.first_item,
:y => pages.current_page.last_item,
:count => pages.item_count %>
</span>
</h4>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd find a duplicated if easier to read than a duplicated h4.

Suggested change
<% if pages.page_count == 1 %>
<h4 class="fs-5">
<%= t ".#{type.pluralize}_title" %>
<span class="badge count-number">
<%= pages.item_count %>
</span>
</h4>
<% elsif pages.page_count > 1 %>
<h4 class="fs-5">
<%= t ".#{type.pluralize}_title" %>
<span class="badge count-number">
<%= t ".range", :x => pages.current_page.first_item,
:y => pages.current_page.last_item,
:count => pages.item_count %>
</span>
</h4>
<h4 class="fs-5">
<%= t ".#{type.pluralize}_title" %>
<span class="badge count-number">
<%= if pages.page_count == 1
pages.item_count
elsif pages.page_count > 1
t(".range", x: pages.current_page.first_item,
y: pages.current_page.last_item,
count: pages.item_count)
end %>
</span>
</h4>
<% if pages.page_count > 1 %>

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reproducing what I removed from browse_helper.rb, except as a code block inside the template.

@tomhughes
Copy link
Member

Looks good to me, thanks.

@tomhughes tomhughes merged commit a232ed0 into openstreetmap:master Mar 25, 2025
22 checks passed
@AntonKhorev AntonKhorev deleted the element-count-badge branch March 25, 2025 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changesets Related to the Changesets feature ui User Interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants