Sha256: 736e9ae6900825a30fc5af92647895fd618637c8d633fb2b01c88c1a5938a1a6

Contents?: true

Size: 1.11 KB

Versions: 4

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Decidim
  module Proposals
    module PublishProposalEventOverride
      extend ActiveSupport::Concern

      included do
        def i18n_options
          return super if author.blank?

          author_path = link_to("@#{author.nickname}", profile_path(author.nickname))
          author_string = "#{author.name} #{author_path}"
          super.merge({ author: author_string })
          resource_admin_url ||= Decidim::ResourceLocatorPresenter.new(resource).admin_url
          resource_admin_path = link_to(I18n.t(".admin_panel", scope: i18n_scope), resource_admin_url)

          super.merge({ author: author_string, admin_url: resource_admin_path })
        end

        private

        def i18n_scope
          return super unless participatory_space_event?

          @i18n_scope ||= if extra[:type].to_s == "admin"
                            "decidim.events.proposals.proposal_published_for_admin"
                          else
                            "decidim.events.proposals.proposal_published_for_space"
                          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
decidim-reporting_proposals-0.5.2 app/events/concerns/decidim/proposals/publish_proposal_event_override.rb
decidim-reporting_proposals-0.5.1 app/events/concerns/decidim/proposals/publish_proposal_event_override.rb
decidim-reporting_proposals-0.5.0 app/events/concerns/decidim/proposals/publish_proposal_event_override.rb
decidim-reporting_proposals-0.4.2 app/events/concerns/decidim/proposals/publish_proposal_event_override.rb