Skip to content

Commit

Permalink
AO3-3471 Allow filtering on language specific /works page (#4682)
Browse files Browse the repository at this point in the history
* Keep owner language while using filters

* Show filter button on mobile

* Linter
  • Loading branch information
ceithir authored Dec 5, 2023
1 parent 4c2621e commit 4b37a0d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 34 deletions.
15 changes: 9 additions & 6 deletions app/views/works/_filters.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@
<%= f.text_field :query %>
</dd>

<dt class="language">
<%= f.label :language_id, ts("Language") %>
</dt>
<dd class="language">
<%= f.select(:language_id, language_options_for_select(Language.default_order, "short"), include_blank: true) %>
</dd>
<% unless @language %>
<dt class="language">
<%= f.label :language_id, ts("Language") %>
</dt>
<dd class="language">
<%= f.select(:language_id, language_options_for_select(Language.default_order, "short"), include_blank: true) %>
</dd>
<% end %>
</dl>
</dd>
<dt class="landmark"><%= ts("Submit") %></dt>
Expand All @@ -174,6 +176,7 @@
<%= hidden_field_tag("fandom_id", @fandom.id) if @fandom %>
<%= hidden_field_tag("pseud_id", @pseud.name) if @pseud %>
<%= hidden_field_tag("user_id", @user.login) if @user %>
<%= hidden_field_tag("language_id", @language.short) if @language %>
</div>

<% end %>
Expand Down
53 changes: 25 additions & 28 deletions app/views/works/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,37 @@
<!-- /end descriptions-->

<!--Subnavigation, sorting and actions.-->
<% if @collection || @tag || @user %>
<% if @collection || @tag || @user || @language %>
<div class="navigation actions module">
<h3 class="landmark heading"><%= ts("Navigation and Actions") %></h3>
<!--gift search subnav-->
<% if @collection && @collection.gift_exchange? %>
<%= render 'gifts/gift_search' %>
<%= render "gifts/gift_search" %>
<% end %>
<!--user role subnav-->
<% if @tag || @user || @collection %>
<ul class="user navigation actions" role="navigation">
<% if @user %>
<% if @user == current_user %>
<li id="edit_multiple"><%= link_to ts('Edit Works'), show_multiple_user_works_path(@user) %></li>
<% end %>
<li><%= span_if_current ts('Works in Collections'), collected_user_works_path(@user) %></li>
<li><%= span_if_current ts('Works'), user_works_path(@user) %></li>
<ul class="user navigation actions" role="navigation">
<% if @user %>
<% if @user == current_user %>
<li id="edit_multiple"><%= link_to ts("Edit Works"), show_multiple_user_works_path(@user) %></li>
<% end %>
<% if @tag && !@collection %>
<li><%= span_if_current ts('Works'), tag_works_path(@tag) %></li>
<li><%= span_if_current ts('Bookmarks'), tag_bookmarks_path(@tag) %></li>
<% end %>
<% if @facets.present? %>
<% # Filters button for narrow screens jumps to filters when JavaScript is disabled and opens filters when JavaScript is enabled %>
<li class="narrow-shown hidden"><a href="#work-filters" id="go_to_filters"><%= ts("Filters") %></a></li>
<% end %>
<% if @tag && logged_in? && !@collection %>
<li><%= render 'favorite_tags/form', current_user: @current_user, favorite_tag: @favorite_tag %></li>
<% end %>
<% if @tag && !@collection && (%w(Fandom Character Relationship).include?(@tag.type.to_s) || @tag.name == "F/F") %>
<li><%= link_to_rss feed_tag_path(:id => @tag.id, :format => :atom) %></li>
<% end %>
</ul>
<% end %>
<li><%= span_if_current ts("Works in Collections"), collected_user_works_path(@user) %></li>
<li><%= span_if_current ts("Works"), user_works_path(@user) %></li>
<% end %>
<% if @tag && !@collection %>
<li><%= span_if_current ts("Works"), tag_works_path(@tag) %></li>
<li><%= span_if_current ts("Bookmarks"), tag_bookmarks_path(@tag) %></li>
<% end %>
<% if @facets.present? %>
<%# Filters button for narrow screens jumps to filters when JavaScript is disabled and opens filters when JavaScript is enabled %>
<li class="narrow-shown hidden"><a href="#work-filters" id="go_to_filters"><%= ts("Filters") %></a></li>
<% end %>
<% if @tag && logged_in? && !@collection %>
<li><%= render "favorite_tags/form", current_user: @current_user, favorite_tag: @favorite_tag %></li>
<% end %>
<% if @tag && !@collection && (%w(Fandom Character Relationship).include?(@tag.type.to_s) || @tag.name == "F/F") %>
<li><%= link_to_rss feed_tag_path({ id: @tag.id, format: :atom }) %></li>
<% end %>
</ul>
</div>
<% end %>
<!---/subnav-->
Expand All @@ -55,7 +53,7 @@
<!--main content-->
<h3 class="landmark heading"><%= ts("Listing Works") %></h3>
<ol class="work index group">
<%= render partial: 'work_blurb', collection: @works, as: :work %>
<%= render partial: "work_blurb", collection: @works, as: :work %>
</ol>

<!--/content-->
Expand All @@ -69,4 +67,3 @@
<% if @works.respond_to?(:total_pages) %>
<%= will_paginate @works %>
<% end %>

2 changes: 2 additions & 0 deletions features/works/work_browse.feature
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ Scenario: Can also browse work indexed by language
And I should see "Deutsch" within "dd.language"
When I browse works in language "English"
Then I should see "2 Works in English"
When I press "Sort and Filter"
Then I should see "2 Works in English"
When I browse works in language "Deutsch"
Then I should see "1 Work in Deutsch"
When I browse works in language "Persian"
Expand Down

0 comments on commit 4b37a0d

Please sign in to comment.