mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Disallow removing filters from sort by column
This commit is contained in:
parent
0a7c483044
commit
69b316e708
2 changed files with 20 additions and 7 deletions
|
@ -7,6 +7,7 @@
|
|||
# - filters: the array of filters within the column we're creating
|
||||
# - filter_name: name of the filter
|
||||
# - selected_default: default selected filter
|
||||
# - allow_removal: allows selected filter to be removed?
|
||||
-%>
|
||||
|
||||
<div class="pure-u-1-3 pure-u-md-1-5 filter-catagory" id="filter-<%= filter_name %>">
|
||||
|
@ -18,11 +19,14 @@
|
|||
<li class="pure-menu-item">
|
||||
|
||||
<% if operators.fetch(filter_name, selected_default) == filter %>
|
||||
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&#{filter_name}=[a-z]+/, "")}"%>">
|
||||
<% if allow_removal %>
|
||||
<a style="color: inherit;" href="<%= base_url + "#{filter_params.gsub(/&#{filter_name}=[a-z]+/, "")}"%>">
|
||||
<b><%= translate(locale, filter) %></b>
|
||||
<i class="remove-filter icon ion-md-close"></i>
|
||||
</a>
|
||||
<% else %>
|
||||
<b><%= translate(locale, filter) %></b>
|
||||
<i class="remove-filter icon ion-md-close"></i>
|
||||
</a>
|
||||
|
||||
<% end %>
|
||||
<% else %>
|
||||
<a href="<%= base_url + "#{filter_params.gsub(/&#{filter_name}=[a-z]+/, "")}&#{filter_name}=#{filter}"%>">
|
||||
<%= translate(locale, filter) %>
|
||||
|
|
|
@ -13,14 +13,18 @@
|
|||
<% filter_params = env.request.query_params.to_s.gsub(/q=.+?(?=&|$)/, "").gsub(/&page=\d+/, "") %>
|
||||
<% base_url = "/search?q=#{URI.encode_www_form(query.not_nil!)}" -%>
|
||||
|
||||
<%
|
||||
# Literally only needed for the sort_by column. So for the rest we'd just use these values:
|
||||
selected_default = "NotNeeded"
|
||||
allow_removal = true
|
||||
%>
|
||||
|
||||
<% filters = ["hour", "today", "week", "month", "year"] %>
|
||||
<% filter_name = "date" %>
|
||||
<% selected_default = "NotNeeded" %>
|
||||
<%= rendered "components/search-filters/filter-column" -%>
|
||||
|
||||
<% filters = ["video", "channel", "playlist", "movie", "show"] %>
|
||||
<% filter_name = "content_type" %>
|
||||
<% selected_default = "NotNeeded" %>
|
||||
<%= rendered "components/search-filters/filter-column" -%>
|
||||
|
||||
<% filters = ["short", "long"] %>
|
||||
|
@ -70,7 +74,12 @@
|
|||
|
||||
<% filters = ["relevance", "rating", "date", "views"] %>
|
||||
<% filter_name = "sort" %>
|
||||
<% selected_default = "relevance" %>
|
||||
<%
|
||||
# Literally only needed for the sort_by column. So for the rest we'd just use these values:
|
||||
selected_default = "relevance"
|
||||
allow_removal = false
|
||||
%>
|
||||
|
||||
<%= rendered "components/search-filters/filter-column" -%>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue