Filters (<%= @filtered ? @active_filter[:name] || 'Custom' : 'None' %>)
- <% if @active_filter[:default] == true %>
+ <% if @active_filter[:default] == :user %>
You are currently filtering by <%= @active_filter[:name] %> because it is set as your default for this category
+ <% elsif @active_filter[:default] == :category and not user_signed_in? %>
+
+ You are currently filtering by <%= @active_filter[:name] %> because it is the default for this category
+
+ <% elsif @active_filter[:default] == :category and user_signed_in? %>
+
+ You are currently filtering by <%= @active_filter[:name] %> because it is the default for this category and you do not have a personal default set
+
<% end %>
<%= form_tag request.original_url, method: :get do %>
<%= render 'search/filters' %>
From a210c640d5e903f3e09338f0560d190aedc874ef Mon Sep 17 00:00:00 2001
From: Moshi <54333972+MoshiKoi@users.noreply.github.com>
Date: Mon, 26 Jun 2023 22:14:22 -0700
Subject: [PATCH 3/7] Add default filter setting to category edit page
---
app/controllers/categories_controller.rb | 2 +-
app/views/categories/_form.html.erb | 7 +++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
index 2511e8dda..30f809486 100644
--- a/app/controllers/categories_controller.rb
+++ b/app/controllers/categories_controller.rb
@@ -143,7 +143,7 @@ def category_params
params.require(:category).permit(:name, :short_wiki, :tag_set_id, :is_homepage, :min_trust_level, :button_text,
:color_code, :min_view_trust_level, :license_id, :sequence,
:asking_guidance_override, :answering_guidance_override,
- :use_for_hot_posts, :use_for_advertisement, :min_title_length, :min_body_length,
+ :use_for_hot_posts, :use_for_advertisement, :min_title_length, :min_body_length, :default_filter_id,
display_post_types: [], post_type_ids: [], required_tag_ids: [],
topic_tag_ids: [], moderator_tag_ids: [])
end
diff --git a/app/views/categories/_form.html.erb b/app/views/categories/_form.html.erb
index ac507654c..1fc59de60 100644
--- a/app/views/categories/_form.html.erb
+++ b/app/views/categories/_form.html.erb
@@ -145,6 +145,13 @@
<%= f.number_field :sequence, class: 'form-element' %>
+
+
+ <%= f.label :default_filter_id, class: 'form-element' %>
+ The default filter for this category, used for anonymous users.
+ <% system_filters = User.find(-1).filters.to_h { |filter| [filter.name, filter.id] } %>
+ <%= f.select :default_filter_id, options_for_select(system_filters, selected: @category.default_filter_id), { include_blank: true } %>
+