diff --git a/app/controllers/admin/communication/websites/pages_controller.rb b/app/controllers/admin/communication/websites/pages_controller.rb index b7c8e6a92b9c313266f33ed7f1a74eb749d8fce1..203ff4d27bb0921e38b8e0cdb96f270996323914 100644 --- a/app/controllers/admin/communication/websites/pages_controller.rb +++ b/app/controllers/admin/communication/websites/pages_controller.rb @@ -98,7 +98,7 @@ class Admin::Communication::Websites::PagesController < Admin::Communication::We params.require(:communication_website_page) .permit( :communication_website_id, :title, :breadcrumb_title, :bodyclass, - :description, :description_short, :header_text, :text, :slug, :published, + :description, :description_short, :header_text, :text, :slug, :published, :full_width, :featured_image, :featured_image_delete, :featured_image_infos, :featured_image_alt, :featured_image_credit, :parent_id, :language_id ) diff --git a/app/models/communication/website/page.rb b/app/models/communication/website/page.rb index 85c2006d56dd76368a4f13c530897f78ceea8c49..f819101e003f67aac4a042f700af6da025fce277 100644 --- a/app/models/communication/website/page.rb +++ b/app/models/communication/website/page.rb @@ -9,6 +9,7 @@ # description_short :text # featured_image_alt :string # featured_image_credit :text +# full_width :boolean default(FALSE) # github_path :text # header_text :text # kind :integer @@ -157,6 +158,11 @@ class Communication::Website::Page < ApplicationRecord page end + def full_width + kind_home? ? true + : attributes['full_width'] + end + def to_s "#{title}" end diff --git a/app/views/admin/communication/blocks/_list.html.erb b/app/views/admin/communication/blocks/_list.html.erb index 4f407759b07e695e229ca57b0b80b846bf9db95f..41505a23d876e2b21c81a6532459af7f865c381e 100644 --- a/app/views/admin/communication/blocks/_list.html.erb +++ b/app/views/admin/communication/blocks/_list.html.erb @@ -10,36 +10,44 @@ </h2> </div> <% if about.blocks.any? %> - <table class="<%= table_classes %>"> - <thead> - <tr> - <% if can? :reorder, Communication::Block %> - <th width="20" class="ps-0"> </th> - <% end %> - <th><%= Communication::Block.human_attribute_name('title') %></th> - <th><%= Communication::Block.human_attribute_name('template') %></th> - <th><%= t 'accessibility.label' %></th> - <th></th> - </tr> - </thead> - <tbody data-sortable data-sort-url="<%= reorder_admin_communication_blocks_path %>"> - <% about.blocks.ordered.each do |block| %> - <tr data-id="<%= block.id %>" class="<%= 'draft' unless block.published? %>"> + <div class="table-responsive"> + <table class="<%= table_classes %>"> + <thead> + <tr> <% if can? :reorder, Communication::Block %> - <td><i class="fa fa-bars handle"></i></td> + <th width="20" class="ps-0"> </th> <% end %> - <td><%= block.to_s.truncate(50) %></td> - <td><%= block.template_kind_i18n %></td> - <td><%= render 'admin/application/a11y/status', about: block %></td> - <td class="text-end"> - <div class="btn-group"> - <%= duplicate_link block %> - <%= edit_link block %> - </div> - </td> + <th><%= Communication::Block.model_name.human %></th> + <th></th> + <th><%= t 'accessibility.label' %></th> + <th></th> </tr> - <% end %> - </tbody> - </table> + </thead> + <tbody data-sortable data-sort-url="<%= reorder_admin_communication_blocks_path %>"> + <% about.blocks.ordered.each do |block| %> + <tr data-id="<%= block.id %>" class="<%= 'draft' unless block.published? %>"> + <% if can? :reorder, Communication::Block %> + <td><i class="fa fa-bars handle"></i></td> + <% end %> + <td> + <%= block.to_s.truncate(50) %><br> + <span class="small"><%= block.template_kind_i18n %></span> + </td> + <td class="p-0"> + <%= image_tag "communication/blocks/templates/#{block.template_kind}.jpg", + height: "100px", alt: '', style:"max-height: 50px" %> + </td> + <td><%= render 'admin/application/a11y/status', about: block %></td> + <td class="text-end"> + <div class="btn-group"> + <%= duplicate_link block %> + <%= edit_link block %> + </div> + </td> + </tr> + <% end %> + </tbody> + </table> + </div> <% end %> </div> diff --git a/app/views/admin/communication/websites/pages/_form.html.erb b/app/views/admin/communication/websites/pages/_form.html.erb index 51d19dd142fd3f2c735520fc98425d40f37e6767..129062b21f7ded4da8a2b441914e05fd76247ed6 100644 --- a/app/views/admin/communication/websites/pages/_form.html.erb +++ b/app/views/admin/communication/websites/pages/_form.html.erb @@ -51,6 +51,7 @@ label_method: ->(p) { sanitize p[:label] }, value_method: ->(p) { p[:id] } unless page.kind_home? %> <%= f.input :bodyclass if can?(:edit, @website) %> + <%= f.input :full_width %> </div> </div> <% else %> diff --git a/app/views/admin/communication/websites/pages/show.html.erb b/app/views/admin/communication/websites/pages/show.html.erb index 641abd9c4ab89471a2796dbaf00c701bba52a119..52d79983c0ecc325ac88aba50985168e9d9cd7d3 100644 --- a/app/views/admin/communication/websites/pages/show.html.erb +++ b/app/views/admin/communication/websites/pages/show.html.erb @@ -79,6 +79,9 @@ </p> <% end %> + <h3 class="h5"><%= Communication::Website::Page.human_attribute_name('full_width') %></h3> + <p><%= t @page.full_width %></p> + <% if @page.children.any? %> <h3 class="h5"><%= Communication::Website::Page.human_attribute_name('children') %></h3> <ul class="list-unstyled mb-0"> diff --git a/app/views/admin/communication/websites/pages/static.html.erb b/app/views/admin/communication/websites/pages/static.html.erb index 8812dd9cf9187dad7c1f1988842661a05b0d41ca..bfc2c810316c2a3365b2d924c73e0e83c2494cf4 100644 --- a/app/views/admin/communication/websites/pages/static.html.erb +++ b/app/views/admin/communication/websites/pages/static.html.erb @@ -4,6 +4,7 @@ title: > breadcrumb_title: "<%= @about.breadcrumb_title.blank? ? @about.title : @about.breadcrumb_title %>" url: "<%= @about.path %>" position: <%= @about.position %> +full_width: <%= @about.full_width %> bodyclass: <%= @about.best_bodyclass %> <%= render 'admin/communication/unsplash/static' %> <% if @about.children.published.any? %> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index b5e6644ce1d933ef78bfd483703c0b97b35371fe..bab76259a26ec516b5c5e9e36bd279400e0940e3 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -97,6 +97,7 @@ en: description_short: Lead text featured_image: Featured image featured_image_alt: Alt text + full_width: Full width header_text: Title displayed in header parent: Parent page published: Published? @@ -592,5 +593,6 @@ en: communication_website_page: breadcrumb_title: If the field is empty, page title will be used in breadcrumbs. description: If this field is empty, the "lead text" field will be used. If also emty the main text's begining will be used. + full_width: On large screens, a full width page uses all available space for the content. This is good for landing pages, or to make them spectacular. If the page is not full width, the content column will be smaller to make reading easier. The unused space might be used for a table of contents. communication_website_post: description: If this field is empty, the "lead text" field will be used. If also emty the main text's begining will be used. diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index 3360033356516d95a8acc9fff0f7976c3dbbdd97..d8f817729f56ff52a80ac1217bdb85385921d098 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -97,6 +97,7 @@ fr: description_short: Chapô featured_image: Image à la une featured_image_alt: Texte alternatif + full_width: Pleine largeur header_text: Titre affiché dans le header parent: Page parente published: Publié ? @@ -596,5 +597,6 @@ fr: communication_website_page: breadcrumb_title: Si ce champ est vide le titre de la page sera utilisé dans le fil d'Ariane. description: Si ce champ est vide le "chapô" sera utilisé. Si il est également vide le début du texte principal sera utilisé. + full_width: Sur de grands écrans, la page en pleine largeur utilisera tout l'espace disponible, ce qui est pertinent pour événementialiser une page. Si la page n'est pas en pleine largeur, l'espace dédié au contenu sera réduit pour faciliter la lecture, et l'espace libre pourra être utilisé pour une table des matières facilitant la navigation. communication_website_post: description: Si ce champ est vide le "chapô" sera utilisé. Si il est également vide le début du texte principal sera utilisé. diff --git a/db/migrate/20220722103657_add_full_width_to_communication_website_page.rb b/db/migrate/20220722103657_add_full_width_to_communication_website_page.rb new file mode 100644 index 0000000000000000000000000000000000000000..fe39e1f418e1746cb82328703a118dab65c559a6 --- /dev/null +++ b/db/migrate/20220722103657_add_full_width_to_communication_website_page.rb @@ -0,0 +1,5 @@ +class AddFullWidthToCommunicationWebsitePage < ActiveRecord::Migration[6.1] + def change + add_column :communication_website_pages, :full_width, :boolean, default: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 8ef9ad8ebf9fe4e9f57ee8a12456e8caea5cc19c..5bf91459823f0ccd00ef1d950ca51d75d29662c2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_07_04_164321) do +ActiveRecord::Schema.define(version: 2022_07_22_103657) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -310,6 +310,7 @@ ActiveRecord::Schema.define(version: 2022_07_04_164321) do t.string "bodyclass" t.uuid "language_id" t.text "featured_image_credit" + t.boolean "full_width", default: false t.index ["communication_website_id"], name: "index_communication_website_pages_on_communication_website_id" t.index ["language_id"], name: "index_communication_website_pages_on_language_id" t.index ["parent_id"], name: "index_communication_website_pages_on_parent_id"