From fdf1cd3ca323c22125b41c91ed8b44d8c1ad9df2 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Mon, 2 May 2022 12:24:25 +0200
Subject: [PATCH] filtres

---
 app/views/admin/application/_filters.html.erb | 79 ++++++++++---------
 .../website/posts/_list.html.erb              |  9 ++-
 .../website/posts/index.html.erb              |  1 +
 .../communication/websites/_sidebar.html.erb  |  4 +-
 config/locales/communication/en.yml           |  4 +-
 config/locales/communication/fr.yml           |  4 +-
 db/schema.rb                                  | 21 ++++-
 7 files changed, 74 insertions(+), 48 deletions(-)

diff --git a/app/views/admin/application/_filters.html.erb b/app/views/admin/application/_filters.html.erb
index baf3ddc07..bb28a2cdf 100644
--- a/app/views/admin/application/_filters.html.erb
+++ b/app/views/admin/application/_filters.html.erb
@@ -3,45 +3,50 @@ collapsable = true if collapsable.nil? # not ||= because collapsable can be "fal
 should_be_open = false
 filters.each { |filter| should_be_open = true if params.has_key?(filter[:scope_name]) }
 %>
-<div class="row">
-  <% if collapsable %>
-    <div class="col-md-2">
-      <a  class="btn btn-primary"
-          data-bs-toggle="collapse"
-          href="#collapseFilters"
-          role="button"
-          aria-expanded="false"
-          aria-controls="collapseFilters">
-        <%= t('filters.buttons.expand') %>
-      </a>
-    </div>
-  <% end %>
-  <div class="col-md-<%= collapsable ? '10' : '12' %>">
-    <div class="collapse <%= (!collapsable || should_be_open) ? 'show' : '' %>" id="collapseFilters">
-        <%= form_tag current_path, method: :get, class: 'do-not-unlock' do |f| %>
-        <div class="row">
-          <div class="col-md-4">
-            <% filters.each do |filter| %>
-              <% if filter[:scope_name] == :for_search_term %>
-                <%= text_field_tag filter[:scope_name], params[filter[:scope_name]], placeholder: filter[:label], class: 'form-control mb-1 filter' %>
-              <% else %>
-                <% if filter[:tree] %>
-                  <% choices = collection_tree(filter[:choices]).map { |elmt| [elmt[:label].html_safe, elmt[:id]] } %>
-                <% else %>
-                  <% choices = filter[:choices].map { |elmt| elmt.is_a?(String) ?  [elmt, elmt] : [elmt.is_a?(Hash) ? elmt[:to_s] : elmt.to_s, elmt[:id]] } %>
-                <% end %>
-                <% field_name = filter[:multiple] ? "#{filter[:scope_name]}[]" : filter[:scope_name] %>
-                <%= select_tag field_name, options_for_select(choices, params[filter[:scope_name]]), include_blank: filter[:label], class: 'form-select mb-1 filter' %>
-              <% end %>
+
+<% if collapsable %>
+  <div class="text-end mt-n5">
+    <a  class="btn btn-light btn-sm"
+        data-bs-toggle="collapse"
+        href="#collapseFilters"
+        role="button"
+        aria-expanded="false"
+        aria-controls="collapseFilters">
+      <i class="fas fa-filter"></i>
+      <%= t('filters.buttons.expand') %>
+    </a>
+  </div>
+<% end %>
+<div class="mt-4 mb-n3 collapse <%= (!collapsable || should_be_open) ? 'show' : '' %>" id="collapseFilters">
+  <%= form_tag current_path, method: :get, class: 'do-not-unlock' do |f| %>
+    <div class="row">
+      <% filters.each do |filter| %>
+        <div class="col-md-4">
+          <% if filter[:scope_name] == :for_search_term %>
+            <%= text_field_tag  filter[:scope_name],
+                                params[filter[:scope_name]],
+                                placeholder: filter[:label],
+                                class: 'form-control mb-3 filter' %>
+          <% else %>
+            <% if filter[:tree] %>
+              <% choices = collection_tree(filter[:choices]).map { |elmt| [elmt[:label].html_safe, elmt[:id]] } %>
+            <% else %>
+              <% choices = filter[:choices].map { |elmt| elmt.is_a?(String) ?  [elmt, elmt] : [elmt.is_a?(Hash) ? elmt[:to_s] : elmt.to_s, elmt[:id]] } %>
             <% end %>
-          </div>
-          <div class="col-md-3">
-            <%= submit_tag t('filters.buttons.submit'), class: 'btn btn-primary btn-submit' %>
-            <%= link_to t('reset'), current_path, class: 'btn btn-warning' %>
-          </div>
+            <% field_name = filter[:multiple] ? "#{filter[:scope_name]}[]" : filter[:scope_name] %>
+            <%= select_tag  field_name,
+                            options_for_select(choices, params[filter[:scope_name]]),
+                            include_blank: filter[:label],
+                            class: 'form-select mb-3 filter' %>
+          <% end %>
         </div>
-        <% end %>
+      <% end %>
+      <div class="col-md-4">
+        <%= submit_tag t('filters.buttons.submit'), class: 'btn btn-primary btn-submit' %>
+        <%= link_to t('reset'), current_path, class: 'btn btn-secondary' %>
+      </div>
     </div>
-  </div>
+  <% end %>
 </div>
+
 <br>
diff --git a/app/views/admin/communication/website/posts/_list.html.erb b/app/views/admin/communication/website/posts/_list.html.erb
index 8ebc3a677..5fbf2c99b 100644
--- a/app/views/admin/communication/website/posts/_list.html.erb
+++ b/app/views/admin/communication/website/posts/_list.html.erb
@@ -19,7 +19,6 @@
       <% unless hide_category %>
         <th><%= Communication::Website::Post.human_attribute_name('categories') %></th>
       <% end %>
-      <th><%= Communication::Website::Post.human_attribute_name('pinned') %></th>
       <th colspan="2"><%= Communication::Website::Post.human_attribute_name('published_at') %></th>
     </tr>
   </thead>
@@ -48,8 +47,12 @@
             </ul>
           </td>
         <% end %>
-        <td><small><%= t post.pinned %></small></td>
-        <td><small><%= l post.published_at, format: :date_with_explicit_month if post.published_at %></small></td>
+        <td>
+          <%= l post.published_at, format: :date_with_explicit_month if post.published_at %>
+          <% if post.pinned %>
+            <span class="badge bg-success"><%= Communication::Website::Post.human_attribute_name('pinned') %></span>
+          <% end %>
+        </td>
         <td class="text-end">
           <div class="btn-group" role="group">
             <%= link_to t('edit'),
diff --git a/app/views/admin/communication/website/posts/index.html.erb b/app/views/admin/communication/website/posts/index.html.erb
index 4f0118150..0d3175281 100644
--- a/app/views/admin/communication/website/posts/index.html.erb
+++ b/app/views/admin/communication/website/posts/index.html.erb
@@ -30,6 +30,7 @@
       </div>
     <% end %>
   </div>
+
 <% end %>
 
 <% content_for :action_bar_left do %>
diff --git a/app/views/admin/communication/websites/_sidebar.html.erb b/app/views/admin/communication/websites/_sidebar.html.erb
index e3517b64d..130b9144f 100644
--- a/app/views/admin/communication/websites/_sidebar.html.erb
+++ b/app/views/admin/communication/websites/_sidebar.html.erb
@@ -1,5 +1,5 @@
 <div class="row mt-2">
-  <div class="col-md-3 col-lg-2">
+  <div class="col-lg-3 col-xl-2">
     <div class="card">
       <div class="list-group list-group-flush" role="tablist">
         <%
@@ -45,7 +45,7 @@
       </div>
     </div>
   </div>
-  <div class="col-md-9 col-lg-10">
+  <div class="col-lg-9 col-xl-10">
     <%= yield %>
   </div>
 </div>
diff --git a/config/locales/communication/en.yml b/config/locales/communication/en.yml
index aab9134ea..f016a7e5a 100644
--- a/config/locales/communication/en.yml
+++ b/config/locales/communication/en.yml
@@ -111,8 +111,8 @@ en:
         description_short: Lead text
         featured_image: Featured image
         featured_image_alt: Alt text
-        pinned: Pinned?
-        published: Published?
+        pinned: Pinned
+        published: Published
         published_at: Publication date
         slug: Slug
         text: Text
diff --git a/config/locales/communication/fr.yml b/config/locales/communication/fr.yml
index a6b2b3291..b600e2889 100644
--- a/config/locales/communication/fr.yml
+++ b/config/locales/communication/fr.yml
@@ -111,8 +111,8 @@ fr:
         description_short: Chapô
         featured_image: Image à la une
         featured_image_alt: Texte alternatif
-        pinned: Mis en avant ?
-        published: Publié ?
+        pinned: Mis en avant
+        published: Publié
         published_at: Date de publication
         slug: Slug
         text: Texte
diff --git a/db/schema.rb b/db/schema.rb
index 6ee0922f1..ea5716f23 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -319,10 +319,10 @@ ActiveRecord::Schema.define(version: 2022_04_28_171541) do
     t.uuid "related_category_id"
     t.string "featured_image_alt"
     t.text "text"
+    t.text "description_short"
     t.string "breadcrumb_title"
     t.text "header_text"
     t.integer "kind"
-    t.text "description_short"
     t.string "bodyclass"
     t.uuid "language_id"
     t.index ["communication_website_id"], name: "index_communication_website_pages_on_communication_website_id"
@@ -503,6 +503,23 @@ ActiveRecord::Schema.define(version: 2022_04_28_171541) do
     t.index ["university_id"], name: "index_education_schools_on_university_id"
   end
 
+  create_table "external_organizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
+    t.string "title"
+    t.text "description"
+    t.string "address"
+    t.string "zipcode"
+    t.string "city"
+    t.string "country"
+    t.string "website"
+    t.string "phone"
+    t.string "mail"
+    t.boolean "active"
+    t.string "sirene"
+    t.integer "kind"
+    t.datetime "created_at", precision: 6, null: false
+    t.datetime "updated_at", precision: 6, null: false
+  end
+
   create_table "languages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
     t.string "name"
     t.string "iso_code"
@@ -692,8 +709,8 @@ ActiveRecord::Schema.define(version: 2022_04_28_171541) do
     t.string "linkedin"
     t.boolean "is_alumnus", default: false
     t.text "description_short"
-    t.boolean "is_author"
     t.string "name"
+    t.boolean "is_author"
     t.index ["university_id"], name: "index_university_people_on_university_id"
     t.index ["user_id"], name: "index_university_people_on_user_id"
   end
-- 
GitLab