Sha256: 4bafe1a0609cc8fd441e283693cc6bf7f1bbc6c1790fc2cfddf3d779ce385ec8

Contents?: true

Size: 1.69 KB

Versions: 5

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

require "decidim/core"

module Decidim
  module Accountability
    # This is the engine that runs on the public interface of `decidim-accountability`.
    # It mostly handles rendering the created results associated to a participatory
    # process.
    class Engine < ::Rails::Engine
      isolate_namespace Decidim::Accountability

      routes do
        resources :results, only: [:index, :show] do
          resources :versions, only: [:show, :index]
        end
        root to: "results#home"
      end

      initializer "decidim_accountability.view_hooks" do
        Decidim.view_hooks.register(:participatory_space_highlighted_elements, priority: Decidim::ViewHooks::LOW_PRIORITY) do |view_context|
          view_context.cell("decidim/accountability/highlighted_results", view_context.current_participatory_space)
        end
      end

      initializer "decidim_accountability.add_cells_view_paths" do
        Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Accountability::Engine.root}/app/cells")
        Cell::ViewModel.view_paths << File.expand_path("#{Decidim::Accountability::Engine.root}/app/views")
      end

      initializer "decidim_accountability.register_metrics" do
        Decidim.metrics_registry.register(:results) do |metric_registry|
          metric_registry.manager_class = "Decidim::Accountability::Metrics::ResultsMetricManage"

          metric_registry.settings do |settings|
            settings.attribute :highlighted, type: :boolean, default: false
            settings.attribute :scopes, type: :array, default: %w(home)
            settings.attribute :weight, type: :integer, default: 4
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-accountability-0.25.0 lib/decidim/accountability/engine.rb
decidim-accountability-0.25.0.rc4 lib/decidim/accountability/engine.rb
decidim-accountability-0.25.0.rc3 lib/decidim/accountability/engine.rb
decidim-accountability-0.25.0.rc2 lib/decidim/accountability/engine.rb
decidim-accountability-0.25.0.rc1 lib/decidim/accountability/engine.rb