Skip to content
Snippets Groups Projects
Unverified Commit d4a185e1 authored by Pierre-André Boissinot's avatar Pierre-André Boissinot Committed by GitHub
Browse files

Limit available blocks templates in extranets (#2700)

parent bb8702d5
No related branches found
No related tags found
No related merge requests found
Showing
with 66 additions and 4 deletions
......@@ -11,6 +11,10 @@ class Communication::Block::Template::CallToAction < Communication::Block::Templ
has_component :alt, :string
has_component :credit, :rich_text
def allowed_for_about?
!about.respond_to?(:extranet)
end
def top_description
text
end
......
......@@ -57,4 +57,9 @@ class Communication::Block::Template::Contact < Communication::Block::Template::
def has_socials?
socials.any?(&:present?)
end
def allowed_for_about?
!about.respond_to?(:extranet)
end
end
......@@ -6,6 +6,10 @@ class Communication::Block::Template::Datatable < Communication::Block::Template
has_component :columns, :array
has_component :description, :rich_text
def allowed_for_about?
!about.respond_to?(:extranet)
end
def elements
if alphabetical
@elements.sort_by! do |element|
......
......@@ -3,4 +3,8 @@ class Communication::Block::Template::Definition < Communication::Block::Templat
has_elements
has_component :description, :rich_text
def allowed_for_about?
!about.respond_to?(:extranet)
end
end
......@@ -3,6 +3,9 @@ class Communication::Block::Template::Feature < Communication::Block::Template::
has_elements
has_component :description, :rich_text
def allowed_for_about?
!about.respond_to?(:extranet)
end
def children
elements
......
......@@ -3,4 +3,8 @@ class Communication::Block::Template::KeyFigure < Communication::Block::Template
has_elements
has_component :description, :rich_text
def allowed_for_about?
!about.respond_to?(:extranet)
end
end
......@@ -7,4 +7,8 @@ class Communication::Block::Template::License < Communication::Block::Template::
has_component :creative_commons_derivatives, :option, options: [:true, :false]
has_component :creative_commons_sharing, :option, options: [:true, :false]
def allowed_for_about?
!about.respond_to?(:extranet)
end
end
......@@ -3,4 +3,8 @@ class Communication::Block::Template::Link < Communication::Block::Template::Bas
has_elements
has_component :description, :rich_text
def allowed_for_about?
!about.respond_to?(:extranet)
end
end
\ No newline at end of file
......@@ -14,6 +14,10 @@ class Communication::Block::Template::Organization < Communication::Block::Templ
has_component :option_logo, :boolean, default: true
has_component :option_summary, :boolean, default: false
def allowed_for_about?
!about.respond_to?(:extranet)
end
def elements
if alphabetical
@elements.sort_by! do |element|
......
......@@ -19,6 +19,10 @@ class Communication::Block::Template::Person < Communication::Block::Template::B
has_component :option_link, :boolean, default: true
has_component :option_contact, :boolean, default: false
def allowed_for_about?
!about.respond_to?(:extranet)
end
def elements
if alphabetical
@elements.sort_by! do |element|
......
......@@ -4,6 +4,10 @@ class Communication::Block::Template::Sound < Communication::Block::Template::Ba
has_component :title, :string
has_component :transcription, :rich_text
def allowed_for_about?
!about.respond_to?(:extranet)
end
protected
def check_accessibility
......
......@@ -2,6 +2,10 @@ class Communication::Block::Template::Testimonial < Communication::Block::Templa
has_elements
def allowed_for_about?
!about.respond_to?(:extranet)
end
def top_screen_reader_only
true
end
......
......@@ -3,6 +3,10 @@ class Communication::Block::Template::Timeline < Communication::Block::Template:
has_elements
has_layouts [:vertical, :horizontal]
def allowed_for_about?
!about.respond_to?(:extranet)
end
def children
elements
end
......
<% content_for :title, t('admin.communication.blocks.choose.title') %>
<% Communication::Block::CATEGORIES.each do |category, kinds| %>
<%
selected_kinds = []
kinds.each do |kind|
@block.template_reset!
@block.template_kind = kind
about = @block.about
template = @block.template
next unless template.allowed_for_about?
selected_kinds << kind
end
next unless selected_kinds.any?
%>
<section class="blocks">
<p class="float-end blocks__category__description"><%= t "admin.communication.blocks.categories.#{category}.description" %></p>
<h2 class="h3 category blocks__category__title"><%= t "admin.communication.blocks.categories.#{category}.label" %></h2>
<div class="row">
<% kinds.each do |kind| %>
<% selected_kinds.each do |kind| %>
<%
@block.template_reset!
@block.template_kind = kind
about = @block.about
template = @block.template
%>
<% next unless template.allowed_for_about? %>
<div class="col-xxl-2 col-lg-3 col-sm-4 col-6 d-flex mb-5">
<div class="flex-fill position-relative js-validate-form-click">
<%= image_tag "communication/blocks/templates/#{kind}.jpg", alt: '', class:"card-img-top block__image" %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment