From 8ea332ffc43141da67b2c25c136834fb7fb0d132 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Gaya?= <sebastien.gaya@gmail.com>
Date: Mon, 13 Mar 2023 11:11:38 +0100
Subject: [PATCH] Leaflet in external JS entrypoint

---
 app/assets/javascripts/extranet.js                      | 1 -
 app/assets/javascripts/map.js                           | 1 +
 app/views/extranet/contacts/organizations/show.html.erb | 2 ++
 3 files changed, 3 insertions(+), 1 deletion(-)
 create mode 100644 app/assets/javascripts/map.js

diff --git a/app/assets/javascripts/extranet.js b/app/assets/javascripts/extranet.js
index 3c9f58a03..acfd1811b 100644
--- a/app/assets/javascripts/extranet.js
+++ b/app/assets/javascripts/extranet.js
@@ -11,7 +11,6 @@
 //= require simple_form_bs5_file_input
 //= require summernote/summernote-bs5
 //= require gdpr/cookie_consent
-//= require leaflet
 //= require autocomplete-rails
 //= require_tree ./application/plugins
 //= require_tree ./extranet
diff --git a/app/assets/javascripts/map.js b/app/assets/javascripts/map.js
new file mode 100644
index 000000000..6ed1c2e64
--- /dev/null
+++ b/app/assets/javascripts/map.js
@@ -0,0 +1 @@
+//= require leaflet
diff --git a/app/views/extranet/contacts/organizations/show.html.erb b/app/views/extranet/contacts/organizations/show.html.erb
index 4998e9356..58b5deeec 100644
--- a/app/views/extranet/contacts/organizations/show.html.erb
+++ b/app/views/extranet/contacts/organizations/show.html.erb
@@ -64,6 +64,8 @@
         </dd>
       <% end %>
       <% if @organization.geolocated? %>
+        <%# Include map.js before call Leaflet (map helper) %>
+        <%= javascript_include_tag 'map' %>
         <dt><%= University::Organization.human_attribute_name(:map) %></dt>
         <dl><%= map(
               center: {
-- 
GitLab