Sha256: 2a5cb39bdb0cebe4dbee15f955778da4d29a5b62aec07562fcf73f91dbfc2d8a

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

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

        def diff_fields_mapping
          {
            title: "Decidim::Proposals::AdminLog::ValueTypes::ProposalTitleBodyPresenter",
            body: "Decidim::Proposals::AdminLog::ValueTypes::ProposalTitleBodyPresenter",
            state: "Decidim::Proposals::AdminLog::ValueTypes::ProposalStatePresenter",
            answered_at: :date,
            answer: :i18n
          }
        end

        def action_string
          case action
          when "answer", "create"
            "decidim.proposals.admin_log.proposal.#{action}"
          else
            super
          end
        end

        def i18n_labels_scope
          "activemodel.attributes.proposal"
        end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-proposals-0.14.4 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.14.3 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.14.2 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.14.1 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb