Sha256: 89f3f0fbe77364daccba69e3c786d6bcc8901abab23e8e4cabc1dff3299d4f3f

Contents?: true

Size: 966 Bytes

Versions: 3

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module Comments
    # A cell to display when a comment has been created.
    class CommentActivityCell < ActivityCell
      delegate :root_commentable, to: :comment

      def renderable?
        comment.present? && root_commentable.present?
      end

      def resource_link_text
        comment.formatted_body
      end

      def resource_link_path
        resource_locator(root_commentable).path(url_params)
      end

      def title
        I18n.t(
          "decidim.comments.last_activity.new_comment_at_html",
          link: link_to(
            translated_attribute(root_commentable.title),
            resource_locator(root_commentable).path
          )
        )
      end

      def participatory_space
        model.participatory_space_lazy
      end

      def comment
        model.resource_lazy
      end

      def url_params
        { anchor: "comment_#{comment.id}" }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-comments-0.16.1 app/cells/decidim/comments/comment_activity_cell.rb
decidim-comments-0.17.0 app/cells/decidim/comments/comment_activity_cell.rb
decidim-comments-0.16.0 app/cells/decidim/comments/comment_activity_cell.rb