Add titles to changeset element page links
This commit is contained in:
parent
22a6d24857
commit
b072c2935f
4 changed files with 52 additions and 11 deletions
|
@ -70,14 +70,14 @@ module BrowseHelper
|
||||||
"nofollow" if object.tags.empty?
|
"nofollow" if object.tags.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def type_and_paginated_count(type, pages)
|
def type_and_paginated_count(type, pages, selected_page = pages.current_page)
|
||||||
if pages.page_count == 1
|
if pages.page_count == 1
|
||||||
t ".#{type.pluralize}",
|
t ".#{type.pluralize}",
|
||||||
:count => pages.item_count
|
:count => pages.item_count
|
||||||
else
|
else
|
||||||
t ".#{type.pluralize}_paginated",
|
t ".#{type.pluralize}_paginated",
|
||||||
:x => pages.current_page.first_item,
|
:x => selected_page.first_item,
|
||||||
:y => pages.current_page.last_item,
|
:y => selected_page.last_item,
|
||||||
:count => pages.item_count
|
:count => pages.item_count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -93,14 +93,14 @@ module BrowseHelper
|
||||||
link_classes = ["page-link", { "px-1" => width > max_width_for_default_padding }]
|
link_classes = ["page-link", { "px-1" => width > max_width_for_default_padding }]
|
||||||
|
|
||||||
tag.ul :class => "pagination pagination-sm mb-1 ms-auto" do
|
tag.ul :class => "pagination pagination-sm mb-1 ms-auto" do
|
||||||
pagination_items(pages, {}).each do |body, n|
|
pagination_items(pages, {}).each do |body, page_or_class|
|
||||||
linked = !(n.is_a? String)
|
linked = !(page_or_class.is_a? String)
|
||||||
link = if linked
|
link = if linked
|
||||||
link_to body, url_for(page_param => n), :class => link_classes
|
link_to body, url_for(page_param => page_or_class.number), :class => link_classes, :title => yield(page_or_class)
|
||||||
else
|
else
|
||||||
tag.span body, :class => link_classes
|
tag.span body, :class => link_classes
|
||||||
end
|
end
|
||||||
concat tag.li link, :class => ["page-item", { n => !linked }]
|
concat tag.li link, :class => ["page-item", { page_or_class => !linked }]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="d-flex flex-wrap gap-2">
|
<div class="d-flex flex-wrap gap-2">
|
||||||
<h4 class="fs-5 mb-0"><%= type_and_paginated_count(type, pages) %></h4>
|
<h4 class="fs-5 mb-0"><%= type_and_paginated_count(type, pages) %></h4>
|
||||||
<% if pages.page_count > 1 %>
|
<% if pages.page_count > 1 %>
|
||||||
<%= sidebar_classic_pagination(pages, "#{type}_page") %>
|
<%= sidebar_classic_pagination(pages, "#{type}_page") { |page| type_and_paginated_count(type, pages, page) } %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -145,7 +145,7 @@ module ActionView
|
||||||
items = []
|
items = []
|
||||||
|
|
||||||
if always_show_anchors && !(wp_first = window_pages[0]).first?
|
if always_show_anchors && !(wp_first = window_pages[0]).first?
|
||||||
items.push [first.number.to_s, first.number]
|
items.push [first.number.to_s, first]
|
||||||
items.push ["...", "disabled"] if wp_first.number - first.number > 1
|
items.push ["...", "disabled"] if wp_first.number - first.number > 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -153,13 +153,13 @@ module ActionView
|
||||||
if current_page == page && !link_to_current_page
|
if current_page == page && !link_to_current_page
|
||||||
items.push [page.number.to_s, "active"]
|
items.push [page.number.to_s, "active"]
|
||||||
else
|
else
|
||||||
items.push [page.number.to_s, page.number]
|
items.push [page.number.to_s, page]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if always_show_anchors && !(wp_last = window_pages[-1]).last?
|
if always_show_anchors && !(wp_last = window_pages[-1]).last?
|
||||||
items.push ["...", "disabled"] if last.number - wp_last.number > 1
|
items.push ["...", "disabled"] if last.number - wp_last.number > 1
|
||||||
items.push [last.number.to_s, last.number]
|
items.push [last.number.to_s, last]
|
||||||
end
|
end
|
||||||
|
|
||||||
items
|
items
|
||||||
|
|
41
test/system/changeset_elements_test.rb
Normal file
41
test/system/changeset_elements_test.rb
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
require "application_system_test_case"
|
||||||
|
|
||||||
|
class ChangesetElementsTest < ApplicationSystemTestCase
|
||||||
|
test "can navigate between element subpages without losing comment input" do
|
||||||
|
element_page_size = 20
|
||||||
|
changeset = create(:changeset, :closed)
|
||||||
|
ways = create_list(:way, element_page_size + 1, :with_history, :changeset => changeset)
|
||||||
|
way_paths = ways.map { |way| way_path(way) }
|
||||||
|
nodes = create_list(:node, element_page_size + 1, :with_history, :changeset => changeset)
|
||||||
|
node_paths = nodes.map { |node| node_path(node) }
|
||||||
|
|
||||||
|
sign_in_as(create(:user))
|
||||||
|
visit changeset_path(changeset)
|
||||||
|
|
||||||
|
within_sidebar do
|
||||||
|
assert_one_missing_link way_paths
|
||||||
|
assert_link "Ways (21-21 of 21)"
|
||||||
|
|
||||||
|
assert_one_missing_link node_paths
|
||||||
|
assert_link "Nodes (21-21 of 21)"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def assert_one_missing_link(hrefs)
|
||||||
|
missing_href = nil
|
||||||
|
hrefs.each do |href|
|
||||||
|
missing = true
|
||||||
|
assert_link :href => href, :minimum => 0, :maximum => 1 do
|
||||||
|
missing = false
|
||||||
|
end
|
||||||
|
if missing
|
||||||
|
assert_nil missing_href, "unexpected extra missing link '#{href}'"
|
||||||
|
missing_href = href
|
||||||
|
end
|
||||||
|
end
|
||||||
|
assert_not_nil missing_href, "expected one link missing but all are present"
|
||||||
|
missing_href
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue