From 0896f53ab9c34087d407af37067b83b26204b24d Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Mon, 6 Feb 2023 10:48:14 +0100
Subject: [PATCH] Better language choice

---
 .../communication/websites/_sidebar.html.erb  | 22 ++++-----
 db/schema.rb                                  | 46 ++++++++++++-------
 2 files changed, 41 insertions(+), 27 deletions(-)

diff --git a/app/views/admin/communication/websites/_sidebar.html.erb b/app/views/admin/communication/websites/_sidebar.html.erb
index 5401aa967..f17d34fe3 100644
--- a/app/views/admin/communication/websites/_sidebar.html.erb
+++ b/app/views/admin/communication/websites/_sidebar.html.erb
@@ -32,7 +32,7 @@
       navigation << {
         title: t('communication.website.analytics'),
         path: analytics_admin_communication_website_path(@website.id, website_id: nil),
-        icon:  Icon::COMMUNICATION_WEBSITE_ANALYTICS,
+        icon: Icon::COMMUNICATION_WEBSITE_ANALYTICS,
         ability: can?(:read, @website)
       } if @website.plausible_url.present?
 
@@ -51,16 +51,16 @@
     </div>
 
     <% if @website.languages.many? %>
-      <div class="card">
-        <div class="card-header">
-          <h2 class="card-title mb-0"><%= Language.model_name.human %></h2>
-        </div>
-        <div class="list-group list-group-flush" role="tablist">
-          <% @website.languages.each do |language| %>
-              <%= link_to I18n.t(language.iso_code, scope: :languages), request.params.merge(lang: language.iso_code), class: "list-group-item list-group-item-action #{'active' if current_website_language == language}" %>
-          <% end %>
-        </div>
-      </div>
+      <select class="form-control form-select mt-5"  onchange="if (this.value) window.location.href=this.value">
+        <% @website.languages.each do |language| %>
+          <% 
+          label = I18n.t(language.iso_code, scope: :languages)
+          path = url_for request.params.merge(lang: language.iso_code)
+          selected = current_website_language == language
+          %>
+          <option value="<%= path %>"<% if selected %> selected="selected"<% end %>><%= label %></option>
+        <% end %>
+      </select>
     <% end %>
 
   </div>
diff --git a/db/schema.rb b/db/schema.rb
index aae0b24e6..d9bb65c8e 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -577,20 +577,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_03_135355) do
     t.string "summernote_locale"
   end
 
-  create_table "research_documents", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
-    t.uuid "university_id", null: false
-    t.uuid "university_person_id", null: false
-    t.string "docid"
-    t.jsonb "data"
-    t.string "title"
-    t.string "url"
-    t.string "ref"
-    t.datetime "created_at", null: false
-    t.datetime "updated_at", null: false
-    t.index ["university_id"], name: "index_research_documents_on_university_id"
-    t.index ["university_person_id"], name: "index_research_documents_on_university_person_id"
-  end
-
   create_table "research_journal_paper_kinds", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
     t.uuid "university_id", null: false
     t.uuid "journal_id", null: false
@@ -678,6 +664,13 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_03_135355) do
     t.index ["university_id"], name: "index_research_laboratories_on_university_id"
   end
 
+  create_table "research_laboratories_publications", id: false, force: :cascade do |t|
+    t.uuid "research_publication_id", null: false
+    t.uuid "research_laboratory_id", null: false
+    t.index ["research_laboratory_id", "research_publication_id"], name: "index_laboratory_publication"
+    t.index ["research_publication_id", "research_laboratory_id"], name: "index_publication_laboratory"
+  end
+
   create_table "research_laboratory_axes", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t|
     t.uuid "university_id", null: false
     t.uuid "research_laboratory_id", null: false
@@ -692,6 +685,27 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_03_135355) do
     t.index ["university_id"], name: "index_research_laboratory_axes_on_university_id"
   end
 
+  create_table "research_publications", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.string "docid"
+    t.jsonb "data"
+    t.string "title"
+    t.string "url"
+    t.string "ref"
+    t.datetime "created_at", null: false
+    t.datetime "updated_at", null: false
+    t.string "hal_url"
+    t.date "publication_date"
+    t.string "doi"
+    t.string "slug"
+  end
+
+  create_table "research_publications_university_people", id: false, force: :cascade do |t|
+    t.uuid "research_publication_id", null: false
+    t.uuid "university_person_id", null: false
+    t.index ["research_publication_id", "university_person_id"], name: "index_publication_person"
+    t.index ["university_person_id", "research_publication_id"], name: "index_person_publication"
+  end
+
   create_table "research_theses", id: :uuid, default: -> { "public.gen_random_uuid()" }, force: :cascade do |t|
     t.uuid "university_id", null: false
     t.uuid "research_laboratory_id", null: false
@@ -797,6 +811,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_03_135355) do
     t.string "city"
     t.string "country"
     t.string "hal_person_identifier"
+    t.string "hal_doc_identifier"
+    t.string "hal_form_identifier"
     t.string "mastodon"
     t.uuid "language_id", null: false
     t.uuid "original_id"
@@ -954,8 +970,6 @@ ActiveRecord::Schema[7.0].define(version: 2023_02_03_135355) do
   add_foreign_key "education_schools", "universities"
   add_foreign_key "imports", "universities"
   add_foreign_key "imports", "users"
-  add_foreign_key "research_documents", "universities"
-  add_foreign_key "research_documents", "university_people"
   add_foreign_key "research_journal_paper_kinds", "research_journals", column: "journal_id"
   add_foreign_key "research_journal_paper_kinds", "universities"
   add_foreign_key "research_journal_papers", "research_journal_paper_kinds", column: "kind_id"
-- 
GitLab