From 1809a516379b82e6d554fd2c994b7663cae67825 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Thu, 22 Jun 2023 12:02:37 +0200
Subject: [PATCH] =?UTF-8?q?plus=20l=C3=A9ger?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../admin/application/i18n/_inline.html.erb      | 16 ++++++++++++++++
 .../communication/websites/pages/show.html.erb   |  1 -
 .../websites/pages/show/_metadata.html.erb       |  3 +++
 .../communication/websites/posts/show.html.erb   |  1 -
 .../websites/posts/show/_metadata.html.erb       |  5 +++++
 5 files changed, 24 insertions(+), 2 deletions(-)
 create mode 100644 app/views/admin/application/i18n/_inline.html.erb

diff --git a/app/views/admin/application/i18n/_inline.html.erb b/app/views/admin/application/i18n/_inline.html.erb
new file mode 100644
index 000000000..48e55bd86
--- /dev/null
+++ b/app/views/admin/application/i18n/_inline.html.erb
@@ -0,0 +1,16 @@
+<% if about.available_languages.many? %>
+  <br>en <%= t(about.language.iso_code, scope: :languages) %>
+
+  <%
+    route_args = about.is_direct_object?  ? [:admin, about.becomes(about.class.base_class)]
+                                          : [:show_in_language, :admin, about.becomes(about.class.base_class)]
+  %>
+  <%
+    links = about.available_languages.map { |language|
+      next if language.id == about.language_id
+      link_to t(language.iso_code, scope: :languages).downcase, 
+                [*route_args, lang: language.iso_code]
+    }.compact
+  %>
+  <br>(basculer en <%= links.to_sentence.html_safe %>)
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/communication/websites/pages/show.html.erb b/app/views/admin/communication/websites/pages/show.html.erb
index 42b782e8b..ecd640809 100644
--- a/app/views/admin/communication/websites/pages/show.html.erb
+++ b/app/views/admin/communication/websites/pages/show.html.erb
@@ -17,7 +17,6 @@
   <div class="row">
     <div class="col-lg-4">
       <%= render 'admin/communication/websites/pages/show/metadata' %>
-      <%= render 'admin/application/i18n/widget', about: @page, small: true %>
     </div>
     <div class="col-lg-8">
       <%= render 'admin/application/summary/show', about: @page, small: true %>
diff --git a/app/views/admin/communication/websites/pages/show/_metadata.html.erb b/app/views/admin/communication/websites/pages/show/_metadata.html.erb
index d5f2b1bd2..0f5873871 100644
--- a/app/views/admin/communication/websites/pages/show/_metadata.html.erb
+++ b/app/views/admin/communication/websites/pages/show/_metadata.html.erb
@@ -12,6 +12,8 @@
 
   <%= @page.published ? 'Publiée' : 'Brouillon' %>
 
+  <%= render 'admin/application/i18n/inline', about: @page %>
+
   <% if @page.parent %>
     <br>
     Dans
@@ -40,3 +42,4 @@
     Pleine largeur
   <% end %>
 <% end %>
+
diff --git a/app/views/admin/communication/websites/posts/show.html.erb b/app/views/admin/communication/websites/posts/show.html.erb
index 1b25802e6..9ba6dc7ad 100644
--- a/app/views/admin/communication/websites/posts/show.html.erb
+++ b/app/views/admin/communication/websites/posts/show.html.erb
@@ -17,7 +17,6 @@
   <div class="row">
     <div class="col-lg-4">
       <%= render 'admin/communication/websites/posts/show/metadata' %>
-      <%= render 'admin/application/i18n/widget', about: @post, small: true %>
     </div>
     <div class="col-lg-8">
       <%= render 'admin/application/summary/show', about: @post, small: true %>
diff --git a/app/views/admin/communication/websites/posts/show/_metadata.html.erb b/app/views/admin/communication/websites/posts/show/_metadata.html.erb
index 66d79126d..f1ea4e5c5 100644
--- a/app/views/admin/communication/websites/posts/show/_metadata.html.erb
+++ b/app/views/admin/communication/websites/posts/show/_metadata.html.erb
@@ -4,6 +4,7 @@
 %>
 <div class="mb-4">
   <%= osuny_label t('metadata') %><br>
+
   <% if @post.published %>
     Publié le <%= l @post.published_at.to_date %>
     <% if @post.pinned %>
@@ -12,10 +13,14 @@
   <% else %>
     Brouillon
   <% end %>
+
   <% if @post.author %>
     <br>par <%= @post.author %>
   <% end %>
+
   <% if @post.categories.any? %>
     <br>dans <%= @post.categories.collect(&:to_s).join(', ') %>
   <% end %>
+
+  <%= render 'admin/application/i18n/inline', about: @post %>
 </div>
\ No newline at end of file
-- 
GitLab