Sha256: af025da3a341168cc3e22516a296252d8a9c9cc45f1423bb1819148a76c43436

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Decidim
  # This cell renders a notification from a notifications collection

  class NotificationCell < Decidim::ViewModel
    include Decidim::IconHelper
    include Decidim::Core::Engine.routes.url_helpers
    include Decidim::SanitizeHelper

    def show
      if notification.event_class_instance.try(:hidden_resource?)
        render :moderated
      else
        render :show
      end
    end

    def notification_title
      notification.event_class_instance.notification_title
    rescue StandardError
      I18n.t("decidim.notifications.show.missing_event")
    end

    def participatory_space_link
      return unless notification.resource.respond_to?(:participatory_space)

      participatory_space = notification.resource.participatory_space
      link_to(
        decidim_html_escape(translated_attribute(participatory_space.title)),
        resource_locator(participatory_space).path
      )
    end

    private

    def notification
      @notification ||= Decidim::NotificationPresenter.new(model)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-core-0.28.4 app/cells/decidim/notification_cell.rb
decidim-core-0.28.3 app/cells/decidim/notification_cell.rb
decidim-core-0.28.2 app/cells/decidim/notification_cell.rb