Sha256: 5c9a597d31da6c1e7b6a26ab46730c9c28bc3205cdf94b0cdfeea9c8c0a745e5

Contents?: true

Size: 1.03 KB

Versions: 8

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Decidim
  module Votings
    module AdminLog
      # This class holds the logic to present a `Decidim::Votings::Voting`
      # for the `AdminLog` log.
      #
      # Usage should be automatic and you should not need to call this class
      # directly, but here is an example:
      #
      #    action_log = Decidim::ActionLog.last
      #    view_helpers # => this comes from the views
      #    BallotStylePresenter.new(action_log, view_helpers).present
      class BallotStylePresenter < Decidim::Log::BasePresenter
        private

        def i18n_params
          super.merge(
            ballot_style_code: ballot_style_code.to_s
          )
        end

        def ballot_style_code
          action_log&.resource&.code || action_log.extra["code"]
        end

        def action_string
          case action
          when "create", "delete", "update"
            "decidim.votings.admin_log.ballot_style.#{action}"
          else
            super
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decidim-elections-0.28.5 app/presenters/decidim/votings/admin_log/ballot_style_presenter.rb
decidim-elections-0.28.4 app/presenters/decidim/votings/admin_log/ballot_style_presenter.rb
decidim-elections-0.28.3 app/presenters/decidim/votings/admin_log/ballot_style_presenter.rb
decidim-elections-0.28.2 app/presenters/decidim/votings/admin_log/ballot_style_presenter.rb
decidim-elections-0.28.1 app/presenters/decidim/votings/admin_log/ballot_style_presenter.rb
decidim-elections-0.28.0 app/presenters/decidim/votings/admin_log/ballot_style_presenter.rb
decidim-elections-0.28.0.rc5 app/presenters/decidim/votings/admin_log/ballot_style_presenter.rb
decidim-elections-0.28.0.rc4 app/presenters/decidim/votings/admin_log/ballot_style_presenter.rb