diff --git a/app/controllers/account/settings_controller.rb b/app/controllers/account/settings_controller.rb index 585e87400..6b08abba2 100644 --- a/app/controllers/account/settings_controller.rb +++ b/app/controllers/account/settings_controller.rb @@ -1,6 +1,4 @@ class Account::SettingsController < ApplicationController - include FilterScoped - def show @account = Account.sole @users = User.active.alphabetically diff --git a/app/controllers/cards_controller.rb b/app/controllers/cards_controller.rb index 526806879..9a0d5d19c 100644 --- a/app/controllers/cards_controller.rb +++ b/app/controllers/cards_controller.rb @@ -6,8 +6,6 @@ class CardsController < ApplicationController before_action :set_collection, only: %i[ create ] before_action :set_card, only: %i[ show edit update destroy ] - enable_collection_filtering only: :index - PAGE_SIZE = 25 def index diff --git a/app/controllers/collections/columns/closeds_controller.rb b/app/controllers/collections/columns/closeds_controller.rb index 30d2cd2c7..2ffd7c253 100644 --- a/app/controllers/collections/columns/closeds_controller.rb +++ b/app/controllers/collections/columns/closeds_controller.rb @@ -1,5 +1,5 @@ class Collections::Columns::ClosedsController < ApplicationController - include CollectionScoped, FilterScoped + include CollectionScoped def show set_page_and_extract_portion_from @collection.cards.closed.recently_closed_first diff --git a/app/controllers/collections/columns/not_nows_controller.rb b/app/controllers/collections/columns/not_nows_controller.rb index b5a311a57..8b6b233b6 100644 --- a/app/controllers/collections/columns/not_nows_controller.rb +++ b/app/controllers/collections/columns/not_nows_controller.rb @@ -1,5 +1,5 @@ class Collections::Columns::NotNowsController < ApplicationController - include CollectionScoped, FilterScoped + include CollectionScoped def show set_page_and_extract_portion_from @collection.cards.postponed.reverse_chronologically.with_golden_first diff --git a/app/controllers/collections/columns/streams_controller.rb b/app/controllers/collections/columns/streams_controller.rb index cc1fc2f67..16a2bf671 100644 --- a/app/controllers/collections/columns/streams_controller.rb +++ b/app/controllers/collections/columns/streams_controller.rb @@ -1,5 +1,5 @@ class Collections::Columns::StreamsController < ApplicationController - include CollectionScoped, FilterScoped + include CollectionScoped def show set_page_and_extract_portion_from @collection.cards.awaiting_triage.reverse_chronologically.with_golden_first diff --git a/app/controllers/collections/columns_controller.rb b/app/controllers/collections/columns_controller.rb index 6210a9556..41ab1a56a 100644 --- a/app/controllers/collections/columns_controller.rb +++ b/app/controllers/collections/columns_controller.rb @@ -1,5 +1,5 @@ class Collections::ColumnsController < ApplicationController - include ActionView::RecordIdentifier, CollectionScoped, FilterScoped + include ActionView::RecordIdentifier, CollectionScoped before_action :set_column, only: [ :show, :update, :destroy ] diff --git a/app/controllers/concerns/filter_scoped.rb b/app/controllers/concerns/filter_scoped.rb index 2c422be2a..a9341f604 100644 --- a/app/controllers/concerns/filter_scoped.rb +++ b/app/controllers/concerns/filter_scoped.rb @@ -6,12 +6,6 @@ module FilterScoped before_action :set_user_filtering end - class_methods do - def enable_collection_filtering(**options) - before_action :enable_collection_filtering, **options - end - end - private def set_filter if params[:filter_id].present? @@ -32,24 +26,4 @@ module FilterScoped def expanded_param ActiveRecord::Type::Boolean.new.cast(params[:expand_all]) end - - def enable_collection_filtering - # We pass a block so that we don't have to pass around the script_name and host - # to the model to make +url_for+ invocable - @user_filtering.enable_collection_filtering do |**options| - url_for(options) - end - end - - def enable_referral_collection_filtering - @user_filtering.enable_collection_filtering do |**options| - if request.referer.present? - uri = URI.parse(request.referer) - uri.query = Rack::Utils.build_query(options) - uri.to_s - else - url_for(options) - end - end - end end diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 744a7f925..5b52b02fa 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -1,8 +1,6 @@ class EventsController < ApplicationController include DayTimelinesScoped - enable_collection_filtering only: :index - def index fresh_when @day_timeline end diff --git a/app/controllers/my/menus_controller.rb b/app/controllers/my/menus_controller.rb index 1a8316957..a81705df3 100644 --- a/app/controllers/my/menus_controller.rb +++ b/app/controllers/my/menus_controller.rb @@ -1,14 +1,7 @@ class My::MenusController < ApplicationController include FilterScoped - before_action :enable_referral_collection_filtering, if: :collection_filtering_enabled? - def show fresh_when @user_filtering end - - private - def collection_filtering_enabled? - params[:enable_collection_filtering].present? - end end diff --git a/app/controllers/notifications/settings_controller.rb b/app/controllers/notifications/settings_controller.rb index 4323ed3c8..42608b558 100644 --- a/app/controllers/notifications/settings_controller.rb +++ b/app/controllers/notifications/settings_controller.rb @@ -1,5 +1,4 @@ class Notifications::SettingsController < ApplicationController - include FilterScoped before_action :set_settings def show diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 41446b2fb..d188e3a1e 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -1,6 +1,4 @@ class NotificationsController < ApplicationController - include FilterScoped - def index @unread = Current.user.notifications.unread.ordered unless current_page_param set_page_and_extract_portion_from Current.user.notifications.read.ordered diff --git a/app/controllers/webhooks_controller.rb b/app/controllers/webhooks_controller.rb index fceb37c5c..8f8315186 100644 --- a/app/controllers/webhooks_controller.rb +++ b/app/controllers/webhooks_controller.rb @@ -1,6 +1,4 @@ class WebhooksController < ApplicationController - include FilterScoped - before_action :ensure_can_administer before_action :set_collection before_action :set_webhook, except: %i[ index new create ] diff --git a/app/models/user/filtering.rb b/app/models/user/filtering.rb index 6e00ecbc1..c9f049ab3 100644 --- a/app/models/user/filtering.rb +++ b/app/models/user/filtering.rb @@ -71,28 +71,12 @@ class User::Filtering filter.collections.any? end - def enable_collection_filtering(&block) - @collection_filtering_route_resolver = block - end - - def self_filter_path(...) - if supports_collection_filtering? - @collection_filtering_route_resolver.call(...) - else - cards_path(...) - end - end - def single_collection_or_first # Default to the first selected or, when no selection, to the first one filter.collections.first || collections.first end def cache_key - ActiveSupport::Cache.expand_cache_key([ user, filter, expanded?, collections, tags, users, filters, supports_collection_filtering? ], "user-filtering") - end - - def supports_collection_filtering? - @collection_filtering_route_resolver.present? + ActiveSupport::Cache.expand_cache_key([ user, filter, expanded?, collections, tags, users, filters ], "user-filtering") end end diff --git a/app/views/account/settings/show.html.erb b/app/views/account/settings/show.html.erb index 72bca26cb..732c49abc 100644 --- a/app/views/account/settings/show.html.erb +++ b/app/views/account/settings/show.html.erb @@ -1,7 +1,7 @@ <% @page_title = "Account Settings" %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %>

<%= @page_title %>

<% end %> diff --git a/app/views/cards/index.html.erb b/app/views/cards/index.html.erb index 47d15dcb8..99121d028 100644 --- a/app/views/cards/index.html.erb +++ b/app/views/cards/index.html.erb @@ -10,7 +10,7 @@ <% end %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %>

<%= @user_filtering.selected_collections_label %> diff --git a/app/views/cards/show.html.erb b/app/views/cards/show.html.erb index 9b35b9b1e..36371cbb1 100644 --- a/app/views/cards/show.html.erb +++ b/app/views/cards/show.html.erb @@ -10,7 +10,7 @@ <% end %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %> <%= link_to collection_url(@card.collection), class: "header__title btn borderless txt-large", style: "--btn-padding: 0.25ch 1ch 0.25ch 0.75ch; view-transistion-name: card-collection-title;", diff --git a/app/views/collections/columns/closeds/show.html.erb b/app/views/collections/columns/closeds/show.html.erb index 9e6c16b73..a30152ac7 100644 --- a/app/views/collections/columns/closeds/show.html.erb +++ b/app/views/collections/columns/closeds/show.html.erb @@ -1,7 +1,7 @@ <% @page_title = "Column: Closed" %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %>
<%= link_to @collection, class: "btn borderless txt-medium", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %> diff --git a/app/views/collections/columns/not_nows/show.html.erb b/app/views/collections/columns/not_nows/show.html.erb index 506d164cf..b9e0cfba2 100644 --- a/app/views/collections/columns/not_nows/show.html.erb +++ b/app/views/collections/columns/not_nows/show.html.erb @@ -1,7 +1,7 @@ <% @page_title = "Column: Now now" %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %>
<%= link_to @collection, class: "btn borderless txt-medium", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %> diff --git a/app/views/collections/columns/show.html.erb b/app/views/collections/columns/show.html.erb index 709c5221e..39090bdd0 100644 --- a/app/views/collections/columns/show.html.erb +++ b/app/views/collections/columns/show.html.erb @@ -1,7 +1,7 @@ <% @page_title = "Column: #{ @column.name }" %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %>
<%= link_to @column.collection, class: "btn borderless txt-medium", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %> diff --git a/app/views/collections/columns/streams/show.html.erb b/app/views/collections/columns/streams/show.html.erb index 0758168a5..f56aeb048 100644 --- a/app/views/collections/columns/streams/show.html.erb +++ b/app/views/collections/columns/streams/show.html.erb @@ -1,7 +1,7 @@ <% @page_title = "Column: The Stream" %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %>
<%= link_to @collection, class: "btn borderless txt-medium", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %> diff --git a/app/views/collections/edit.html.erb b/app/views/collections/edit.html.erb index f565cc972..df0d6dc79 100644 --- a/app/views/collections/edit.html.erb +++ b/app/views/collections/edit.html.erb @@ -1,7 +1,7 @@ <% @page_title = "Collection Settings" %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %>
<%= link_to @collection, class: "btn borderless txt-medium", data: { controller: "hotkey", action: "keydown.esc@document->hotkey#click" } do %> diff --git a/app/views/collections/new.html.erb b/app/views/collections/new.html.erb index 39ca1937f..ba9f1151f 100644 --- a/app/views/collections/new.html.erb +++ b/app/views/collections/new.html.erb @@ -1,7 +1,7 @@ <% @page_title = "Create a new collection" %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %> <% end %>
diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb index 96392f1d2..c89e70976 100644 --- a/app/views/collections/show.html.erb +++ b/app/views/collections/show.html.erb @@ -10,7 +10,7 @@ <% end %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %>
<%= render "cards/webhooks", collection: @collection if Current.user.admin? %> diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index 8acc92214..d6a777d40 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -4,7 +4,7 @@ <%= render "filters/broadcasts", filter: @filter %> <% content_for :header do %> - <%= render "filters/menu", user_filtering: @user_filtering %> + <%= render "filters/menu" %> <%= render "events/index/add_card_button", user_filtering: @user_filtering %>

diff --git a/app/views/filters/_menu.html.erb b/app/views/filters/_menu.html.erb index a117bdfa7..ae4a3443b 100644 --- a/app/views/filters/_menu.html.erb +++ b/app/views/filters/_menu.html.erb @@ -8,6 +8,6 @@ dialog_target: "dialog", navigable_list_focus_on_selection_value: false, navigable_list_actionable_items_value: true } do %> - <%= turbo_frame_tag "my_menu", src: my_menu_path(enable_collection_filtering: user_filtering.supports_collection_filtering?, **user_filtering.filter.as_params), target: "_top" %> + <%= turbo_frame_tag "my_menu", src: my_menu_path, target: "_top" %> <% end %> diff --git a/app/views/filters/menu/_collections.html.erb b/app/views/filters/menu/_collections.html.erb index c9298093e..f6dfad1ec 100644 --- a/app/views/filters/menu/_collections.html.erb +++ b/app/views/filters/menu/_collections.html.erb @@ -1,10 +1,7 @@ <% # Using method: :get inside Turbo frame triggers some special Turbo handling where the script_name is lost %> -<%= form_with url: user_filtering.self_filter_path(script_name: Account.sole.slug), method: :get, class: "display-contents", - data: { controller: "form" } do |form| %> - <% if user_filtering.collections.any? %> - <%= collapsible_nav_section "Collections" do %> - <%= render "filters/menu/collections/all_option", form: form, user_filtering: user_filtering %> - <%= render partial: "filters/menu/collections/collection", collection: user_filtering.collections, as: :collection, locals: { form: form, user_filtering: user_filtering } %> - <% end %> +<% if user_filtering.collections.any? %> + <%= collapsible_nav_section "Collections" do %> + <%= render "filters/menu/collections/all_option", user_filtering: user_filtering %> + <%= render partial: "filters/menu/collections/collection", collection: user_filtering.collections, as: :collection %> <% end %> <% end %> diff --git a/app/views/filters/menu/collections/_all_option.html.erb b/app/views/filters/menu/collections/_all_option.html.erb index 8ee95a795..e5a682b9b 100644 --- a/app/views/filters/menu/collections/_all_option.html.erb +++ b/app/views/filters/menu/collections/_all_option.html.erb @@ -1,5 +1,3 @@ -<% clear_url_path = user_filtering.self_filter_path(user_filtering.as_params.except(:collection_ids), script_name: request.script_name) %> - <% if Current.user.collections.many? %>