Merge remote-tracking branch 'upstream/pull/4272'
This commit is contained in:
commit
71cb2c50fc
5 changed files with 63 additions and 18 deletions
|
@ -72,10 +72,6 @@ time[title] {
|
|||
border-color: $grey !important;
|
||||
}
|
||||
|
||||
.border-lightgrey {
|
||||
border-color: $lightgrey !important;
|
||||
}
|
||||
|
||||
/* Rules for the header */
|
||||
|
||||
#menu-icon {
|
||||
|
|
|
@ -82,6 +82,29 @@ module BrowseHelper
|
|||
end
|
||||
end
|
||||
|
||||
def sidebar_classic_pagination(pages, page_param)
|
||||
max_width_for_default_padding = 35
|
||||
|
||||
width = 0
|
||||
pagination_items(pages, {}).each do |body|
|
||||
width += 2 # padding width
|
||||
width += body.length
|
||||
end
|
||||
link_classes = ["page-link", { "px-1" => width > max_width_for_default_padding }]
|
||||
|
||||
tag.ul :class => "pagination pagination-sm mb-1 ms-auto" do
|
||||
pagination_items(pages, {}).each do |body, n|
|
||||
linked = !(n.is_a? String)
|
||||
link = if linked
|
||||
link_to body, url_for(page_param => n), :class => link_classes
|
||||
else
|
||||
tag.span body, :class => link_classes
|
||||
end
|
||||
concat tag.li link, :class => ["page-item", { n => !linked }]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
ICON_TAGS = %w[aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway].freeze
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
<div class="row">
|
||||
<div class="col">
|
||||
<h4><%= heading %></h4>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<h4 class="fs-5 mb-0"><%= type_and_paginated_count(type, pages) %></h4>
|
||||
<% if pages.page_count > 1 %>
|
||||
<div class="col-auto">
|
||||
<h4>
|
||||
<span class="border border-lightgrey rounded p-1">
|
||||
<%= raw pagination_links_each(pages, {}) { |n| link_to(n, page_param => n) } %>
|
||||
</span>
|
||||
</h4>
|
||||
</div>
|
||||
<%= sidebar_classic_pagination(pages, "#{type}_page") %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<% end %>
|
||||
|
||||
<% unless @ways.empty? %>
|
||||
<%= render :partial => "paging_nav", :locals => { :heading => type_and_paginated_count("way", @way_pages), :pages => @way_pages, :page_param => "way_page" } %>
|
||||
<%= render :partial => "paging_nav", :locals => { :type => "way", :pages => @way_pages } %>
|
||||
<ul class="list-unstyled">
|
||||
<% @ways.each do |way| %>
|
||||
<%= element_list_item "way", way do %>
|
||||
|
@ -90,7 +90,7 @@
|
|||
<% end %>
|
||||
|
||||
<% unless @relations.empty? %>
|
||||
<%= render :partial => "paging_nav", :locals => { :heading => type_and_paginated_count("relation", @relation_pages), :pages => @relation_pages, :page_param => "relation_page" } %>
|
||||
<%= render :partial => "paging_nav", :locals => { :type => "relation", :pages => @relation_pages } %>
|
||||
<ul class="list-unstyled">
|
||||
<% @relations.each do |relation| %>
|
||||
<%= element_list_item "relation", relation do %>
|
||||
|
@ -103,7 +103,7 @@
|
|||
<% end %>
|
||||
|
||||
<% unless @nodes.empty? %>
|
||||
<%= render :partial => "paging_nav", :locals => { :heading => type_and_paginated_count("node", @node_pages), :pages => @node_pages, :page_param => "node_page" } %>
|
||||
<%= render :partial => "paging_nav", :locals => { :type => "node", :pages => @node_pages } %>
|
||||
<ul class="list-unstyled">
|
||||
<% @nodes.each do |node| %>
|
||||
<%= element_list_item "node", node do %>
|
||||
|
|
|
@ -130,6 +130,40 @@ module ActionView
|
|||
|
||||
html
|
||||
end
|
||||
|
||||
def pagination_items(paginator, options)
|
||||
options = DEFAULT_OPTIONS.merge(options)
|
||||
link_to_current_page = options[:link_to_current_page]
|
||||
always_show_anchors = options[:always_show_anchors]
|
||||
|
||||
current_page = paginator.current_page
|
||||
window_pages = current_page.window(options[:window_size]).pages
|
||||
|
||||
first = paginator.first
|
||||
last = paginator.last
|
||||
|
||||
items = []
|
||||
|
||||
if always_show_anchors && !(wp_first = window_pages[0]).first?
|
||||
items.push [first.number.to_s, first.number]
|
||||
items.push ["...", "disabled"] if wp_first.number - first.number > 1
|
||||
end
|
||||
|
||||
window_pages.each do |page|
|
||||
if current_page == page && !link_to_current_page
|
||||
items.push [page.number.to_s, "active"]
|
||||
else
|
||||
items.push [page.number.to_s, page.number]
|
||||
end
|
||||
end
|
||||
|
||||
if always_show_anchors && !(wp_last = window_pages[-1]).last?
|
||||
items.push ["...", "disabled"] if last.number - wp_last.number > 1
|
||||
items.push [last.number.to_s, last.number]
|
||||
end
|
||||
|
||||
items
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue