diff --git a/app/models/communication/block/template.rb b/app/models/communication/block/template.rb index 91e27ae02ceada809a5c642cc26b997401305980..a8653c9dfc374ab9621f5e6a8fd63faf0e7b6ad5 100644 --- a/app/models/communication/block/template.rb +++ b/app/models/communication/block/template.rb @@ -12,7 +12,7 @@ class Communication::Block::Template protected def data - block.data + block.data || {} end def university diff --git a/app/views/admin/communication/blocks/_static.html.erb b/app/views/admin/communication/blocks/_static.html.erb index 7f8e7a416c1c33a4f247eee4cbfbf53f6956724d..da263b2fe176342b6133fa255a7b53a1cea0fed7 100644 --- a/app/views/admin/communication/blocks/_static.html.erb +++ b/app/views/admin/communication/blocks/_static.html.erb @@ -4,5 +4,6 @@ blocks: - template: <%= block.template %> position: <%= block.position %> data: -<%= render "admin/communication/blocks/templates/#{block.template}/static", block: block if block.data %><% end %> +<%= render "admin/communication/blocks/templates/#{block.template}/static", + block: block if block.data && block.data.present? %><% end %> <% end %> diff --git a/app/views/admin/communication/blocks/templates/gallery/_show.html.erb b/app/views/admin/communication/blocks/templates/gallery/_show.html.erb index 6043b61ce4e72859ee15e7157526e79981e099d5..420ed90b378baa55d58c47c29751f98e82f45e65 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_show.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_show.html.erb @@ -1,16 +1,18 @@ -<h2><%= @block.data['title'] %></h2> -<div class="row"> -<% @block.data['elements'].each do |image| %> - <div class="col-xxl-2 col-xl-3 col-6"> - <article class="card"> - <% unless image.dig('file', 'id').blank? %> - <% blob = ActiveStorage::Blob.find(image.dig('file', 'id')) %> - <%= kamifusen_tag blob, width: 500, class: 'img-fluid mb-2' %> - <% end %> - <div class="card-body"> - <p class="mb-0"><%= image['alt'] %></p> - </div> - </article> - </div> +<% if @block.data %> + <h2><%= @block.data['title'] %></h2> + <div class="row"> + <% @block.data['elements'].each do |image| %> + <div class="col-xxl-2 col-xl-3 col-6"> + <article class="card"> + <% unless image.dig('file', 'id').blank? %> + <% blob = ActiveStorage::Blob.find(image.dig('file', 'id')) %> + <%= kamifusen_tag blob, width: 500, class: 'img-fluid mb-2' %> + <% end %> + <div class="card-body"> + <p class="mb-0"><%= image['alt'] %></p> + </div> + </article> + </div> + <% end %> + </div> <% end %> -</div> diff --git a/app/views/admin/communication/blocks/templates/gallery/_static.html.erb b/app/views/admin/communication/blocks/templates/gallery/_static.html.erb index d9b7f93e2ef7623deb6113f4660aafb50d6c1ea9..49ebec44b59f9fa3ffe0aa46fb9486c5983821ec 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_static.html.erb @@ -1,7 +1,7 @@ -<% if !block.data.nil? && !block.data.is_a?(String) && block.data.has_key?('elements') %> title: > <%= prepare_text_for_static block.data['title'] %> images: +<% if block.data.has_key?('elements') %> <% block.data['elements'].each do |image| file_id = nil if image.has_key?('file') diff --git a/app/views/admin/communication/blocks/templates/organization_chart/_show.html.erb b/app/views/admin/communication/blocks/templates/organization_chart/_show.html.erb index cdee4815fe8d177247ade7796fa5e4472e3edf6d..b2fe5da0693322051f44ddf9531677f1036b44dd 100644 --- a/app/views/admin/communication/blocks/templates/organization_chart/_show.html.erb +++ b/app/views/admin/communication/blocks/templates/organization_chart/_show.html.erb @@ -16,4 +16,4 @@ </div> <% end %> </div> -<% end %> +<% end if @block.data %> diff --git a/app/views/admin/communication/blocks/templates/organization_chart/_static.html.erb b/app/views/admin/communication/blocks/templates/organization_chart/_static.html.erb index d9a5b0442b0ac546b2f7c8ca5cd8b0ea2c75ea4e..f2694c15ff23129b4fc3d12e1f715165dc571e96 100644 --- a/app/views/admin/communication/blocks/templates/organization_chart/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/organization_chart/_static.html.erb @@ -1,4 +1,4 @@ -<% if !block.data.nil? && !block.data.is_a?(String) && block.data.has_key?('elements') %> +<% if block.data.has_key?('elements') %> <% block.data['elements'].each do |element| %> - title: > <%= prepare_text_for_static element['title'] %> diff --git a/app/views/admin/communication/blocks/templates/partners/_show.html.erb b/app/views/admin/communication/blocks/templates/partners/_show.html.erb index 22a91333e3f70a264a33e2b9c43ce868d5b6130f..463abb31d28a5f474a1209b2a65d3ce62cb16c6f 100644 --- a/app/views/admin/communication/blocks/templates/partners/_show.html.erb +++ b/app/views/admin/communication/blocks/templates/partners/_show.html.erb @@ -16,4 +16,4 @@ </div> <% end %> </div> -<% end %> +<% end if @block.data %> diff --git a/app/views/admin/communication/blocks/templates/partners/_static.html.erb b/app/views/admin/communication/blocks/templates/partners/_static.html.erb index fd0bf2c78cd1aaab93504ac5c4be06e0af9b6154..90043893cd7bee4e2e054c0fbe84b9544ce0279f 100644 --- a/app/views/admin/communication/blocks/templates/partners/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/partners/_static.html.erb @@ -1,4 +1,4 @@ -<% if !block.data.nil? && !block.data.is_a?(String) && block.data.has_key?('elements') %> +<% if block.data.has_key?('elements') %> <% block.data['elements'].each do |element| %> - title: > <%= element['title'] %>