Sha256: 4663fb9556c777bfddbd627ff460c0281c5a7754e7386ad130237cc8ad534ab3

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Decidim
  # The controller to show all the last activities in a Decidim Organization.
  class LastActivitiesController < Decidim::ApplicationController
    include FilterResource
    include Paginable

    helper Decidim::ResourceHelper
    helper Decidim::FiltersHelper

    helper_method :activities, :resource_types

    private

    def resource_types
      return @resource_types if defined?(@resource_types)

      @resource_types = ActionLog.public_resource_types.sort_by do |klass|
        klass.constantize.model_name.human
      end

      @resource_types = @resource_types.map do |klass|
        [klass, klass.constantize.model_name.human]
      end

      @resource_types << ["all", I18n.t("decidim.last_activities.all")]
    end

    def activities
      @activities ||= paginate(search.result)
    end

    def search_collection
      ActionLog
        .where(
          organization: current_organization,
          visibility: %w(public-only all)
        )
        .with_new_resource_type("all")
        .order(created_at: :desc)
    end

    def default_filter_params
      { with_resource_type: "all" }
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-core-0.27.3 app/controllers/decidim/last_activities_controller.rb
decidim-core-0.27.2 app/controllers/decidim/last_activities_controller.rb
decidim-core-0.27.1 app/controllers/decidim/last_activities_controller.rb