Sha256: 4b788718258e51ab421757321479444d242cd74df5e2b4b9eac6a2e4ae15f88a

Contents?: true

Size: 772 Bytes

Versions: 25

Compression:

Stored size: 772 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Log
    module ValueTypes
      # This class presents the given value as a
      # Decidim::ParticipatoryProcessType. If the type can be found, it shows
      # its title. Otherwise it shows its ID.
      #
      # Returns an HTML-safe String
      class ParticipatoryProcessTypePresenter < Decidim::Log::ValueTypes::DefaultPresenter
        def present
          return unless value
          return h.translated_attribute(type.title) if type

          I18n.t("not_found", id: value, scope: "decidim.log.value_types.participatory_process_type_presenter")
        end

        private

        def type
          @type ||= Decidim::ParticipatoryProcessType.find_by(id: value)
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
decidim-participatory_processes-0.29.1 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.28.4 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.27.9 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.29.0 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.28.3 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.27.8 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.29.0.rc4 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.29.0.rc3 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.29.0.rc2 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.29.0.rc1 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.28.2 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.27.7 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.28.1 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.27.6 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.28.0 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.27.5 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.28.0.rc5 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.28.0.rc4 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.27.4 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb
decidim-participatory_processes-0.27.3 app/presenters/decidim/log/value_types/participatory_process_type_presenter.rb