-
Notifications
You must be signed in to change notification settings - Fork 491
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
AO3-6539 Update user creation summary h3s and pagination behavior #4897
Conversation
<div class="work listbox group" id="works-summary"> | ||
<h3 class="heading"><%= t(".works", count: works.size) %></h3> | ||
<h3 class="heading"><%= search_header(@works, nil, "Work") %></h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We just call pluralize
on the string passed here, which is... oof. A problem for future us.
otwarchive/app/helpers/search_helper.rb
Lines 4 to 37 in 3f1a3f9
def search_header(collection, search, item_name, parent=nil) | |
header = [] | |
if !collection.respond_to?(:total_pages) | |
header << ts("Recent #{item_name.pluralize}") | |
elsif collection.total_pages < 2 | |
header << pluralize(collection.total_entries, item_name) | |
else | |
total_entries = collection.total_entries | |
total_entries = collection.unlimited_total_entries if collection.respond_to?(:unlimited_total_entries) | |
header << ts(" %{start_number} - %{end_number} of %{total} %{things}", | |
start_number: number_with_delimiter(collection.offset + 1), | |
end_number: number_with_delimiter(collection.offset + collection.length), | |
total: number_with_delimiter(total_entries), | |
things: item_name.pluralize) | |
end | |
header << ts("found") if search.present? && search.query.present? | |
case parent | |
when Collection | |
header << ts("in %{collection_link}", collection_link: link_to(parent.title, parent)) | |
when Pseud | |
header << ts("by %{byline}", byline: parent.byline) | |
when User | |
header << ts("by %{username}", username: parent.login) | |
when Language | |
header << ts("in %{language}", language: parent.name) | |
end | |
header << ts("in %{tag_link}", tag_link: link_to_tag_with_text(parent, parent.name)) if parent.is_a?(Tag) | |
# The @fandom version is used when following a fandom link from a user's dashboard, which | |
# which will take you to a URL like /users/username/works?fandom_id=123. | |
header << ts("in %{fandom_link}", fandom_link: link_to_tag(@fandom)) if @fandom.present? | |
header.join(" ").html_safe | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😱
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice.
Issue
https://otwarchive.atlassian.net/browse/AO3-6539
Purpose
If an admin manually entered a URL with incorrect pagination params for user creations, they would see a page saying the user had no works or comments. Now it will not say that, but it will display empty list boxes with pagination links (if applicable) to be more consistent with other pages on the site.
I also:
role="navigation"
from two lists, because that's not a valid way to use that attributespan_if_current
in the navigation, which is a little unnecessary, but never a bad idea for consistencyTesting Instructions
What needs testing