Module: Controllers::ActivitiesTab

Extended by:
ActiveSupport::Concern
Included in:
ActivitiesController, CustomersController, OpportunitiesController, OrdersController, QuotesController
Defined in:
app/concerns/controllers/activities_tab.rb

Overview

Shared query logic for the "Activities" tab content rendered on
Quote / Order / Opportunity / Customer (and other) show pages and
inline-fetched by their respective tab_activities actions.

Inclusion gives the host controller a private
build_activities_tab_data helper that assigns the five instance
variables the activities/_index partial expects:

@context_object — the parent record (Quote/Order/...)
@activities — all_activities aggregator if defined,
else activities, in natural order
@activity_types_for_filter — collection for the filter dropdown
@selected_activity_id — id of the activity to scroll to, if any
(popped from params[:selected_activity]
— when present, ransack filters are
cleared so the selected record always
surfaces)
@q — Ransack search object
@pagy — Pagy::Pagy paginator

When params[:selected_activity] is supplied the helper computes the
page that contains that activity (using Activity.position_of_activity)
so the infinite-scroll list lands on it.

The infinite-scroll lazy-load frame at the bottom of the activities
partial keeps using polymorphic_path([@context_object, :activities], page: N, format: :turbo_stream) for subsequent pages — that path
routes to ActivitiesController#index, which still serves the
infinite-scroll stream. Only the initial tab load is taken over by
the per-parent tab_activities action.