Class: Decidim::NotificationCell

Inherits:
ViewModel
  • Object
show all
Defined in:
app/cells/decidim/notification_cell.rb

Overview

This cell renders a notification from a notifications collection

Direct Known Subclasses

Decidim::NotificationActions::BaseCell

Instance Method Summary collapse

Instance Method Details

#action_cellObject



41
42
43
# File 'app/cells/decidim/notification_cell.rb', line 41

def action_cell
  @action_cell ||= (notification.event_class_instance.action_cell if action_class&.safe_constantize)
end

#action_classObject



37
38
39
# File 'app/cells/decidim/notification_cell.rb', line 37

def action_class
  @action ||= ("#{notification.event_class_instance.action_cell.camelize}Cell" if notification.event_class_instance.action_cell)
end

#notification_titleObject



21
22
23
24
25
# File 'app/cells/decidim/notification_cell.rb', line 21

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


27
28
29
30
31
32
33
34
35
# File 'app/cells/decidim/notification_cell.rb', line 27

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

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

#showObject



9
10
11
12
13
14
15
16
17
18
19
# File 'app/cells/decidim/notification_cell.rb', line 9

def show
  if !notification.can_participate?(current_user)
    render :not_available
  elsif notification.deleted_resource?
    render :deleted
  elsif notification.hidden_resource?
    render :moderated
  else
    render :show
  end
end