From ee592661cc77550cc333d982945d34cdaec56d27 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Sun, 22 Jan 2023 18:18:16 +0100
Subject: [PATCH] wip

---
 app/assets/stylesheets/admin/pure/style.sass  |   1 +
 .../teachers/show/_programs.html.erb          |  16 +-
 .../admin/layouts/themes/pure/_panel.html.erb |   5 +-
 .../admin/university/people/_form.html.erb    | 221 ++++++++----------
 .../university/people/_main_infos.html.erb    | 127 +++++-----
 .../admin/university/people/show.html.erb     |   2 +-
 .../university/people/show/_roles.html.erb    |  14 +-
 7 files changed, 165 insertions(+), 221 deletions(-)

diff --git a/app/assets/stylesheets/admin/pure/style.sass b/app/assets/stylesheets/admin/pure/style.sass
index bff438e83..56a5bb843 100644
--- a/app/assets/stylesheets/admin/pure/style.sass
+++ b/app/assets/stylesheets/admin/pure/style.sass
@@ -1,5 +1,6 @@
 .pure
     &__section
+        margin-bottom: $spacing3
         h2
             font-size: px2rem(18)
             font-weight: bold
diff --git a/app/views/admin/education/teachers/show/_programs.html.erb b/app/views/admin/education/teachers/show/_programs.html.erb
index 1a3e7c573..262cc5099 100644
--- a/app/views/admin/education/teachers/show/_programs.html.erb
+++ b/app/views/admin/education/teachers/show/_programs.html.erb
@@ -1,9 +1,8 @@
 <% param_name ||= :page %>
 <% if involvements.total_count > 0 %>
-  <div class="card">
-    <div class="card-header">
-      <h2 class="card-title mb-0 h5"><%= "#{Education::Program.model_name.human(count: 2)} (#{involvements.total_count})" %></h2>
-    </div>
+  <%= panel title: Education::Program.model_name.human(count: 2),
+            subtitle: "#{involvements.total_count} #{Education::Program.model_name.human(count: involvements.total_count).downcase}" do %>
+
     <div class="table-responsive">
       <table class="<%= table_classes %>">
         <thead>
@@ -33,11 +32,6 @@
         </tbody>
       </table>
     </div>
-
-    <% if involvements.total_pages > 1 %>
-      <div class="card-footer">
-        <%= paginate involvements, theme: 'bootstrap-5', param_name: param_name %>
-      </div>
-    <% end %>
-  </div>
+    <%= paginate involvements, theme: 'bootstrap-5', param_name: param_name %>
+  <% end %>
 <% end %>
diff --git a/app/views/admin/layouts/themes/pure/_panel.html.erb b/app/views/admin/layouts/themes/pure/_panel.html.erb
index 7841e16c5..a119a06d2 100644
--- a/app/views/admin/layouts/themes/pure/_panel.html.erb
+++ b/app/views/admin/layouts/themes/pure/_panel.html.erb
@@ -1,9 +1,12 @@
-<section class="pure__section flex-fill position-relative mb-5">
+<section class="pure__section flex-fill position-relative">
   <% if action %>
     <div class="float-end"><%= raw action %></div>
   <% end %>
   <% if title %>
     <h2><%= title %></h2>
   <% end %>
+  <% if subtitle %>
+    <p><%= subtitle %></p>
+  <% end %>
   <%= yield %>
 </section>
\ No newline at end of file
diff --git a/app/views/admin/university/people/_form.html.erb b/app/views/admin/university/people/_form.html.erb
index 1c96a3da2..2b4c8d345 100644
--- a/app/views/admin/university/people/_form.html.erb
+++ b/app/views/admin/university/people/_form.html.erb
@@ -4,147 +4,110 @@
 
   <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">
-            <%= University::Person.human_attribute_name('essentials') %>
-          </h5>
-        </div>
-        <div class="card-body">
-          <div class="row">
-            <div class="col-md-6">
-              <%= f.input :first_name %>
-            </div>
-            <div class="col-md-6">
-              <%= f.input :last_name %>
-            </div>
-          </div>
-          <div class="row">
-            <div class="col-md-6">
-              <%= f.input :gender, label_method: lambda { |g| t("activerecord.attributes.university/person.genders.#{g[1]}") } %>
-            </div>
-            <div class="col-md-6">
-              <%= f.input :birthdate, discard_year: true, include_blank: true %>
-            </div>
-          </div>
-          <%= render 'admin/application/summary/form', f: f, about: person %>
-          <%= f.input :biography,
-                      as: :summernote,
-                      input_html: {
-                        data: { 'summernote-config' => 'mini-list' }
-                      } %>
-        </div>
-      </div>
-      <div class="card flex-fill w-100">
-        <div class="card-header">
-          <h5 class="card-title mb-0">
-            <%= University::Person.human_attribute_name('contacts') %>
-          </h5>
-        </div>
-        <div class="card-body">
-          <p><em><%= t("university.person.personal_data_warning") %></em></p>
-          <div class="row">
-            <div class="col-md-6">
-              <%= f.input :email %>
-            </div>
-            <div class="col-md-6">
-              <%= f.input :phone_mobile %>
-            </div>
-          </div>
-          <div class="row">
-            <div class="col-md-6">
-              <%= f.input :phone_professional %>
-            </div>
-            <div class="col-md-6">
-              <%= f.input :phone_personal %>
-            </div>
-          </div>
-          <div class="row">
-            <div class="col-md-6">
-              <%= f.input :address %>
-            </div>
-            <div class="col-md-6">
-              <%= f.input :zipcode %>
-            </div>
-          </div>
-          <div class="row">
-            <div class="col-md-6">
-              <%= f.input :city %>
-            </div>
-            <div class="col-md-6">
-              <%= f.input :country, input_html: { class: 'form-select' } %>
-            </div>
+      <%= panel title: University::Person.human_attribute_name('essentials') do %>
+        <div class="row pure__row--small">
+          <div class="col-xxl-6">
+            <%= f.input :first_name %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :last_name %>
           </div>
         </div>
-      </div>
-      <div class="card flex-fill w-100">
-        <div class="card-header">
-          <h5 class="card-title mb-0">
-            <%= University::Person.human_attribute_name('socials') %>
-          </h5>
+        <div class="row pure__row--small">
+          <div class="col-xxl-6">
+            <%= f.input :gender, label_method: lambda { |g| t("activerecord.attributes.university/person.genders.#{g[1]}") } %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :birthdate, discard_year: true, include_blank: true %>
+          </div>
         </div>
-        <div class="card-body">
-          <%= f.input :url %>
-          <div class="row">
-            <div class="col-md-6">
-              <%= f.input :linkedin %>
-            </div>
-            <div class="col-md-6">
-              <%= f.input :twitter %>
-              <%= f.input :mastodon %>
-            </div>
+        <%= render 'admin/application/summary/form', f: f, about: person %>
+        <%= f.input :biography,
+                    as: :summernote,
+                    input_html: {
+                      data: { 'summernote-config' => 'mini-list' }
+                    } %>
+      <% end %>
+      <%= panel title: University::Person.human_attribute_name('contacts') do %>
+        <p><em><%= t("university.person.personal_data_warning") %></em></p>
+        <div class="row pure__row--small">
+          <div class="col-xxl-6">
+            <%= f.input :email %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :phone_mobile %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :phone_professional %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :phone_personal %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :address %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :zipcode %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :city %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :country, input_html: { class: 'form-select' } %>
           </div>
         </div>
-      </div>
-      <div class="card flex-fill w-100">
-        <div class="card-header">
-          <h5 class="card-title mb-0"><%= University::Person.human_attribute_name('abilities') %></h5>
+      <% end %>
+      <%= panel title: University::Person.human_attribute_name('socials') do %>
+        <p><em><%= t("university.person.personal_data_warning") %></em></p>
+        <div class="row pure__row--small">
+          <div class="col-xxl-6">
+           <%= f.input :url %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :linkedin %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :twitter %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :mastodon %>
+          </div>
         </div>
-        <div class="card-body">
-          <div class="row">
-            <div class="col-md-6">
-              <%= f.input :is_teacher %>
-              <%= f.input :is_administration %>
-              <%= f.input :is_alumnus %>
-            </div>
-            <div class="col-md-6">
-              <%= f.input :tenure %>
-              <%= f.input :is_researcher %>
-              <%= f.input :habilitation %>
-            </div>
+      <% end %>
+      <%= panel title: University::Person.human_attribute_name('abilities') do %>
+        <div class="row pure__row--small">
+          <div class="col-xxl-6">
+            <%= f.input :is_teacher %>
+            <%= f.input :is_administration %>
+            <%= f.input :is_alumnus %>
+          </div>
+          <div class="col-xxl-6">
+            <%= f.input :tenure %>
+            <%= f.input :is_researcher %>
+            <%= f.input :habilitation %>
           </div>
         </div>
-      </div>
+      <% end %>
     </div>
     <div class="col-md-4">
-      <div class="card flex-fill w-100">
-        <div class="card-header">
-          <h5 class="card-title mb-0"><%= t('metadata') %></h5>
-        </div>
-        <div class="card-body">
+      <%= panel title: t('metadata') do %>
           <%= f.input :slug,
-          as: :string,
-          input_html: person.persisted? ? {} : {
-            class: 'js-slug-input',
-            data: { source: '#university_person_first_name, #university_person_last_name' }
-          } %>
+                      as: :string,
+                      input_html: person.persisted? ? {} : {
+                        class: 'js-slug-input',
+                        data: { source: '#university_person_first_name, #university_person_last_name' }
+                      } %>
           <%= f.association :user, collection: current_university.users.ordered if can?(:manage, User) %>
-        </div>
-      </div>
-      <div class="card flex-fill w-100">
-        <div class="card-header">
-          <h5 class="card-title mb-0"><%= University::Person.human_attribute_name('picture') %></h5>
-        </div>
-        <div class="card-body">
-          <%= f.input :picture,
-                  as: :single_deletable_file,
-                  label: false,
-                  input_html: { accept: '.jpg,.jpeg,.png,.svg' },
-                  preview: 200,
-                  resize: 1,
-                  direct_upload: true %>
-        </div>
-      </div>
+      <% end %>
+      <%= panel title: University::Person.human_attribute_name('picture') do %>
+        <%= f.input :picture,
+                    as: :single_deletable_file,
+                    label: false,
+                    input_html: { accept: '.jpg,.jpeg,.png,.svg' },
+                    preview: 200,
+                    resize: 1,
+                    direct_upload: true %>
+      <% end %>
       <%= render 'admin/application/meta_description/form', f: f, about: person %>
     </div>
   </div>
diff --git a/app/views/admin/university/people/_main_infos.html.erb b/app/views/admin/university/people/_main_infos.html.erb
index 6ab39d44f..2569690dd 100644
--- a/app/views/admin/university/people/_main_infos.html.erb
+++ b/app/views/admin/university/people/_main_infos.html.erb
@@ -1,101 +1,90 @@
 <div class="row">
   <div class="col-md-8 col-xl-9">
     <%= render 'admin/application/summary/show', about: person %>
-
-    <div class="card flex-fill w-100">
-      <div class="card-header">
-        <h2 class="card-title mb-0 h5"><%= t('content') %></h2>
-      </div>
-      <div class="card-body">
+    <%= panel title: t('content') do %>
+      <div class="row pure__row--small">
         <% unless person.gender.blank? %>
-          <h3 class="h5"><%= University::Person.human_attribute_name('gender') %></h3>
-          <p><%= t("activerecord.attributes.university/person.genders.#{person.gender}") %></p>
+          <div class="col-md-6">
+            <h3 class="h5"><%= University::Person.human_attribute_name('gender') %></h3>
+            <p><%= t("activerecord.attributes.university/person.genders.#{person.gender}") %></p>
+          </div>
         <% end %>
         <% unless person.email.blank? %>
-          <h3 class="h5"><%= University::Person.human_attribute_name('email') %></h3>
-          <p><%= link_to person.email, "mailto:#{person.email}", target: '_blank' %></p>
+          <div class="col-md-6">
+            <h3 class="h5"><%= University::Person.human_attribute_name('email') %></h3>
+            <p><%= link_to person.email, "mailto:#{person.email}", target: '_blank' %></p>
+          </div>
         <% end %>
         <% ['phone_mobile', 'phone_personal', 'phone_professional'].each do |phone| %>
           <% unless person[phone].blank? %>
-            <h3 class="h5"><%= University::Person.human_attribute_name(phone) %></h3>
-            <p><%= link_to person[phone], "tel:#{person[phone]}", target: '_blank' %></p>
+            <div class="col-md-6">
+              <h3 class="h5"><%= University::Person.human_attribute_name(phone) %></h3>
+              <p><%= link_to person[phone], "tel:#{person[phone]}", target: '_blank' %></p>
+            </div>
           <% end %>
         <% end %>
         <% unless person.birthdate.blank? %>
-          <h3 class="h5"><%= University::Person.human_attribute_name('birthdate') %></h3>
-          <p><%= l(person.birthdate, format: :birthday) %></p>
+          <div class="col-md-6">
+            <h3 class="h5"><%= University::Person.human_attribute_name('birthdate') %></h3>
+            <p><%= l(person.birthdate, format: :birthday) %></p>
+           </div>
         <% end %>
         <% [:address, :zipcode, :city, :country].each do |property| %>
           <% value = person.send property %>
           <% next if value.blank? %>
-          <h3 class="h5"><%= University::Person.human_attribute_name(property) %></h3>
-          <p><%= value %></p>
-        <% end %>
-
-        <% unless person.biography.blank? %>
-          <h3 class="h5"><%= University::Person.human_attribute_name('biography') %></h3>
-          <%= person.biography %>
+          <div class="col-md-6">
+            <h3 class="h5"><%= University::Person.human_attribute_name(property) %></h3>
+            <p><%= value %></p>
+          </div>
         <% end %>
       </div>
-    </div>
-    <% unless person.url.blank? && person.linkedin.blank? && person.twitter.blank? %>
-      <div class="card flex-fill w-100">
-        <div class="card-header">
-          <h2 class="card-title mb-0 h5"><%= University::Person.human_attribute_name('socials') %></h2>
-        </div>
-        <div class="card-body">
-          <% unless person.url.blank? %>
-            <h3 class="h5"><%= University::Person.human_attribute_name('url') %></h3>
-            <p><%= link_to person.url, person.url, target: '_blank' %></p>
-          <% end %>
-          <% unless person.linkedin.blank? %>
-            <h3 class="h5"><%= University::Person.human_attribute_name('linkedin') %></h3>
-            <p><%= link_to person.linkedin, person.linkedin, target: '_blank' %></p>
-          <% end %>
-          <% unless person.twitter.blank? %>
-            <h3 class="h5"><%= University::Person.human_attribute_name('twitter') %></h3>
-            <p><%= link_to person.twitter, "https://twitter.com/#{person.twitter}", target: '_blank' %></p>
-          <% end %>
-          <% unless person.mastodon.blank? %>
-            <h3 class="h5"><%= University::Person.human_attribute_name('mastodon') %></h3>
-            <p><%= link_to person.mastodon, person.mastodon, target: '_blank' %></p>
-          <% end %>
-        </div>
-      </div>
+      <% unless person.biography.blank? %>
+        <h3 class="h5"><%= University::Person.human_attribute_name('biography') %></h3>
+        <%= person.biography %>
+      <% end %>
     <% end %>
+    
+    <%= panel title: University::Person.human_attribute_name('socials') do %>
+      <% unless person.url.blank? %>
+        <h3 class="h5"><%= University::Person.human_attribute_name('url') %></h3>
+        <p><%= link_to person.url, person.url, target: '_blank' %></p>
+      <% end %>
+      <% unless person.linkedin.blank? %>
+        <h3 class="h5"><%= University::Person.human_attribute_name('linkedin') %></h3>
+        <p><%= link_to person.linkedin, person.linkedin, target: '_blank' %></p>
+      <% end %>
+      <% unless person.twitter.blank? %>
+        <h3 class="h5"><%= University::Person.human_attribute_name('twitter') %></h3>
+        <p><%= link_to person.twitter, "https://twitter.com/#{person.twitter}", target: '_blank' %></p>
+      <% end %>
+      <% unless person.mastodon.blank? %>
+        <h3 class="h5"><%= University::Person.human_attribute_name('mastodon') %></h3>
+        <p><%= link_to person.mastodon, person.mastodon, target: '_blank' %></p>
+      <% end %>
+    <% end unless person.url.blank? && person.linkedin.blank? && person.twitter.blank? %>
+
     <%= render 'admin/communication/blocks/list', about: person %>
   </div>
   <div class="col-md-4 col-xl-3">
-    <div class="card flex-fill w-100">
-      <div class="card-header">
-        <h2 class="card-title mb-0 h5"><%= t('metadata') %></h2>
-      </div>
-      <div class="card-body">
+    <%= panel title: t('metadata') do %>
         <h3 class="h5"><%= University::Person.human_attribute_name('slug') %></h3>
         <p><%= person.slug %></p>
         <% if person.user.present? %>
           <h3 class="h5"><%= University::Person.human_attribute_name('user') %></h3>
           <p><%= link_to_if can?(:read, person.user), person.user, admin_user_path(person.user) %></p>
         <% end %>
-      </div>
-    </div>
-    <% if person.best_picture.attached? %>
-      <div class="card flex-fill w-100">
-        <div class="card-header">
-          <h2 class="card-title mb-0 h5"><%= t('activerecord.attributes.university/person.picture') %></h2>
-        </div>
-        <div class="card-body">
-          <% if person.best_picture_inherits_from_user? %>
-            <p>
-              <span class="small text-muted">
-                <%= t 'admin.inheritance.sentence_html', link: link_to_if(can?(:read, person.user), person.user, [:admin, person.user]) %>
-              </span>
-            </p>
-          <% end %>
-          <%= kamifusen_tag person.best_picture, class: 'img-fluid' %>
-        </div>
-      </div>
     <% end %>
+    <%= panel title: t('activerecord.attributes.university/person.picture') do %>
+      <% if person.best_picture_inherits_from_user? %>
+        <p>
+          <span class="small text-muted">
+            <%= t 'admin.inheritance.sentence_html', link: link_to_if(can?(:read, person.user), person.user, [:admin, person.user]) %>
+          </span>
+        </p>
+      <% end %>
+      <%= kamifusen_tag person.best_picture, class: 'img-fluid' %>
+    <% end if person.best_picture.attached? %>
+
     <%= render 'admin/application/meta_description/show', about: person %>
   </div>
 </div>
diff --git a/app/views/admin/university/people/show.html.erb b/app/views/admin/university/people/show.html.erb
index 026ee04e5..e4b751669 100644
--- a/app/views/admin/university/people/show.html.erb
+++ b/app/views/admin/university/people/show.html.erb
@@ -3,7 +3,7 @@
 <%= render 'main_infos', person: @person %>
 
 <% if @teacher_involvements.total_count > 0 || @administrator_involvements.total_count > 0 %>
-  <h2 class="mb-3"><%= University::Person::Involvement.model_name.human(count: 2) %></h2>
+  <h2 class="category"><%= University::Person::Involvement.model_name.human(count: 2) %></h2>
 
   <div class="row">
     <% if @person.is_teacher? && @teacher_involvements.any? %>
diff --git a/app/views/admin/university/people/show/_roles.html.erb b/app/views/admin/university/people/show/_roles.html.erb
index 748082e55..b59e6e48c 100644
--- a/app/views/admin/university/people/show/_roles.html.erb
+++ b/app/views/admin/university/people/show/_roles.html.erb
@@ -1,8 +1,6 @@
 <% if involvements.total_count > 0 %>
-  <div class="card">
-    <div class="card-header">
-      <h2 class="card-title mb-0 h5"><%= t('university.person.administrator_roles') %> (<%= involvements.total_count %>)</h2>
-    </div>
+  <%= panel title: t('university.person.administrator_roles'),
+            subtitle: "#{involvements.total_count} #{t('university.person.administrator_roles').downcase}" do %>
     <div class="table-responsive">
       <table class="<%= table_classes %>">
         <thead>
@@ -42,10 +40,6 @@
         </tbody>
       </table>
     </div>
-    <% if involvements.total_pages > 1 %>
-      <div class="card-footer">
-        <%= paginate involvements, theme: 'bootstrap-5', param_name: :roles_page %>
-      </div>
-    <% end %>
-  </div>
+    <%= paginate involvements, theme: 'bootstrap-5', param_name: :roles_page %>
+  <% end %>
 <% end %>
-- 
GitLab