Sha256: f4d1f570e889139ead7b5b82fbfadca1d3fb0ffd15f0ac917722a02199a01f20

Contents?: true

Size: 1.49 KB

Versions: 42

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

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

        def resource_presenter
          @resource_presenter ||= Decidim::Proposals::Log::ValuationAssignmentPresenter.new(action_log.resource, h, action_log.extra["resource"])
        end

        def diff_fields_mapping
          {
            valuator_role_id: "Decidim::Proposals::AdminLog::ValueTypes::ValuatorRoleUserPresenter"
          }
        end

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

        def i18n_labels_scope
          "activemodel.attributes.valuation_assignment.admin_log"
        end

        def diff_actions
          super + %w(create delete)
        end

        def i18n_params
          super.merge(proposal_title: h.translated_attribute(action_log.extra["proposal_title"]))
        end
      end
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
decidim-proposals-0.26.1 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.26.0 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.26.0.rc2 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.26.0.rc1 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.25.2 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.25.1 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.25.0 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.25.0.rc4 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.25.0.rc3 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.25.0.rc2 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.25.0.rc1 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.24.3 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.23.6 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.24.2 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.23.5 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.24.1 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.24.0 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.24.0.rc2 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.23.4 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb
decidim-proposals-0.24.0.rc1 app/presenters/decidim/proposals/admin_log/valuation_assignment_presenter.rb