Skip to content
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

Merged
merged 1 commit into from
Aug 19, 2024

Conversation

sarken
Copy link
Member

@sarken sarken commented Aug 19, 2024

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:

  • updated the heading on the user creation summary list boxes to say, "X - Y of Total Items"
  • removed the role="navigation" from two lists, because that's not a valid way to use that attribute
  • switched to span_if_current in the navigation, which is a little unnecessary, but never a bad idea for consistency
  • added a "Creations" navigation item as a breadcrumb on the User Creations page

Testing Instructions

What needs testing

@sarken sarken added Priority: High - Broken on Test Merge immediately after approval Awaiting Review labels Aug 19, 2024
<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>
Copy link
Member Author

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.

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

Copy link
Contributor

Choose a reason for hiding this comment

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

😱

Copy link
Contributor

@Bilka2 Bilka2 left a comment

Choose a reason for hiding this comment

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

Very nice.

@brianjaustin brianjaustin merged commit 72f2932 into otwcode:master Aug 19, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants