Skip to content

Commit

Permalink
add cell for comparative stats map and add new query in api_queries
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbeig committed Feb 5, 2020
1 parent 67d7fed commit d6744f6
Show file tree
Hide file tree
Showing 23 changed files with 269 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
//= link decidim/comparative_stats/graphs.js
//= link decidim/comparative_stats/upcoming_events.js
3 changes: 3 additions & 0 deletions app/assets/config/decidim_comparative_stats_manifest.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*
*= link decidim/comparative_stats/upcoming_events.css
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//= require leaflet
//= require_self

$(function() {

var map_object = document.getElementById('upcoming_events');
var map = L.map(map_object, {
center: [41,2],
zoom: 4
});

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);

});
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//= require leaflet
//= require_self

#upcoming_events {
height: 360px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<section class="extended home-section">
<div class="wrapper-home">
<div class="row column text-center">
<div class="navigation_maps">
<%= content_tag(:div, "", id: "upcoming_events", class: "map", data: { endpoints: upcoming_events }) %>
</div>
</div>
</div>
</section>

<%= javascript_include_tag "decidim/comparative_stats/upcoming_events" %>
<%= stylesheet_link_tag "decidim/comparative_stats/upcoming_events" %>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

module Decidim
module ComparativeStats
# This cell renders a map with participatory processes
# the `model` is spected to be a collection of API endpoints
#
module ContentBlocks
class ParticipatoryProcessesGeocodEventsCell < Decidim::ViewModel

view_paths << "#{Decidim::ComparativeStats::Engine.root}/app/cells/decidim/comparative_stats/content_blocks/partipatory_processes_geocod_events"

def show
render :show
end

def endpoints
Decidim::ComparativeStats::Endpoint.first
end

def upcoming_events
events = {}
data = endpoints.api.fetch_global_events.data
byebug
# endpoints.each do |endpoint|
# endpoint.api.fetch_global_events.data.each do |item|
# events[item.name] ||= {}
# end
# end
events
end
end
end
end
end
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ en:
update: 'Check and update endpoint'
endpoints:
add: "Add a Decidim URL"
content_blocks:
geocod_events: "Geocod events"
components:
comparative_stats:
name: "ComparativeStats"
Expand Down
23 changes: 23 additions & 0 deletions lib/decidim/comparative_stats/api_queries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,29 @@ module ApiQueries
}
}
GRAPHQL

GLOBAL_EVENTS = <<~GRAPHQL
query {
assemblies {
id
components {
...on Meetings{
meetings {
edges {
node {
id
coordinates {
latitude
longitude
}
}
}
}
}
}
}
}
GRAPHQL
end
end
end
10 changes: 10 additions & 0 deletions lib/decidim/comparative_stats/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ class Engine < ::Rails::Engine
initializer "decidim_comparative_stats.assets" do |app|
app.config.assets.precompile += %w(decidim_comparative_stats_manifest.js)
end

initializer "decidim.comparative_stats.content_blocks" do
Decidim.content_blocks.register(:homepage, :multinenant_upcoming_events) do |content_block|
content_block.cell = "decidim/comparative_stats/content_blocks/participatory_processes_geocod_events"
# content_block.settings_form_cell = "decidim/content_blocks/hero_settings_form"
content_block.public_name_key = "decidim.comparative_stats.content_blocks.geocod_events"

# content_block.default!
end
end
end
end
end
Binary file added vendor/assets/images/draw/layers-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/draw/layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/draw/marker-icon-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/draw/marker-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/draw/marker-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/draw/spritesheet-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/draw/spritesheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
156 changes: 156 additions & 0 deletions vendor/assets/images/draw/spritesheet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/images/layers-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/images/layers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/images/marker-icon-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/images/marker-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added vendor/assets/images/images/marker-shadow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions vendor/assets/javascripts/leaflet.js

Large diffs are not rendered by default.

0 comments on commit d6744f6

Please sign in to comment.