Class: Decidim::Admin::ContentBlockCell

Inherits:
ViewModel
  • Object
show all
Includes:
ContentBlocks::HasRelatedComponents
Defined in:
app/cells/decidim/admin/content_block_cell.rb

Instance Method Summary collapse

Instance Method Details

#componentObject



19
20
21
22
23
24
25
26
27
# File 'app/cells/decidim/admin/content_block_cell.rb', line 19

def component
  @component ||= if component_manifest_name.present?
                   components = components_for(model)
                   component_id = model.settings.try(:component_id)
                   components = components.where(id: component_id) if component_id.present?

                   components.first if components.one?
                 end
end

#content_block_pathObject



15
16
17
# File 'app/cells/decidim/admin/content_block_cell.rb', line 15

def content_block_path
  raise "#{self.class.name} is expected to implement #content_block_path"
end

#edit_content_block_pathObject



11
12
13
# File 'app/cells/decidim/admin/content_block_cell.rb', line 11

def edit_content_block_path
  raise "#{self.class.name} is expected to implement #edit_content_block_path"
end

#nameObject



29
30
31
32
33
# File 'app/cells/decidim/admin/content_block_cell.rb', line 29

def name
  return I18n.t(public_name_key) if component.blank?

  "#{I18n.t(public_name_key)} (#{decidim_escape_translated(component&.name)})"
end