From 8862dce5ba6545659523c110b71f0b9c2c732e73 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Fri, 28 Apr 2023 14:49:37 +0200 Subject: [PATCH] list --- .../application/connections/_list.html.erb | 23 +++++++++++++++---- .../connections/_direct_source.html.erb | 16 +++++++++++++ .../connections/_indirect_object.html.erb | 10 ++++++++ .../websites/connections/_list.html.erb | 23 ++++--------------- .../university/organizations/show.html.erb | 4 ++-- .../admin/university/people/show.html.erb | 2 ++ 6 files changed, 52 insertions(+), 26 deletions(-) create mode 100644 app/views/admin/communication/websites/connections/_direct_source.html.erb create mode 100644 app/views/admin/communication/websites/connections/_indirect_object.html.erb diff --git a/app/views/admin/application/connections/_list.html.erb b/app/views/admin/application/connections/_list.html.erb index bcf496e4b..699fbf3d5 100644 --- a/app/views/admin/application/connections/_list.html.erb +++ b/app/views/admin/application/connections/_list.html.erb @@ -1,7 +1,20 @@ <%= osuny_panel Communication::Website::Connection.model_name.human(count: 2) do %> - <ul class="list-unstyled"> - <% about.websites.each do |website| %> - <li><%= link_to website, [:admin, website] %></li> - <% end %> - </ul> + <table class="table"> + <thead> + <tr> + <th><%= Communication::Website.model_name.human %></th> + <th><%= Communication::Website::Connection.human_attribute_name('direct_source_type') %></th> + <th><%= Communication::Website::Connection.human_attribute_name('direct_source') %></th> + </tr> + </thead> + <tbody> + <% about.connections.each do |connection| %> + <tr> + <td><%= link_to connection.website, [:admin, connection.website] %></td> + <td><%= connection.direct_source_type %><%= connection.direct_source_type.constantize.model_name.human unless connection.direct_source_type.nil? %></td> + <td><%= render 'admin/communication/websites/connections/direct_source', connection: connection %></td> + </tr> + <% end %> + </tbody> + </table> <% end if about.websites.any? %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/connections/_direct_source.html.erb b/app/views/admin/communication/websites/connections/_direct_source.html.erb new file mode 100644 index 000000000..4b51b14a6 --- /dev/null +++ b/app/views/admin/communication/websites/connections/_direct_source.html.erb @@ -0,0 +1,16 @@ +<% +source = connection.direct_source +source_name = source.to_s +begin + case connection.direct_source_type + when 'Communication::Website::Page' + source_link = admin_communication_website_page_path(website_id: source.website.id, id: source.id, lang: current_language) + when 'Communication::Website::Post' + source_link = admin_communication_website_post_path(website_id: source.website.id, id: source.id, lang: current_language) + else + source_link = url_for [:admin, source] + end +rescue +end +%> +<%= link_to_if source_link, source_name, source_link %> diff --git a/app/views/admin/communication/websites/connections/_indirect_object.html.erb b/app/views/admin/communication/websites/connections/_indirect_object.html.erb new file mode 100644 index 000000000..8c4794ce5 --- /dev/null +++ b/app/views/admin/communication/websites/connections/_indirect_object.html.erb @@ -0,0 +1,10 @@ +<% +object = connection.indirect_object +object_name = object.to_s +object_name = object.id if object.is_a?(ActiveStorage::Blob) +begin + object_link = url_for [:admin, object] +rescue +end +%> +<%= link_to_if object_link, object_name, object_link %> \ No newline at end of file diff --git a/app/views/admin/communication/websites/connections/_list.html.erb b/app/views/admin/communication/websites/connections/_list.html.erb index db0b18e6a..98006e373 100644 --- a/app/views/admin/communication/websites/connections/_list.html.erb +++ b/app/views/admin/communication/websites/connections/_list.html.erb @@ -10,30 +10,15 @@ </thead> <tbody> <% connections.each do |connection| %> - <% - object = connection.indirect_object - object_name = object.to_s - object_name = object.id if object.is_a?(ActiveStorage::Blob) - begin - object_link = url_for [:admin, object] - rescue - end - source = connection.direct_source - source_name = source.to_s - begin - source_link = url_for [:admin, source] - rescue - end - %> <tr> <td><%= link_to connection, [:admin, connection] %></td> <td> - <%= link_to_if object_link, object_name, object_link %><br> - <span class="small"><%= connection.indirect_object_type %></span> + <%= render 'admin/communication/websites/connections/indirect_object', connection: connection %> + <br><span class="small"><%= connection.indirect_object_type %></span> </td> <td> - <%= link_to_if source_link, source_name, source_link %><br> - <span class="small"><%= connection.direct_source_type %></span> + <%= render 'admin/communication/websites/connections/direct_source', connection: connection %> + <br><span class="small"><%= connection.direct_source_type %></span> </td> <td><%= l connection.updated_at %></td> </tr> diff --git a/app/views/admin/university/organizations/show.html.erb b/app/views/admin/university/organizations/show.html.erb index dccb51446..ad1e87d7b 100644 --- a/app/views/admin/university/organizations/show.html.erb +++ b/app/views/admin/university/organizations/show.html.erb @@ -82,6 +82,8 @@ <% end %> <%= render 'admin/communication/blocks/list', about: @organization %> + + <%= render 'admin/application/connections/list', about: @organization %> </div> <div class="col-md-4"> @@ -118,8 +120,6 @@ <% end if @organization.logo.attached? || @organization.logo_on_dark_background.attached? %> <%= render 'admin/application/meta_description/show', about: @organization %> - - <%= render 'admin/application/connections/list', about: @organization %> </div> </div> diff --git a/app/views/admin/university/people/show.html.erb b/app/views/admin/university/people/show.html.erb index 485f258b5..6ed908096 100644 --- a/app/views/admin/university/people/show.html.erb +++ b/app/views/admin/university/people/show.html.erb @@ -31,6 +31,8 @@ action += link_to t('university.manage_experiences'), <%= render 'admin/university/people/experiences/list', experiences: @person.experiences.ordered %> <% end %> +<%= render 'admin/application/connections/list', about: @person %> + <% content_for :action_bar_left do %> <%= destroy_link @person %> <%= static_link static_admin_university_person_path(@person) %> -- GitLab