Sha256: d6e7189fffc95d8aa702c799719f04d1f56fa95d2a162f2c0df56e9200b820c1

Contents?: true

Size: 992 Bytes

Versions: 24

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Accountability
    module AdminLog
      module ValueTypes
        # This class presents the given value as a Decidim::Accountability::Result. Check
        # the `DefaultPresenter` for more info on how value presenters work.
        class ParentPresenter < Decidim::Log::ValueTypes::DefaultPresenter
          # Public: Presents the value as a Decidim::Accountability::Result. If the result can
          # be found, it shows its title. Otherwise it shows its ID.
          #
          # Returns an HTML-safe String.
          def present
            return unless value
            return h.translated_attribute(result.title) if result
            I18n.t("not_found", id: value, scope: "decidim.accountability.admin_log.value_types.parent_presenter")
          end

          private

          def result
            @result ||= Decidim::Accountability::Result.find_by(id: value)
          end
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
decidim-accountability-0.18.1 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.17.2 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.18.0 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.17.1 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.16.1 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.17.0 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.16.0 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.15.2 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.15.1 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.15.0 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.14.4 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.14.3 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.14.2 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.14.1 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.13.1 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.12.2 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.13.0 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.12.1 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.13.0.pre1 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb
decidim-accountability-0.12.0 app/presenters/decidim/accountability/admin_log/value_types/parent_presenter.rb