From 7398c92a23eb501b22ec150ba32e39b81683652d Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Mon, 24 Jul 2023 12:01:52 +0200 Subject: [PATCH] better --- .../admin/commons/content-editor.sass | 3 + .../communication/blocks/_block.html.erb | 2 +- .../blocks/content/_editor.html.erb | 66 ++++++++++--------- .../_heading-for-mode-structure.html.erb | 20 ++++++ .../blocks/headings/_heading.html.erb | 9 +-- .../contents/_structure.html.erb | 2 +- config/locales/communication/en.yml | 6 ++ config/locales/communication/fr.yml | 6 ++ config/locales/en.yml | 1 + config/locales/fr.yml | 1 + 10 files changed, 78 insertions(+), 38 deletions(-) create mode 100644 app/views/admin/communication/blocks/headings/_heading-for-mode-structure.html.erb diff --git a/app/assets/stylesheets/admin/commons/content-editor.sass b/app/assets/stylesheets/admin/commons/content-editor.sass index 09439c2c5..a9cc2e2f3 100644 --- a/app/assets/stylesheets/admin/commons/content-editor.sass +++ b/app/assets/stylesheets/admin/commons/content-editor.sass @@ -9,6 +9,9 @@ &.sortable-chosen .content-editor__elements display: none + &--mode-structure + .content-editor__elements__handle + cursor: move &--hover opacity: 0 transition: opacity 0.25s ease diff --git a/app/views/admin/communication/blocks/_block.html.erb b/app/views/admin/communication/blocks/_block.html.erb index f85fe076b..dfd640583 100644 --- a/app/views/admin/communication/blocks/_block.html.erb +++ b/app/views/admin/communication/blocks/_block.html.erb @@ -19,7 +19,7 @@ <span class=" content-editor__elements__handle content-editor__elements__element--hover"> <span class="handle"> - <span class="small"><%= t 'organize' %></span> + <span class="small"><%= t 'move' %></span> <i class="<%= Icon::SORT %>"></i> </span> </span> diff --git a/app/views/admin/communication/blocks/content/_editor.html.erb b/app/views/admin/communication/blocks/content/_editor.html.erb index 9e72a7a03..b05d9befd 100644 --- a/app/views/admin/communication/blocks/content/_editor.html.erb +++ b/app/views/admin/communication/blocks/content/_editor.html.erb @@ -3,35 +3,37 @@ mode_expert = about.headings.many? %> <div class="js-content-editor mb-5" data-sort-blocks-url="<%= reorder_admin_communication_blocks_path(lang: nil, website_id: nil, extranet_id: nil) %>" - data-sort-headings-url="<%= reorder_admin_communication_headings_path(lang: nil, website_id: nil, extranet_id: nil) %>"> - + data-sort-headings-url="<%= reorder_admin_communication_headings_path(lang: nil, website_id: nil, extranet_id: nil) %>" + data-mode-write="<%= admin_communication_contents_write_path(about_type: about.class.polymorphic_name, about_id: about.id) %>" + data-mode-structure="<%= admin_communication_contents_structure_path(about_type: about.class.polymorphic_name, about_id: about.id) %>" + > <% if mode_expert %> - <ul class="nav nav-tabs justify-content-md-end"> - <li class="nav-item small"> - <a class="nav-link active" - id="mode-write-tab" - data-bs-toggle="tab" - data-bs-target="#mode-write" - type="button" - role="tab" - aria-controls="mode-write" - aria-selected="true"> - Écrire le contenu - </a> - </li> - <li class="nav-item small"> - <a class="nav-link" - id="mode-structure-tab" - data-bs-toggle="tab" - data-bs-target="#mode-structure" - type="button" - role="tab" - aria-controls="mode-structure" - aria-selected="false"> - Organiser le plan - </a> - </li> - </ul> + <ul class="nav nav-tabs justify-content-md-end"> + <li class="nav-item small"> + <a class="nav-link active" + id="mode-write-tab" + data-bs-toggle="tab" + data-bs-target="#mode-write" + type="button" + role="tab" + aria-controls="mode-write" + aria-selected="true"> + Écrire le contenu + </a> + </li> + <li class="nav-item small"> + <a class="nav-link" + id="mode-structure-tab" + data-bs-toggle="tab" + data-bs-target="#mode-structure" + type="button" + role="tab" + aria-controls="mode-structure" + aria-selected="false"> + Organiser le plan + </a> + </li> + </ul> <% end %> <div class="tab-content"> <div class="tab-pane fade show active" @@ -46,7 +48,9 @@ mode_expert = about.headings.many? </div> </div> <% end %> - <%= render 'admin/communication/contents/write', about: about %> + <div class="inner"> + <%= render 'admin/communication/contents/write', about: about %> + </div> </div> <div class="tab-pane fade" id="mode-structure" @@ -58,7 +62,9 @@ mode_expert = about.headings.many? <p class="text-lg-end text-muted small mt-2">Dans le mode "Organiser le plan", vous ne voyez pas les blocs mais seulement les titres. Lorsque vous déplacez un titre, tous les blocs suivent. C'est le mode idéal pour ranger les documents longs.</p> </div> </div> - <%= render 'admin/communication/contents/structure', about: about %> + <div class="inner"> + <%= render 'admin/communication/contents/structure', about: about %> + </div> </div> </div> diff --git a/app/views/admin/communication/blocks/headings/_heading-for-mode-structure.html.erb b/app/views/admin/communication/blocks/headings/_heading-for-mode-structure.html.erb new file mode 100644 index 000000000..029ab25ed --- /dev/null +++ b/app/views/admin/communication/blocks/headings/_heading-for-mode-structure.html.erb @@ -0,0 +1,20 @@ +<div class=" content-editor__elements__element + content-editor__elements__element--heading + content-editor__elements__element--mode-structure + js-content-editor-element + mt-3" + data-id="<%= heading.id %>" + data-level="<%= heading.level %>" + data-kind="heading"> + <div class="content-editor__elements__handle" + style="padding-left: <%= (heading.level - Communication::Block::Heading::DEFAULT_LEVEL) * 48 %>px"> + <span class="h4"><%= heading %></span> + <i class="<%= Icon::SORT %>"></i> + <p class="small text-muted"> + <%= t('admin.communication.contents.blocks.quantity', count: heading.blocks.count) %> + </p> + </div> +</div> +<% heading.children.ordered.each do |child| %> + <%= render 'admin/communication/blocks/headings/heading', heading: child %> +<% end %> diff --git a/app/views/admin/communication/blocks/headings/_heading.html.erb b/app/views/admin/communication/blocks/headings/_heading.html.erb index 0f9758677..26822180e 100644 --- a/app/views/admin/communication/blocks/headings/_heading.html.erb +++ b/app/views/admin/communication/blocks/headings/_heading.html.erb @@ -1,6 +1,3 @@ -<% -hide_blocks ||= false -%> <div class=" content-editor__elements__element content-editor__elements__element--heading js-content-editor-element @@ -12,12 +9,12 @@ hide_blocks ||= false <span class="h4"><%= heading %></span> <%= link_to t('edit'), edit_admin_communication_heading_path(heading), - class: 'action ms-2' %> + class: 'action ms-2'%> <% if can?(:update, heading) %> <span class=" content-editor__elements__handle content-editor__elements__element--hover"> <span class="handle"> - <span class="small"><%= t 'organize' %></span> + <span class="small"><%= t 'move' %></span> <i class="<%= Icon::SORT %>"></i> </span> </span> @@ -26,7 +23,7 @@ hide_blocks ||= false </div> <% heading.blocks.ordered.each do |block| %> <%= render 'admin/communication/blocks/block', block: block %> -<% end unless hide_blocks %> +<% end %> <% heading.children.ordered.each do |child| %> <%= render 'admin/communication/blocks/headings/heading', heading: child %> <% end %> diff --git a/app/views/admin/communication/contents/_structure.html.erb b/app/views/admin/communication/contents/_structure.html.erb index 6a7beb1f8..e60d2a42e 100644 --- a/app/views/admin/communication/contents/_structure.html.erb +++ b/app/views/admin/communication/contents/_structure.html.erb @@ -2,6 +2,6 @@ content-editor--organize js-content-editor-sortable-container"> <% about.headings.root.ordered.each do |heading| %> - <%= render 'admin/communication/blocks/headings/heading', heading: heading, hide_blocks: true %> + <%= render 'admin/communication/blocks/headings/heading-for-mode-structure', heading: heading %> <% end %> </div> diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml index 5dffae2be..40b9b4a22 100644 --- a/config/locales/communication/en.yml +++ b/config/locales/communication/en.yml @@ -666,6 +666,12 @@ en: video_title: label: Video title placeholder: Enter video title + contents: + blocks: + quantity: + zero: No block + one: 1 block + other: "%{count} blocks" website: pages: as_list: See as a list diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml index cd68c04b0..f4d9918f1 100644 --- a/config/locales/communication/fr.yml +++ b/config/locales/communication/fr.yml @@ -663,6 +663,12 @@ fr: video_title: label: Titre de la vidéo placeholder: Entrer le titre de la vidéo + contents: + blocks: + quantity: + zero: Aucun bloc + one: 1 bloc + other: "%{count} blocs" website: pages: as_list: Voir en liste diff --git a/config/locales/en.yml b/config/locales/en.yml index df0d2e155..fc5648c67 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -276,6 +276,7 @@ en: server_admin: Admin server sign_out: Log out metadata: Metadata + move: Move open: Open organize: Organize please_confirm: Are you sure? diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b46a68883..c7e4dc9de 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -276,6 +276,7 @@ fr: server_admin: Admin serveur sign_out: Déconnexion metadata: Informations + move: Déplacer open: Ouvrir organize: Organiser please_confirm: Est-ce que vous confirmez ? -- GitLab