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-6238 Random Items button on a collection doesn't work from the collection homepage #4462

54 changes: 23 additions & 31 deletions app/views/collections/_sidebar.html.erb
Original file line number Diff line number Diff line change
@@ -1,62 +1,54 @@
<div id="dashboard" class="region" role="navigation region">
<h3 class="landmark heading">Dashboard</h3>
<h3 class="landmark heading"><%= t(".landmark.dashboard") %></h3>
<ul class="navigation actions">
<li><%= span_if_current ts('Dashboard', key: 'dashboard'), @collection %></li>
<li><%= span_if_current ts('Profile', key: 'dashboard'), collection_profile_path(@collection) %></li>
<li><%= span_if_current t(".dashboard"), @collection %></li>
<li><%= span_if_current t(".profile"), collection_profile_path(@collection) %></li>
<% if [email protected]_profile.faq.blank? %>
<li><%= span_if_current ts('FAQ', key: 'dashboard'), collection_profile_path(@collection, :anchor => "faq") %></li>
<li><%= span_if_current t(".faq"), collection_profile_path(@collection, anchor: "faq") %></li>
<% end %>
<% if [email protected]_profile.rules.blank? %>
<li><%= span_if_current ts('Rules', key: 'dashboard'), collection_profile_path(@collection, :anchor => "rules") %></li>
<li><%= span_if_current t(".rules"), collection_profile_path(@collection, anchor: "rules") %></li>
<% end %>

<% if @collection.parent %>
<li><%= link_to ts('Parent Collection', key: 'dashboard'), collection_path(@collection.parent) %></li>
<li><%= link_to t(".parent_collection"), collection_path(@collection.parent) %></li>
<% else %>
<li><%= span_if_current ts("Subcollections (%{count})", key: 'dashboard', :count => @collection.children.count), collection_collections_path(@collection) %></li>
<li><%= span_if_current t(".subcollections", count: @collection.children.count), collection_collections_path(@collection) %></li>
<% end %>
</ul>

<!-- challenge section of dash -->
<% if @collection.challenge %>
<%= render :partial => "challenge/#{challenge_class_name(@collection)}/challenge_sidebar" %>
<%= render partial: "challenge/#{challenge_class_name(@collection)}/challenge_sidebar" %>
<% end %>

<h4 class="landmark heading">Contents</h4>
<h4 class="landmark heading"><%= t(".landmark.contents") %></h4>
<ul class="navigation actions">
<li><%= span_if_current ts("Fandoms (%{count})", key: 'dashboard', count: SearchCounts.fandom_count_for_collection(@collection)), collection_fandoms_path(@collection) %></li>
<li><%= span_if_current t(".fandoms", count: SearchCounts.fandom_count_for_collection(@collection)), collection_fandoms_path(@collection) %></li>

<li><%= span_if_current ts("Works (%{count})", key: 'dashboard', count: SearchCounts.work_count_for_collection(@collection)), collection_works_path(@collection) %></li>
<li><%= span_if_current t(".works", count: SearchCounts.work_count_for_collection(@collection)), collection_works_path(@collection) %></li>

<li><%= span_if_current ts("Bookmarked Items (%{count})", key: 'dashboard', count: SearchCounts.bookmarkable_count_for_collection(@collection)), collection_bookmarks_path(@collection) %></li>
<li><%= span_if_current t(".bookmarks", count: SearchCounts.bookmarkable_count_for_collection(@collection)), collection_bookmarks_path(@collection) %></li>

<li>
<% if controller.controller_name == 'collections' && controller.action_name == 'show' %>
<%= link_to 'Random Items',
:url => collection_path(@collection, :show_random => true), :method => :get, :remote => true %>
<% else %>
<%= link_to 'Random Items', collection_path(@collection, :show_random => true) %>
<% end %>
</li>
<li><%= span_if_current ts('People', key: 'dashboard'), collection_people_path(@collection) %></li>
<li><%= span_if_current ts('Tags', key: 'dashboard'), collection_tags_path(@collection) %></li>
</ul>
<li><%= span_if_current t(".random_items"), collection_path(@collection, show_random: true) %></li>
<li><%= span_if_current t(".people"), collection_people_path(@collection) %></li>
<li><%= span_if_current t(".tags"), collection_tags_path(@collection) %></li>
</ul>

<% if @collection.user_is_maintainer?(current_user)%>
<h4 class="landmark heading">Choices</h4>
<% if @collection.user_is_maintainer?(current_user) %>
<h4 class="landmark heading"><%= t(".landmark.choices") %></h4>
<ul class="navigation actions">
<li><%= span_if_current(ts('Manage Items', key: 'dashboard'), collection_items_path(@collection)) %></li>
<li><%= span_if_current(t(".manage_items"), collection_items_path(@collection)) %></li>
<% if @collection.user_is_owner?(current_user) %>
<% if @collection.challenge %>
<% if @collection.prompt_meme? %>
<li><%= span_if_current ts('Challenge Settings', key: 'dashboard'), edit_collection_prompt_meme_path(@collection) %></li>
<li><%= span_if_current t(".challenge_settings"), edit_collection_prompt_meme_path(@collection) %></li>
<% elsif @collection.gift_exchange? %>
<li><%= span_if_current ts('Challenge Settings', key: 'dashboard'), edit_collection_gift_exchange_path(@collection) %></li>
<li><%= span_if_current t(".challenge_settings"), edit_collection_gift_exchange_path(@collection) %></li>
<% end %>
<% end %>
<li><%= span_if_current ts('Collection Settings', key: 'dashboard'), edit_collection_path(@collection) %></li>
<li><%= span_if_current t(".collection_settings"), edit_collection_path(@collection) %></li>
<% end %>
</ul>
<% end %>
</div>

8 changes: 4 additions & 4 deletions app/views/wrangling_guidelines/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!--Descriptive page name, messages and instructions-->
<h2 class="heading"><%= link_to ts('Wrangling Guidelines'), wrangling_guidelines_path %> > <%= @wrangling_guideline.title %></h2>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this > the typo you're referring to? It's not a typo -- it's part of the heading, to make it breadcrumb-like. For example, "Wrangling Guidelines > Wrangling Guidelines - Intro and General Concepts" on these guidelines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

whoops, I'll fix that...

<h2 class="heading"><%= link_to t(".heading"), wrangling_guidelines_path %> > <%= @wrangling_guideline.title %></h2>
<!--/descriptions-->

<!--subnav-->
Expand All @@ -11,12 +11,12 @@
<% if logged_in_as_admin? %>
<div class="header">
<h3 class="heading">
Updated: <%=h @wrangling_guideline.updated_at %> | <%= link_to ts('Edit'), edit_wrangling_guideline_path(@wrangling_guideline) %>
Updated: <%= h @wrangling_guideline.updated_at %> | <%= link_to t(".edit"), edit_wrangling_guideline_path(@wrangling_guideline) %>
</h3>
</div>
<% end %>
<div class="userstuff">
<%=raw sanitize_field(@wrangling_guideline, :content) %>
<%= raw sanitize_field(@wrangling_guideline, :content) %>
</div>
</div>
<!--/content-->
<!--/content-->
25 changes: 25 additions & 0 deletions config/locales/views/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,27 @@ en:
notice:
unreviewed_by_collection: Works and bookmarks listed here have been added to a collection but need approval from a collection moderator before they are listed in the collection.
page_heading: Items by %{username} in Collections
collections:
sidebar:
bookmarks: Bookmarked Items (%{count})
challenge_settings: Challenge Settings
collection_settings: Collection Settings
dashboard: Dashboard
fandoms: Fandoms (%{count})
faq: FAQ
landmark:
choices: Choices
contents: Contents
dashboard: Dashboard
manage_items: Manage Items
parent_collection: Parent Collection
people: People
profile: Profile
random_items: Random Items
rules: Rules
subcollections: Subcollections (%{count})
tags: Tags
works: Works (%{count})
comments:
comment_form:
anonymous_creator: Anonymous Creator
Expand Down Expand Up @@ -1094,3 +1115,7 @@ en:
unrevealed: A translation of a work in an unrevealed collection
work_module:
draft_deletion_notice_html: This draft will be <strong>scheduled for deletion</strong> on %{deletion_date}.
wrangling_guidelines:
show:
edit: Edit
heading: Wrangling Guidelines
17 changes: 17 additions & 0 deletions features/collections/collection_dashboard.feature
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,20 @@ Feature: Collection
Then I should see "Dashboard Light"
And I should see "Recent bookmarks"
And I should see "Bookmarks (6)" within "#collection-bookmarks"

Scenario: Given that I am on a collection's homepage the "Random Items" button should work

Given I have a collection "Dashboard Light" with name "dashboard_light"
And I am logged in as "user"
When I post the work "Work 1" in the collection "Dashboard Light"
And I post the work "Work 2" in the collection "Dashboard Light"
And I post the work "Work 3" in the collection "Dashboard Light"
And I post the work "Work 4" in the collection "Dashboard Light"
And I post the work "Work 5" in the collection "Dashboard Light"
And I post the work "Work 6" in the collection "Dashboard Light"
When I go to "Dashboard Light" collection's page
Then I should see "Random Items"

When I go to "Dashboard Light" collection's page
And I follow "Random Items"
Then I should see "Random works"
Loading