Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Niveau de titre du bloc #1387

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading