decidim-decidim_geo 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE-AGPLv3.txt +661 -0
- data/README.md +172 -0
- data/Rakefile +119 -0
- data/app/cells/decidim/geo/content_blocks/geo_maps/show.erb +15 -0
- data/app/cells/decidim/geo/content_blocks/geo_maps_cell.rb +114 -0
- data/app/cells/decidim/geo/content_blocks/geo_maps_settings_form_cell.rb +14 -0
- data/app/cells/decidim/geo/geo_collection_map/show.erb +4 -0
- data/app/cells/decidim/geo/geo_collection_map_cell.rb +102 -0
- data/app/commands/decidim/admin/create_scope.rb +56 -0
- data/app/commands/decidim/admin/create_scope_type.rb +47 -0
- data/app/commands/decidim/admin/update_scope.rb +60 -0
- data/app/commands/decidim/admin/update_scope_type.rb +62 -0
- data/app/commands/decidim/geo/admin/create_shapefile.rb +51 -0
- data/app/commands/decidim/geo/admin/update_geo_config.rb +54 -0
- data/app/commands/decidim/geo/command.rb +14 -0
- data/app/controllers/decidim/admin/scopes_controller.rb +115 -0
- data/app/controllers/decidim/geo/admin/application_controller.rb +21 -0
- data/app/controllers/decidim/geo/admin/geo_configs_controller.rb +44 -0
- data/app/controllers/decidim/geo/admin/shapefiles_controller.rb +41 -0
- data/app/controllers/decidim/geo/application_controller.rb +13 -0
- data/app/controllers/decidim/geo/shapefile_controller.rb +11 -0
- data/app/forms/decidim/admin/scope_form.rb +43 -0
- data/app/forms/decidim/admin/scope_type_form.rb +27 -0
- data/app/forms/decidim/geo/admin/geo_config_form.rb +20 -0
- data/app/forms/decidim/geo/admin/shapefile_form.rb +23 -0
- data/app/helpers/decidim/admin/scopes_helper.rb +72 -0
- data/app/jobs/decidim/geo/shp2pgsql_job.rb +14 -0
- data/app/models/decidim/debates/debate.rb +226 -0
- data/app/models/decidim/geo/application_record.rb +10 -0
- data/app/models/decidim/geo/geo_config.rb +28 -0
- data/app/models/decidim/geo/shapedata.rb +23 -0
- data/app/models/decidim/geo/shapefile.rb +27 -0
- data/app/models/decidim/geo/space_location.rb +16 -0
- data/app/models/decidim/scope.rb +111 -0
- data/app/models/decidim/scope_type.rb +26 -0
- data/app/overrides/decidim/assemblies/admin/assemblies/_form/insert_location_form.html.erb.deface +13 -0
- data/app/overrides/decidim/assemblies/assemblies/show/insert_location.html.erb.deface +7 -0
- data/app/overrides/decidim/participatory_processes/admin/participatory_processes/_form/insert_location_form.html.erb.deface +13 -0
- data/app/overrides/decidim/participatory_processes/participatory_process_groups/show/insert_map.html.erb.deface +6 -0
- data/app/overrides/layouts/decidim/_assembly_header/insert_map.html.erb.deface +25 -0
- data/app/overrides/layouts/decidim/_process_header/insert_map.html.erb.deface +22 -0
- data/app/overrides/layouts/decidim/_wrapper/insert_map.html.erb.deface +5 -0
- data/app/overrides/remove_default_meetings_map.rb +4 -0
- data/app/overrides/remove_default_proposals_map.rb +4 -0
- data/app/packs/entrypoints/decidim_geo.js +3 -0
- data/app/packs/images/decidim/geo/not-geolocated.svg +3 -0
- data/app/packs/src/decidim/geo/actions/index.js +25 -0
- data/app/packs/src/decidim/geo/api/index.js +53 -0
- data/app/packs/src/decidim/geo/api/queries.js +77 -0
- data/app/packs/src/decidim/geo/bootstrap.js +6 -0
- data/app/packs/src/decidim/geo/index.js +101 -0
- data/app/packs/src/decidim/geo/models/configStore.js +44 -0
- data/app/packs/src/decidim/geo/models/dropdownFilterStore.js +65 -0
- data/app/packs/src/decidim/geo/models/filterStore.js +121 -0
- data/app/packs/src/decidim/geo/models/geoDatasourceNode/GeoDatasourceNode.js +124 -0
- data/app/packs/src/decidim/geo/models/geoDatasourceNode/index.js +1 -0
- data/app/packs/src/decidim/geo/models/geoScope/GeoScope.js +128 -0
- data/app/packs/src/decidim/geo/models/geoScope/index.js +1 -0
- data/app/packs/src/decidim/geo/models/geoStore.js +118 -0
- data/app/packs/src/decidim/geo/models/pointStore.js +134 -0
- data/app/packs/src/decidim/geo/models/scopeDropdownStore.js +20 -0
- data/app/packs/src/decidim/geo/ui/DrawerDetail/fallback.js +42 -0
- data/app/packs/src/decidim/geo/ui/DrawerDetail/index.js +2 -0
- data/app/packs/src/decidim/geo/ui/DrawerDetail/meetings.js +75 -0
- data/app/packs/src/decidim/geo/ui/DrawerMenuItem/fallback.js +45 -0
- data/app/packs/src/decidim/geo/ui/DrawerMenuItem/index.js +2 -0
- data/app/packs/src/decidim/geo/ui/DrawerMenuItem/meetings.js +62 -0
- data/app/packs/src/decidim/geo/ui/createClasses.js +7 -0
- data/app/packs/src/decidim/geo/ui/createCustomMarker.js +14 -0
- data/app/packs/src/decidim/geo/ui/createDomElement.js +2 -0
- data/app/packs/src/decidim/geo/ui/createDrawer.js +170 -0
- data/app/packs/src/decidim/geo/ui/createDrawerActions.js +197 -0
- data/app/packs/src/decidim/geo/ui/createFilterDropdown.js +320 -0
- data/app/packs/src/decidim/geo/ui/createGeoScopeLayer.js +20 -0
- data/app/packs/src/decidim/geo/ui/createGeoScopeMenuItem.js +8 -0
- data/app/packs/src/decidim/geo/ui/createNodeMarker.js +9 -0
- data/app/packs/src/decidim/geo/ui/createNodeMenuItem.js +13 -0
- data/app/packs/src/decidim/geo/ui/index.js +8 -0
- data/app/packs/src/decidim/geo/ui/initMap.js +22 -0
- data/app/packs/src/decidim/geo/utils/index.js +30 -0
- data/app/packs/src/decidim/geo/utils/saveConfig.js +15 -0
- data/app/packs/stylesheets/decidim/geo/_geo.scss +2 -0
- data/app/packs/stylesheets/decidim/geo/geo/_decidim_geo_decidimGeo.scss +476 -0
- data/app/packs/stylesheets/decidim/geo/geo/_decidim_geo_override.scss +65 -0
- data/app/permissions/decidim/geo/admin/permissions.rb +24 -0
- data/app/permissions/decidim/geo/permissions.rb +15 -0
- data/app/uploaders/decidim/geo/shapefile_uploader.rb +14 -0
- data/app/validators/geocoding_validator.rb +30 -0
- data/app/views/decidim/admin/scope_types/_form.html.erb +10 -0
- data/app/views/decidim/admin/scope_types/index.html.erb +46 -0
- data/app/views/decidim/admin/scopes/_form.html.erb +20 -0
- data/app/views/decidim/admin/scopes/index.html.erb +55 -0
- data/app/views/decidim/geo/admin/geo_configs/_form.html.erb +47 -0
- data/app/views/decidim/geo/admin/geo_configs/index.html.erb +8 -0
- data/app/views/decidim/geo/admin/shapefiles/_form.html.erb +29 -0
- data/app/views/decidim/geo/admin/shapefiles/index.html.erb +38 -0
- data/app/views/decidim/geo/admin/shapefiles/new.html.erb +8 -0
- data/app/views/layouts/decidim/decidim_geo/admin/application.html.erb +19 -0
- data/config/assets.rb +9 -0
- data/config/i18n-tasks.yml +10 -0
- data/config/locales/de.yml +102 -0
- data/config/locales/en.yml +108 -0
- data/config/locales/fr.yml +102 -0
- data/db/migrate/20221019184712_add_postgis_extension_to_database.rb +5 -0
- data/db/migrate/20221025195520_create_decidim_geo.rb +22 -0
- data/db/migrate/20231013082325_create_decidim_geo_config.rb +11 -0
- data/db/migrate/20231206115531_add_spaces_config_to_decidim_geo_configs.rb +6 -0
- data/db/migrate/20240309004347_add_organization_to_shapefiles.rb +6 -0
- data/db/migrate/20240326052727_create_space_locations.rb +18 -0
- data/lib/decidim/api/geo_config_type.rb +15 -0
- data/lib/decidim/api/geo_coordinates_type.rb +22 -0
- data/lib/decidim/api/geo_datasource_type.rb +147 -0
- data/lib/decidim/api/geo_dates_type.rb +15 -0
- data/lib/decidim/api/geo_query_extension.rb +25 -0
- data/lib/decidim/api/geo_scope_api_type.rb +26 -0
- data/lib/decidim/api/geo_shapedata_type.rb +18 -0
- data/lib/decidim/api/geo_shapefile_type.rb +22 -0
- data/lib/decidim/api/input_filters/assembly_input_filter.rb +13 -0
- data/lib/decidim/api/input_filters/geo_datasource_input_filter.rb +18 -0
- data/lib/decidim/api/input_filters/geoencoded_input_filter.rb +13 -0
- data/lib/decidim/api/input_filters/has_scopeable_input_filter.rb +17 -0
- data/lib/decidim/api/input_filters/process_input_filter.rb +13 -0
- data/lib/decidim/api/input_filters/resource_type_input_filter.rb +13 -0
- data/lib/decidim/api/input_filters/scope_input_filter.rb +13 -0
- data/lib/decidim/api/input_filters/time_input_filter.rb +13 -0
- data/lib/decidim/api/meetings_input_filter.rb +14 -0
- data/lib/decidim/api/query_extension.rb +320 -0
- data/lib/decidim/api/shapefile_query_extention.rb +18 -0
- data/lib/decidim/api/shapefile_type.rb +18 -0
- data/lib/decidim/decidim_geo/admin.rb +10 -0
- data/lib/decidim/decidim_geo/admin_engine.rb +69 -0
- data/lib/decidim/decidim_geo/api.rb +23 -0
- data/lib/decidim/decidim_geo/engine.rb +58 -0
- data/lib/decidim/decidim_geo/load_shp/app_load_shp.rb +85 -0
- data/lib/decidim/decidim_geo/space_location/assembly_create_command_override.rb +26 -0
- data/lib/decidim/decidim_geo/space_location/assembly_form_override.rb +33 -0
- data/lib/decidim/decidim_geo/space_location/assembly_update_command_override.rb +21 -0
- data/lib/decidim/decidim_geo/space_location/participatory_process_command_override.rb +21 -0
- data/lib/decidim/decidim_geo/space_location/participatory_process_form_override.rb +33 -0
- data/lib/decidim/decidim_geo/space_location/space_override.rb +15 -0
- data/lib/decidim/decidim_geo/test/factories.rb +13 -0
- data/lib/decidim/decidim_geo/version.rb +14 -0
- data/lib/decidim/decidim_geo.rb +25 -0
- data/lib/tasks/decidim_geo_webpacker_tasks.rake +61 -0
- metadata +335 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
class CreateDecidimGeo < ActiveRecord::Migration[6.0]
|
2
|
+
def change
|
3
|
+
create_table :decidim_geo_shapefiles do |t|
|
4
|
+
t.string :title, null: false
|
5
|
+
t.string :description, null: true
|
6
|
+
t.string :shapefile, null: false
|
7
|
+
t.belongs_to :decidim_scope_types, index: true, foreign_key: true, null: true
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
create_table :decidim_geo_shapefile_datas do |t|
|
13
|
+
t.belongs_to :decidim_geo_shapefiles, index: true, foreign_key: true
|
14
|
+
t.jsonb :data
|
15
|
+
t.multi_polygon :geom
|
16
|
+
|
17
|
+
t.belongs_to :decidim_scopes, index: true, foreign_key: true, null: true
|
18
|
+
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# This migration comes from decidim_geo (originally 20231012094655)
|
2
|
+
class CreateDecidimGeoConfig < ActiveRecord::Migration[6.0]
|
3
|
+
def change
|
4
|
+
create_table :decidim_geo_configs do |t|
|
5
|
+
t.float :longitude, null: true
|
6
|
+
t.float :latitude, null: true
|
7
|
+
t.integer :zoom, null: true
|
8
|
+
t.string :tile, null: true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
class AddSpacesConfigToDecidimGeoConfigs < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
add_column :decidim_geo_configs, :only_processes, :boolean, default: false, null: false
|
4
|
+
add_column :decidim_geo_configs, :only_assemblies, :boolean, default: false, null: false
|
5
|
+
end
|
6
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateSpaceLocations < ActiveRecord::Migration[6.1]
|
2
|
+
def change
|
3
|
+
create_table :decidim_geo_space_locations do |t|
|
4
|
+
t.bigint :decidim_geo_space_id
|
5
|
+
t.string :decidim_geo_space_type
|
6
|
+
t.string :address
|
7
|
+
t.float :latitude
|
8
|
+
t.float :longitude
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index :decidim_geo_space_locations,
|
13
|
+
[:decidim_geo_space_type, :decidim_geo_space_id],
|
14
|
+
unique: true,
|
15
|
+
name: "decidim_geo_space_poly_idx"
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class GeoConfigType < Decidim::Api::Types::BaseObject
|
6
|
+
|
7
|
+
description "A geo admin config"
|
8
|
+
|
9
|
+
field :zoom, Float, null: false
|
10
|
+
field :longitude, Float, null: false
|
11
|
+
field :latitude, Float, null: false
|
12
|
+
field :tile, String, null: true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
# This type represents a Decidim's global property.
|
6
|
+
class GeoCoordinatesType < Decidim::Api::Types::BaseObject
|
7
|
+
description "Physical coordinates for a location"
|
8
|
+
|
9
|
+
field :latitude, GraphQL::Types::Float, "Latitude of this coordinate", null: true
|
10
|
+
field :longitude, GraphQL::Types::Float, "Longitude of this coordinate", null: true
|
11
|
+
|
12
|
+
def latitude
|
13
|
+
object[:latitude]
|
14
|
+
end
|
15
|
+
|
16
|
+
def longitude
|
17
|
+
object[:longitude]
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_storage'
|
4
|
+
|
5
|
+
module Decidim
|
6
|
+
module Geo
|
7
|
+
class GeoDatasourceType < Decidim::Api::Types::BaseObject
|
8
|
+
description "A datasource for all objects"
|
9
|
+
include Decidim::SanitizeHelper
|
10
|
+
field :type, String, null: false
|
11
|
+
field :id, ID, null: false
|
12
|
+
field :component_id, ID, null: true
|
13
|
+
field :participatory_space_id, ID, null: true
|
14
|
+
field :participatory_space_type, String, null: true
|
15
|
+
field :title, Decidim::Core::TranslatedFieldType, "The title for this title", null: true
|
16
|
+
field :short_description, Decidim::Core::TranslatedFieldType, "The short description for this short description", null: true
|
17
|
+
field :description, Decidim::Core::TranslatedFieldType, "The description for this description", null: true
|
18
|
+
field :banner_image, String, null: true
|
19
|
+
field :coordinates, Decidim::Geo::GeoCoordinatesType, "Physical coordinates for this object", null: true
|
20
|
+
field :start_time, Decidim::Core::DateTimeType, "The time this object starts", null: true
|
21
|
+
field :end_time, Decidim::Core::DateTimeType, "The time this object ends", null: true
|
22
|
+
field :scope, Decidim::Core::ScopeApiType, null: true
|
23
|
+
field :link, String, null: false
|
24
|
+
|
25
|
+
def type
|
26
|
+
object.class.name
|
27
|
+
end
|
28
|
+
|
29
|
+
def id
|
30
|
+
object.id
|
31
|
+
end
|
32
|
+
|
33
|
+
def component_id
|
34
|
+
object.component.id if object.respond_to?(:component)
|
35
|
+
end
|
36
|
+
|
37
|
+
def participatory_space_id
|
38
|
+
return object.component.participatory_space_id if object.respond_to?(:component)
|
39
|
+
end
|
40
|
+
|
41
|
+
def participatory_space_type
|
42
|
+
return object.component.participatory_space_type if object.respond_to?(:component)
|
43
|
+
end
|
44
|
+
|
45
|
+
def link
|
46
|
+
Decidim::ResourceLocatorPresenter.new(object).path(anchor: "DecidimGeo")
|
47
|
+
end
|
48
|
+
|
49
|
+
def title
|
50
|
+
return object.title if object.respond_to?(:title)
|
51
|
+
return object.name if object.respond_to?(:name)
|
52
|
+
end
|
53
|
+
|
54
|
+
def short_description
|
55
|
+
return truncate_translated(object.short_description, 250) if object.respond_to?(:short_description)
|
56
|
+
return truncate_translated(object.body, 250) if object.respond_to?(:body)
|
57
|
+
return truncate_translated(object.description, 250) if object.respond_to?(:description)
|
58
|
+
end
|
59
|
+
|
60
|
+
def description
|
61
|
+
return truncate_translated(object.body) if object.respond_to?(:body)
|
62
|
+
return truncate_translated(object.description) if object.respond_to?(:description)
|
63
|
+
end
|
64
|
+
|
65
|
+
def truncate_translated(value, chars=2800)
|
66
|
+
value.each do |key, v|
|
67
|
+
if v.is_a?(Hash)
|
68
|
+
value[key] = truncate_translated(v, chars)
|
69
|
+
else
|
70
|
+
value[key] =
|
71
|
+
Rails::Html::FullSanitizer.new.sanitize(
|
72
|
+
Decidim::HtmlTruncation.new(
|
73
|
+
Decidim::ContentProcessor.render(
|
74
|
+
v
|
75
|
+
),
|
76
|
+
max_length: 2800,
|
77
|
+
tail: "…",
|
78
|
+
count_tags: false,
|
79
|
+
count_tail: false,
|
80
|
+
tail_before_final_tag: false
|
81
|
+
).perform
|
82
|
+
).html_safe
|
83
|
+
end
|
84
|
+
end
|
85
|
+
value
|
86
|
+
end
|
87
|
+
|
88
|
+
def banner_image
|
89
|
+
return object.attached_uploader(:banner_image).url(only_path: true) if object.respond_to?(:banner_image)
|
90
|
+
return object.attachments.first.url if object.respond_to?(:attachments) && object.attachments.first
|
91
|
+
end
|
92
|
+
|
93
|
+
def coordinates
|
94
|
+
{latitude: latitude, longitude: longitude} if has_coordinates?
|
95
|
+
end
|
96
|
+
|
97
|
+
def start_time
|
98
|
+
object.start_time if object.respond_to?(:start_time)
|
99
|
+
end
|
100
|
+
|
101
|
+
def end_time
|
102
|
+
object.end_time if object.respond_to?(:end_time)
|
103
|
+
end
|
104
|
+
|
105
|
+
def latitude
|
106
|
+
return location.latitude if has_geo_location?
|
107
|
+
object.latitude
|
108
|
+
end
|
109
|
+
|
110
|
+
def longitude
|
111
|
+
return location.longitude if has_geo_location?
|
112
|
+
object.longitude
|
113
|
+
end
|
114
|
+
|
115
|
+
def geom
|
116
|
+
RGeo::GeoJSON.encode(object.shapedata.geom) if (object.respond_to?(:shapedata) && !object.shapedata.nil?)
|
117
|
+
end
|
118
|
+
|
119
|
+
def scope
|
120
|
+
object.scope if object.respond_to?(:scope)
|
121
|
+
end
|
122
|
+
|
123
|
+
def has_geo_location?
|
124
|
+
object.respond_to?(:decidim_geo_space_location)
|
125
|
+
end
|
126
|
+
|
127
|
+
def location
|
128
|
+
return nil unless has_geo_location?
|
129
|
+
object.decidim_geo_space_location
|
130
|
+
end
|
131
|
+
|
132
|
+
def has_coordinates?
|
133
|
+
(
|
134
|
+
has_geo_location? &&
|
135
|
+
!location.latitude.nil? &&
|
136
|
+
!location.longitude.nil?
|
137
|
+
) || (
|
138
|
+
object.respond_to?(:latitude) &&
|
139
|
+
object.respond_to?(:longitude) &&
|
140
|
+
!object.latitude.nil? &&
|
141
|
+
!object.longitude.nil?
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class GeoDatesType < Decidim::Api::Types::BaseObject
|
6
|
+
|
7
|
+
description "A geo content block config"
|
8
|
+
|
9
|
+
field :zoom, Integer, null: false
|
10
|
+
field :lng, Integer, null: false
|
11
|
+
field :lat, Integer, null: false
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Decidim
|
2
|
+
module Geo
|
3
|
+
module GeoQueryExtension
|
4
|
+
# Public: Extends a type with `decidim_geo`'s fields.
|
5
|
+
#
|
6
|
+
# type - A GraphQL::BaseType to extend.
|
7
|
+
#
|
8
|
+
# Returns nothing.
|
9
|
+
|
10
|
+
def self.included(type)
|
11
|
+
type.field :shapefiles, [Decidim::Geo::ShapefileType], description: "Return's information about the shapefiles", null: true
|
12
|
+
|
13
|
+
type.field :geo_config, Decidim::Geo::GeoConfigType, description: "Return's information about the geo config", null: true
|
14
|
+
end
|
15
|
+
|
16
|
+
def shapefiles
|
17
|
+
Decidim::Geo::Shapefile.all
|
18
|
+
end
|
19
|
+
|
20
|
+
def geo_config
|
21
|
+
Decidim::Geo::GeoConfig.geo_config_default
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class GeoScopeApiType < Decidim::Api::Types::BaseObject
|
6
|
+
description "A geo scope"
|
7
|
+
|
8
|
+
field :id, ID, null: false
|
9
|
+
field :name, Decidim::Core::TranslatedFieldType, "The graphql_name of this scope.", null: false
|
10
|
+
|
11
|
+
field :children, [Decidim::Geo::GeoScopeApiType, { null: true }], "Descendants of this scope", null: false
|
12
|
+
field :parent, Decidim::Geo::GeoScopeApiType, "This scope's parent scope.", null: true
|
13
|
+
|
14
|
+
field :geom, GraphQL::Types::JSON, null: true
|
15
|
+
|
16
|
+
def geom
|
17
|
+
RGeo::GeoJSON.encode(object.shapedata.geom) unless object.shapedata.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def name
|
21
|
+
object.name
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
# GeoShapedataType
|
6
|
+
class GeoShapedataType < Decidim::Api::Types::BaseObject
|
7
|
+
description "A shapefile data"
|
8
|
+
|
9
|
+
field :id, ID, null: false
|
10
|
+
field :data, GraphQL::Types::JSON, null: true
|
11
|
+
field :geom, GraphQL::Types::JSON, null: true
|
12
|
+
|
13
|
+
def geom
|
14
|
+
RGeo::GeoJSON.encode(object.geom)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class GeoShapefileType < Decidim::Api::Types::BaseObject
|
6
|
+
|
7
|
+
description "A shapefile"
|
8
|
+
|
9
|
+
field :id, ID, null: false
|
10
|
+
field :title, String, null: false
|
11
|
+
field :description, String, null: true
|
12
|
+
field :shapefile, String, null: false
|
13
|
+
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
|
14
|
+
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
|
15
|
+
|
16
|
+
def shapefile
|
17
|
+
object.shapefile.path
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class AssemblyInputFilter < Decidim::Core::BaseInputFilter
|
6
|
+
|
7
|
+
graphql_name "AssemblyFilter"
|
8
|
+
description "A type used for filtering geo datasources by Assembly"
|
9
|
+
|
10
|
+
argument :assembly_id, type: ID, description: "List results by assembly_id", required: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class GeoDatasourceInputFilter < Decidim::Core::BaseInputFilter
|
6
|
+
|
7
|
+
graphql_name "GeoDatasourceFilter"
|
8
|
+
description "A type used for filtering geo datasources"
|
9
|
+
|
10
|
+
argument :assembly_filter, Decidim::Geo::AssemblyInputFilter, description: "List results by Assembly", required: false
|
11
|
+
argument :process_filter, Decidim::Geo::ProcessInputFilter, description: "List results by ParticipatoryProcess", required: false
|
12
|
+
argument :scope_filter, Decidim::Geo::ScopeInputFilter, description: "List results by Scope", required: false
|
13
|
+
argument :resource_type_filter, Decidim::Geo::ResourceTypeInputFilter, description: "List results by Resource Type", required: false
|
14
|
+
argument :time_filter, type: Decidim::Geo::TimeInputFilter, description: "List results by time", required: false
|
15
|
+
argument :geoencoded_filter, type: Decidim::Geo::GeoencodedInputFilter, description: "List results if they are geoencoded", required: false
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class GeoencodedInputFilter < Decidim::Core::BaseInputFilter
|
6
|
+
|
7
|
+
graphql_name "GeoencodedFilter"
|
8
|
+
description "A type used for filtering geo datasources if they are geoencoded"
|
9
|
+
|
10
|
+
argument :geoencoded, type: Boolean, description: "List results by time", required: true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
module HasScopeableInputFilter
|
6
|
+
def self.included(child_class)
|
7
|
+
child_class.argument :scope_id,
|
8
|
+
type: GraphQL::Types::ID,
|
9
|
+
description: "List result by Scope using decidim_scope_id",
|
10
|
+
required: false,
|
11
|
+
prepare: lambda { |scope_id, _ctx|
|
12
|
+
{ decidim_scope_id: scope_id }
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class ProcessInputFilter < Decidim::Core::BaseInputFilter
|
6
|
+
|
7
|
+
graphql_name "ProcessFilter"
|
8
|
+
description "A type used for filtering geo datasources by Participatory Process"
|
9
|
+
|
10
|
+
argument :process_id, type: ID, description: "List results by process_id", required: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class ResourceTypeInputFilter < Decidim::Core::BaseInputFilter
|
6
|
+
|
7
|
+
graphql_name "ResourceTypeFilter"
|
8
|
+
description "A type used for filtering geo datasources by Resource Type"
|
9
|
+
|
10
|
+
argument :resource_type, type: String, description: "List results by resource_type", required: false
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class ScopeInputFilter < Decidim::Core::BaseInputFilter
|
6
|
+
|
7
|
+
graphql_name "ScopeFilter"
|
8
|
+
description "A type used for filtering geo datasources by scope"
|
9
|
+
|
10
|
+
argument :scope_id, type: Integer, description: "Retrieve search only on this scope", required: true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Geo
|
5
|
+
class TimeInputFilter < Decidim::Core::BaseInputFilter
|
6
|
+
|
7
|
+
graphql_name "TimeFilter"
|
8
|
+
description "A type used for filtering geo datasources by time: past, future, active"
|
9
|
+
|
10
|
+
argument :time, type: ID, description: "List results by time", required: true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module Meetings
|
5
|
+
class MeetingsInputFilter < Decidim::Core::BaseInputFilter
|
6
|
+
include Decidim::Core::HasPublishableInputFilter
|
7
|
+
include Decidim::Core::HasHastaggableInputFilter
|
8
|
+
include Decidim::Geo::HasScopeableInputFilter
|
9
|
+
|
10
|
+
graphql_name "MeetingsFilter"
|
11
|
+
description "A type used for filtering meetings"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|