Skip to content

Commit

Permalink
Merge pull request #1387 from noesya/heading-level
Browse files Browse the repository at this point in the history
Niveau de titre du bloc
  • Loading branch information
arnaudlevy committed Nov 6, 2023
2 parents 6979b97 + 1c1dd05 commit 9c1a165
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/models/communication/block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Communication::Block < ApplicationRecord

IMAGE_MAX_SIZE = 5.megabytes
FILE_MAX_SIZE = 100.megabytes
DEFAULT_HEADING_LEVEL = 2 # h1 is the page title

belongs_to :about, polymorphic: true
belongs_to :heading, optional: true
Expand Down Expand Up @@ -152,6 +153,11 @@ def full_text
template.full_text
end

def heading_level
heading.present? ? heading.level + 1
: DEFAULT_HEADING_LEVEL
end

def to_s
title.blank? ? "#{Communication::Block.model_name.human} #{position}"
: "#{title}"
Expand Down
1 change: 1 addition & 0 deletions app/views/admin/communication/blocks/_static.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ should_render_data = block.data && block.data.present?
title: >-
<%= prepare_text_for_static block.title %>
position: <%= block.position %>
heading_level: <%= block.heading_level %>
data:
<%= render template_path,
block: block,
Expand Down

0 comments on commit 9c1a165

Please sign in to comment.