Sha256: 8e7ffd468a9e07f6654c4b459f95f24725946c4a8348b6e03abfbddedb9993bc

Contents?: true

Size: 1.3 KB

Versions: 33

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

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

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

        def diff_fields_mapping
          {
            cancel_reason: :i18n,
            dice: :integer,
            request_timestamp: :date,
            witnesses: :i18n,
            additional_info: :i18n,
            title: :i18n,
            reference: :string,
            decidim_proposals_component_id: :component
          }
        end

        def i18n_labels_scope
          "activemodel.attributes.sortition"
        end

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

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
decidim-sortitions-0.23.1 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.23.1.rc1 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.23.0 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.22.0 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.21.0 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.20.1 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.20.0 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.19.1 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.18.1 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.19.0 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.17.2 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.18.0 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.17.1 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.16.1 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.17.0 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.16.0 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.15.2 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.15.1 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.15.0 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb
decidim-sortitions-0.14.4 app/presenters/decidim/sortitions/admin_log/sortition_presenter.rb