From 69b316e7081259e2a714c83af26e949cb95744e7 Mon Sep 17 00:00:00 2001 From: syeopite Date: Wed, 27 Oct 2021 06:10:30 -0700 Subject: [PATCH] Disallow removing filters from sort by column --- .../components/search-filters/filter-column.ecr | 12 ++++++++---- .../components/search-filters/search-filters.ecr | 15 ++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/invidious/views/components/search-filters/filter-column.ecr b/src/invidious/views/components/search-filters/filter-column.ecr index 71a5015b..d8e99ebd 100644 --- a/src/invidious/views/components/search-filters/filter-column.ecr +++ b/src/invidious/views/components/search-filters/filter-column.ecr @@ -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? -%>
@@ -18,11 +19,14 @@
  • <% if operators.fetch(filter_name, selected_default) == filter %> - "> + <% if allow_removal %> + "> + <%= translate(locale, filter) %> + + + <% else %> <%= translate(locale, filter) %> - - - + <% end %> <% else %> "> <%= translate(locale, filter) %> diff --git a/src/invidious/views/components/search-filters/search-filters.ecr b/src/invidious/views/components/search-filters/search-filters.ecr index 2eb8b330..cd805f1e 100644 --- a/src/invidious/views/components/search-filters/search-filters.ecr +++ b/src/invidious/views/components/search-filters/search-filters.ecr @@ -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" -%>