From b3ee4408ec5db3b687f26f16e354ab7df358afdf Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Thu, 16 Nov 2023 14:19:52 +0100 Subject: [PATCH] Fix #1423 --- app/models/communication/block/template/base.rb | 4 ++++ app/models/communication/block/template/page.rb | 5 +++++ app/models/communication/block/with_heading_ranks.rb | 4 ++-- app/views/admin/communication/blocks/_static.html.erb | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/communication/block/template/base.rb b/app/models/communication/block/template/base.rb index 8bc0ed6b9..396c61b43 100644 --- a/app/models/communication/block/template/base.rb +++ b/app/models/communication/block/template/base.rb @@ -145,6 +145,10 @@ class Communication::Block::Template::Base false end + def heading_title + block.title + end + def to_s self.class.to_s.demodulize end diff --git a/app/models/communication/block/template/page.rb b/app/models/communication/block/template/page.rb index 16a94047e..2d3285619 100644 --- a/app/models/communication/block/template/page.rb +++ b/app/models/communication/block/template/page.rb @@ -29,6 +29,11 @@ class Communication::Block::Template::Page < Communication::Block::Template::Bas selected_pages end + def heading_title + block.title.present? ? block.title + : page&.title + end + protected def selected_pages_selection diff --git a/app/models/communication/block/with_heading_ranks.rb b/app/models/communication/block/with_heading_ranks.rb index 33ea91848..da97b3919 100644 --- a/app/models/communication/block/with_heading_ranks.rb +++ b/app/models/communication/block/with_heading_ranks.rb @@ -4,8 +4,8 @@ module Communication::Block::WithHeadingRanks DEFAULT_HEADING_LEVEL = 2 # h1 is the page title def heading_rank_self - title.present? ? heading_rank_base - : false + template.heading_title.present? ? heading_rank_base + : false end def heading_rank_children diff --git a/app/views/admin/communication/blocks/_static.html.erb b/app/views/admin/communication/blocks/_static.html.erb index e0c2d9d88..65a4e0bde 100644 --- a/app/views/admin/communication/blocks/_static.html.erb +++ b/app/views/admin/communication/blocks/_static.html.erb @@ -5,7 +5,7 @@ should_render_data = block.data && block.data.present? - kind: block template: <%= block.template_kind %> title: >- - <%= prepare_text_for_static block.title %> + <%= prepare_text_for_static block.template.heading_title %> position: <%= block.position %> ranks: self: <%= block.heading_rank_self %> -- GitLab