Sha256: 6821f139ac6cb80bbaee79a45e1d394a904cfdf86f2da594384ff2b28f8b49cf

Contents?: true

Size: 961 Bytes

Versions: 4

Compression:

Stored size: 961 Bytes

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
      render :show
    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

4 entries across 4 versions & 1 rubygems

Version Path
decidim-core-0.28.1 app/cells/decidim/notification_cell.rb
decidim-core-0.28.0 app/cells/decidim/notification_cell.rb
decidim-core-0.28.0.rc5 app/cells/decidim/notification_cell.rb
decidim-core-0.28.0.rc4 app/cells/decidim/notification_cell.rb