aboutsummaryrefslogtreecommitdiff
path: root/app/views/welcome
diff options
context:
space:
mode:
authorNemael <100dragons@gmail.com>2020-10-09 00:54:02 +0200
committerNemael <100dragons@gmail.com>2020-10-09 00:54:02 +0200
commitc120ead3de7ee7be890b6c0218fa76a9127863e8 (patch)
tree7e6a60eeccb0280a5440aa81c629cd234e984374 /app/views/welcome
parent31850c6ca118b7828dbaa3ad1a87dab4287718f5 (diff)
downloadincommon-map-c120ead3de7ee7be890b6c0218fa76a9127863e8.tar.gz
Attempts to make buttons that update the leaflet map. The javascript functions and controllers functions are not in the correct filesAttempts
Diffstat (limited to 'app/views/welcome')
-rw-r--r--app/views/welcome/index.html.erb56
1 files changed, 52 insertions, 4 deletions
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb
index 1977962..a07a034 100644
--- a/app/views/welcome/index.html.erb
+++ b/app/views/welcome/index.html.erb
@@ -6,16 +6,68 @@
integrity: "sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==",
crossorigin: '') %>
<% end %>
+<script>
+ function update_leaflet(points_list){
+ console.log(points_list)
+ console.log("EAFEAG")
+ var marker = L.marker([50.900, 4.351]).addTo(mymap);
+ var marker = L.marker([50.950, 4.351]).addTo(mymap);
+ console.log(document.getElementsByName("categories")[0].value)
+ <%= x = 2 %>
+ }
+ function get_selected_categories(){
+ <%= def tt(v)
+ puts v
+ end %>
+ cats = document.getElementsByName("cat_sel")
+ checked = []
+ for (i = 0; i < cats.length; i++){
+ if (cats[i].checked){
+ checked.push(cats[i].value)
+ }
+ }
+ console.log(checked)
+ }
+</script>
<h1>Bienvenue à l'atelier carto d'IN COMMON</h1>
<%= tag.div(id: 'map') %>
<% content_for :debug do %>
+ <%= def test_button
+ list_points = Resource.where('feature @> ?', {"properties": {"categories": [87]}}.to_json)
+ res_list = 0
+ i = 0
+ puts list_points
+ return(list_points)
+ end%>
<p>Premier élément de la liste:</p>
<% res = @resources.first %>
<p><%= res.feature["properties"]["name"] %></p>
<p><%= res.feature["geometry"]["coordinates"] %></p>
+ <button onclick=<%= test_button() %>>Test</button>
+ <% x = Resource.where('feature @> ?', {"properties": {"categories": [87]}}.to_json)%>
+ <%= x[0].feature %>
+ <%= @number_fiel = number_field_tag("categories")%>
+ <%= "NUMBER FIELD:" + @number_fiel %>
+ <p></p>
+ <%= x1 = Resource.where('feature @> ?', {"properties": {"categories": [@number_fiel]}}.to_json) %>
+ <%= "TEST" %>
+ <%= link_to("test_button", "", :onclick=> "update_leaflet(" + "[50.900, 4.351]" + ")", data: "ABC", remote: true)%>
+ <p></p>
+ <%= categories = Category.order(:id)%>
+ <%= check_box_tag(categories[0].id, value="1", :onchange=>'alert()') %>
+ <p></p>
+ <p></p>
+ <% categories.each do |category| %>
+ <%= x = check_box_tag("cat_sel", value=category.dewey_id, :onchange=> 'alert()') %>
+
+ <%= puts x %>
+ <%= label_tag(category.name) %>
+ <% end %>
+ <%= link_to("Update Leaflet", "", :onclick=> "test_button()", remote: true)%>
+
<% end %>
<% content_for :body_end do %>
@@ -31,9 +83,5 @@
accessToken: 'pk.eyJ1IjoibmVtYWVsIiwiYSI6ImNrZzBrYjBudTB3bnMyenFmNWtrN3h3bmMifQ.Rkeyhm-9iIQOV7NAMA5LaA'
}).addTo(mymap);
var marker = L.marker([50.850, 4.351]).addTo(mymap);
- //CONTINUER AVEC LES WHILE ET CONDITIONS, @resources ne contient que 25 elements (lié au nombre d'élément par page?) -- oui
- //OU PLUTOT UTILISER POSTGRES POUR FAIRE DES REQUESTES SUR @resources
- var count = 0
- console.log(count)
</script>
<% end %>