Sha256: 5c866cbcc6f800fb067068346c2b803493438c5e3595dff13c6eee0c8172f51b

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

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

        def diff_fields_mapping
          {
            body: :string
          }
        end

        def i18n_params
          super.merge({
                        suggestion: suggestion_presenter.present
                      })
        end

        def suggestion_presenter
          Decidim::Log::ResourcePresenter.new(action_log.resource.suggestion, h, title: action_log.resource.suggestion)
        end

        def action_string
          case action
          when "create"
            "decidim.admin_log.suggestion_note.#{action}"
          else
            super
          end
        end

        def i18n_labels_scope
          "activemodel.attributes.suggestion_note"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-participatory_documents-0.2.2 app/presenters/decidim/participatory_documents/admin_log/suggestion_note_presenter.rb
decidim-participatory_documents-0.2.1 app/presenters/decidim/participatory_documents/admin_log/suggestion_note_presenter.rb
decidim-participatory_documents-0.2.0 app/presenters/decidim/participatory_documents/admin_log/suggestion_note_presenter.rb