Sha256: ebd7f77a37bb808ebd2f3eaa1de02ef4690d03da46fe61b0f0756d17b99c2d72

Contents?: true

Size: 1.51 KB

Versions: 14

Compression:

Stored size: 1.51 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 resource_presenter
          @resource_presenter ||= Decidim::Proposals::Log::ResourcePresenter.new(action_log.resource, h, action_log.extra["resource"])
        end

        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", "update"
            "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

14 entries across 14 versions & 1 rubygems

Version Path
decidim-proposals-0.20.1 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.20.0 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.19.1 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.18.1 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.19.0 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.17.2 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.18.0 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.17.1 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.16.1 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.17.0 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.16.0 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.15.2 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.15.1 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb
decidim-proposals-0.15.0 app/presenters/decidim/proposals/admin_log/proposal_presenter.rb