From e594713121baa9d3c507b000847651458b2fa433 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Thu, 6 Jan 2022 15:35:39 +0100
Subject: [PATCH] better

---
 .../education/program/teachers/_form.html.erb | 18 +++---
 .../admin/education/programs/show.html.erb    | 64 ++++++++++---------
 2 files changed, 43 insertions(+), 39 deletions(-)

diff --git a/app/views/admin/education/program/teachers/_form.html.erb b/app/views/admin/education/program/teachers/_form.html.erb
index d15ac9831..e8c8b9067 100644
--- a/app/views/admin/education/program/teachers/_form.html.erb
+++ b/app/views/admin/education/program/teachers/_form.html.erb
@@ -1,14 +1,16 @@
 <%= simple_form_for [:admin, teacher] do |f| %>
-  <div class="row">
-    <div class="col-md-8">
-      <div class="card flex-fill w-100">
-        <div class="card-header">
-          <h5 class="card-title mb-0"><%= t('admin.infos') %></h5>
-        </div>
-        <div class="card-body">
+  <div class="card flex-fill w-100">
+    <div class="card-header">
+      <h5 class="card-title mb-0"><%= t('admin.infos') %></h5>
+    </div>
+    <div class="card-body">
+      <div class="row">
+        <div class="col-md-6">
           <% teacher_ids = @program.teachers.where.not(id: teacher.id).pluck(:person_id) %>
           <%= f.association :person, collection: current_university.people.teachers.where.not(id: teacher_ids).ordered %>
-          <%= f.input :description, input_html: { rows: 5 } %>
+        </div>
+        <div class="col-md-6">
+          <%= f.input :description, as: :string %>
         </div>
       </div>
     </div>
diff --git a/app/views/admin/education/programs/show.html.erb b/app/views/admin/education/programs/show.html.erb
index 93f13b21d..e6c1563c7 100644
--- a/app/views/admin/education/programs/show.html.erb
+++ b/app/views/admin/education/programs/show.html.erb
@@ -104,39 +104,41 @@
         <% end %>
         <h3 class="h5 <%= 'mt-4' if i > 0 %>"><%= Education::Program.human_attribute_name('teachers') %></h3>
         <p><%= link_to t('create'), new_admin_education_program_teacher_path(program_id: @program.id), class: 'btn btn-primary' %></p>
-        <table class="table">
-          <thead>
-            <tr>
-              <th><%= Education::Program::Teacher.model_name.human %></th>
-              <th><%= Education::Program::Teacher.human_attribute_name('description') %></th>
-              <th></th>
-            </tr>
-          </thead>
-          <tbody>
-            <% @program.teachers.includes(:person).ordered.each do |teacher| %>
+        <% if @program.teachers.any? %>
+          <table class="table">
+            <thead>
               <tr>
-                <td>
-                  <%= link_to_if  can?(:read, teacher.person),
-                                  teacher.person,
-                                  admin_education_teacher_path(teacher.person) %>
-                </td>
-                <td><%= teacher.description %></td>
-                <td class="text-end pe-0">
-                  <div class="btn-group" role="group">
-                    <%= link_to t('edit'),
-                                edit_admin_education_program_teacher_path(teacher, { program_id: @program.id }),
-                                class: button_classes %>
-                    <%= link_to t('delete'),
-                                admin_education_program_teacher_path(teacher, { program_id: @program.id }),
-                                method: :delete,
-                                data: { confirm: t('please_confirm') },
-                                class: button_classes_danger %>
-                  </div>
-                </td>
+                <th><%= Education::Program::Teacher.model_name.human %></th>
+                <th><%= Education::Program::Teacher.human_attribute_name('description') %></th>
+                <th></th>
               </tr>
-            <% end %>
-          </tbody>
-        </table>
+            </thead>
+            <tbody>
+              <% @program.teachers.includes(:person).ordered.each do |teacher| %>
+                <tr>
+                  <td>
+                    <%= link_to_if  can?(:read, teacher.person),
+                                    teacher.person,
+                                    admin_education_teacher_path(teacher.person) %>
+                  </td>
+                  <td><%= teacher.description %></td>
+                  <td class="text-end pe-0">
+                    <div class="btn-group" role="group">
+                      <%= link_to t('edit'),
+                                  edit_admin_education_program_teacher_path(teacher, { program_id: @program.id }),
+                                  class: button_classes %>
+                      <%= link_to t('delete'),
+                                  admin_education_program_teacher_path(teacher, { program_id: @program.id }),
+                                  method: :delete,
+                                  data: { confirm: t('please_confirm') },
+                                  class: button_classes_danger %>
+                    </div>
+                  </td>
+                </tr>
+              <% end %>
+            </tbody>
+          </table>
+        <% end %>
       </div>
     </div>
   </div>
-- 
GitLab