Sha256: 4e149ab2d74d4c88f2af167b6b0e0fbfc6a86597744e598500d1000e08bf7535

Contents?: true

Size: 1.44 KB

Versions: 3

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

module Decidim
  module ParticipatoryDocuments
    class SuggestionAnswerEvent < Decidim::Events::SimpleEvent
      include Decidim::Events::AuthorEvent

      def resource_path
        @resource_path ||= if resource.suggestable.is_a?(Decidim::ParticipatoryDocuments::Document)
                             main_component_path(resource.suggestable.component)
                           else
                             main_component_path(resource.suggestable.document.component)
                           end
      end

      def resource_url
        @resource_url ||= if resource.suggestable.is_a?(Decidim::ParticipatoryDocuments::Document)
                            main_component_url(resource.suggestable.component)
                          else
                            main_component_url(resource.suggestable.document.component)
                          end
      end

      def resource_title
        title ||= if resource.suggestable.is_a?(Decidim::ParticipatoryDocuments::Document)
                    translated_attribute(resource.suggestable.title)
                  else
                    translated_attribute(resource.suggestable.document.title)
                  end

        Decidim::ContentProcessor.render_without_format(title, links: false).html_safe
      end

      def event_has_roles?
        true
      end

      def resource_text
        translated_attribute(resource.answer)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-participatory_documents-0.2.2 app/events/decidim/participatory_documents/suggestion_answer_event.rb
decidim-participatory_documents-0.2.1 app/events/decidim/participatory_documents/suggestion_answer_event.rb
decidim-participatory_documents-0.2.0 app/events/decidim/participatory_documents/suggestion_answer_event.rb