From 72dc5dbba144b478b67f227ebe18d317d3b15fa5 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Fri, 17 Feb 2023 07:40:03 +0100
Subject: [PATCH] wip

---
 .../admin/application/_connections.html.erb   | 23 -------------------
 .../application/connections/_list.html.erb    | 12 ++++++++++
 .../application/connections/_source.html.erb  | 13 +++++++++++
 .../university/organizations/show.html.erb    |  2 +-
 4 files changed, 26 insertions(+), 24 deletions(-)
 delete mode 100644 app/views/admin/application/_connections.html.erb
 create mode 100644 app/views/admin/application/connections/_list.html.erb
 create mode 100644 app/views/admin/application/connections/_source.html.erb

diff --git a/app/views/admin/application/_connections.html.erb b/app/views/admin/application/_connections.html.erb
deleted file mode 100644
index d8bc0bbc2..000000000
--- a/app/views/admin/application/_connections.html.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-<%= osuny_panel Communication::Website::Connection.model_name.human(count: 2) do %>
-  <% about.websites.each do |website| %>
-    <div class="mb-4">
-      <p class="mb-0"><b><%= link_to website, [:admin, website] %></b></p>
-      <ul class="list-unstyled small">
-        <% Communication::Website::Connection.for_object(about).in_website(website).each do |connection| %>
-          <% 
-          source = connection.source
-          begin
-            path = url_for [:admin, source]                 
-          rescue
-          end
-          path = edit_admin_communication_block_path(source) if source.is_a?(Communication::Block)
-          path = admin_communication_website_page_path( website_id: website.id, 
-                                                        lang: website.default_language, 
-                                                        id: source) if source.is_special_page?
-          %>
-          <li><%= link_to_if path, source, path %></li>
-        <% end %>
-      </ul>
-    </tr>
-  <% end %>
-<% end if about.websites.any? %>
\ No newline at end of file
diff --git a/app/views/admin/application/connections/_list.html.erb b/app/views/admin/application/connections/_list.html.erb
new file mode 100644
index 000000000..fa6604e82
--- /dev/null
+++ b/app/views/admin/application/connections/_list.html.erb
@@ -0,0 +1,12 @@
+<%= osuny_panel Communication::Website::Connection.model_name.human(count: 2) do %>
+  <% about.websites.each do |website| %>
+    <div class="mb-4">
+      <p class="mb-0"><b><%= link_to website, [:admin, website] %></b></p>
+      <ul class="list-unstyled small">
+        <% Communication::Website::Connection.for_object(about).in_website(website).each do |connection| %>
+          <li><%= render  'admin/application/connections/source', connection: connection %></li>
+        <% end %>
+      </ul>
+    </tr>
+  <% end %>
+<% end if about.websites.any? %>
\ No newline at end of file
diff --git a/app/views/admin/application/connections/_source.html.erb b/app/views/admin/application/connections/_source.html.erb
new file mode 100644
index 000000000..6259885df
--- /dev/null
+++ b/app/views/admin/application/connections/_source.html.erb
@@ -0,0 +1,13 @@
+<% 
+source = connection.source
+website = connection.website
+begin
+  path = url_for [:admin, source]
+rescue
+end
+path = edit_admin_communication_block_path(source) if source.is_a?(Communication::Block)
+path = admin_communication_website_page_path( website_id: website.id, 
+                                              lang: website.default_language, 
+                                              id: source) if source.is_special_page?
+%>
+<%= link_to_if path, source, path %>
\ No newline at end of file
diff --git a/app/views/admin/university/organizations/show.html.erb b/app/views/admin/university/organizations/show.html.erb
index 52be2c05d..3bdbd88e6 100644
--- a/app/views/admin/university/organizations/show.html.erb
+++ b/app/views/admin/university/organizations/show.html.erb
@@ -88,7 +88,7 @@
 
     <%= render 'admin/application/meta_description/show', about: @organization %>
 
-    <%= render 'admin/application/connections', about: @organization %>
+    <%= render 'admin/application/connections/list', about: @organization %>
   </div>
 </div>
 
-- 
GitLab