Sha256: 5291a8ac84b564d1c6f90c7006c659ba885ff1ad26f119749d87166a600fda59

Contents?: true

Size: 1.01 KB

Versions: 30

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Decidim
  module AdminLog
    # This class holds the logic to present a `Decidim::Component`
    # for the `AdminLog` log.
    #
    # Usage should be automatic and you shouldn't need to call this class
    # directly, but here's an example:
    #
    #    action_log = Decidim::ActionLog.last
    #    view_helpers # => this comes from the views
    #    ComponentPresenter.new(action_log, view_helpers).present
    class ComponentPresenter < Decidim::Log::BasePresenter
      private

      def diff_fields_mapping
        {
          name: :i18n,
          published_at: :date,
          weight: :integer
        }
      end

      def i18n_labels_scope
        "activemodel.attributes.component"
      end

      def action_string
        case action
        when "create", "delete", "publish", "unpublish"
          "decidim.admin_log.component.#{action}"
        else
          super
        end
      end

      def diff_actions
        super + %w(unpublish)
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
decidim-core-0.26.10 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.9 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.8 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.7 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.5 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.4 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.3 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.2 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.1 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.0 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.0.rc2 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.26.0.rc1 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.25.2 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.25.1 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.25.0 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.25.0.rc4 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.25.0.rc3 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.25.0.rc2 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.25.0.rc1 app/presenters/decidim/admin_log/component_presenter.rb
decidim-core-0.24.3 app/presenters/decidim/admin_log/component_presenter.rb