Sha256: 2d1e5d2d10ddf0b58f2cca7a4653022a31e5ecaacb9a213b2ed8f519d931ec95

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Decidim
  module Assemblies
    module AdminLog
      # This class holds the logic to present a `Decidim::AssembliesType`
      # 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
      #    AssembliesTypePresenter.new(action_log, view_helpers).present
      class AssembliesTypePresenter < Decidim::Log::BasePresenter
        private

        def diff_fields_mapping
          {
            title: :i18n
          }
        end

        def i18n_labels_scope
          "activemodel.attributes.assemblies_type"
        end

        def action_string
          case action
          when "create", "delete", "update"
            "decidim.admin_log.assembly_type.#{action}"
          else
            super
          end
        end

        def has_diff?
          action == "delete" || super
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
decidim-assemblies-0.23.1 app/presenters/decidim/assemblies/admin_log/assemblies_type_presenter.rb
decidim-assemblies-0.23.1.rc1 app/presenters/decidim/assemblies/admin_log/assemblies_type_presenter.rb
decidim-assemblies-0.23.0 app/presenters/decidim/assemblies/admin_log/assemblies_type_presenter.rb
decidim-assemblies-0.22.0 app/presenters/decidim/assemblies/admin_log/assemblies_type_presenter.rb
decidim-assemblies-0.21.0 app/presenters/decidim/assemblies/admin_log/assemblies_type_presenter.rb