Make maps actually configurable#6340
Merged
tramuntanal merged 159 commits intodecidim:developfrom Oct 1, 2020
Merged
Conversation
- Split the map scripts to "default" (OSM) and "here" (HERE Maps) - Refactor the main map script to trigger an event for the map element instead of assuming using always HERE Maps - Add the new maps assets to the core manifests
Contributor
|
Oh wow 😍 |
Contributor
|
This is great @ahukkanen ! |
Contributor
|
This is amazing, nice job @ahukkanen! |
Member
|
Awesome!! I think we all agree that this was a very much needed and welcome feature, thanks @ahukkanen 👏 👏 |
The address key is now required for the autocomplete functionality.
tramuntanal
previously approved these changes
Sep 25, 2020
Contributor
tramuntanal
left a comment
There was a problem hiding this comment.
Huge work here @ahukkanen !
Contributor
|
Let's wait for the final @decidim/product ok before merging |
Contributor
Member
Contributor
|
@ahukkanen there's a small conflict in the changelog that I can't resolve because the PR is in a fork. |
Contributor
Author
|
@tramuntanal Merged with develop. |
tramuntanal
reviewed
Oct 1, 2020
Contributor
tramuntanal
left a comment
There was a problem hiding this comment.
There's been a bad merge.
You can test with
bundle exec mdl CHANGELOG.md
tramuntanal
approved these changes
Oct 1, 2020
Contributor
|
Hurray!!! 🎉🎉🎉🎉🎉 Huge work here @ahukkanen ! |
Contributor
|
Thanks @ahukkanen ! Congrats !! |
roxanaopr
pushed a commit
to i-need-another-coffee/decidim
that referenced
this pull request
Oct 15, 2020
* Add backend for configuring maps * Add autoloading for the Decidim::Map module * Refactor frontend map scripts for the new API - Split the map scripts to "default" (OSM) and "here" (HERE Maps) - Refactor the main map script to trigger an event for the map element instead of assuming using always HERE Maps - Add the new maps assets to the core manifests * Refactor the MapHelper to use the new Decidim::Map module * Refactor the static map generator to use the new Decidim::Map module * Refactor the geocoding validator to use the new Decidim::Map module * Refactor the form classes to use the new Decidim::Map module * Refactor the views to use the new Decidim::Map module * Display the header_snippets content in the document <head> element * Update the initializer and secrets templates for the new maps API * Add tests for the new Decidim::Map module * Update documentation for the map functionality * Update the code comments from the maps documentation * Add CHANGELOG entry * Remove reference to Geoapify * Lint the maps documentation * Add documentation integrating to additional map services * Remove utility configuration for an unregistered category * Fix and generalize the map setup for the specs * Fix issue with the static map generator * Fix static map generator tests * Add upgrade note about the maps configuration * Fix code reference links in the docs * Fix comments spec after changing specs map configuration to new style * Fix typo in comment * Refine the CHANGELOG upgrade notes * Update maps documentation - Refine some of the writing - Add a section about disabling specific map services * Update and refine the maps customization documentation * Refine the maps documentation (fix typo, make order more logic) * Add reference to the initializer file for OSM configuration docs * Refer to the custom map providers documentation in maps docs * Remove redundant check for the geocoding availability * Display meetings maps only if static map service is available * Add ability to query availability of multiple map services * Display meetings static maps only if geocoding is also available Check for the availability of both map services, geocoding and static maps before displaying the static map images for the meetings. * Pass the configured language to the geocoder gem * Run the geocoding initializer after the config initializers are load * Pass record specific geocoding through the Decidim API This customizes the Geocoder gem's record specific geocoding in order to pass the search requests through Decidim's own API which configures the geocoder for each search. * Remove unused http_headers option from the geocoded_by calls This option did really nothing. See documentation at: https://github.com/alexreisner/geocoder#advanced-model-configuration Supported parameters: `:lookup`, `:ip_lookup`, `:language`, and `:params`. * Add tests for the Geocoder gem's customizations * Fix Rubocop violation * Fix the geocoding utility spec after passing the language option * Pass the whole helper block to the map builder * Allow passing the maps API key to OSM map tile layer configuration * Add passing API key to OSM tile layer config to the example * Update the maps customization documentation - Document how to pass the API key to the tile layer configuration for normal OSM style maps - Correct some typos * Update maps documentation - Change the position of the first second level heading - Add example how to pass the API key to the OSM tile layer configuration * Refine the maps customization documentation * Refine maps docs * Update maps customization documentation Correct the documentation for the geocoding utility's `search()` method about the returned object types. * Update maps documentation - Add a section about global geocoder configurations - Clarify some parts of the documentation about enabling the functionality for the components * Fix the meetings map The map helper needs to inject the map JS/CSS snippets into the document head with `content_for`. Because of this, we need to pass the view where the map is displayed in as a context variable for the map cell. * Get rid of inline JS for map builders and refactor the frontend JS - Refactor the frontend JS in order to make map controlling more modular * Create a new controller class which controls the leaflet map * Create a controller registry for fetching the different controller instances anywhere in the app * Simplify the map initialization code with the controller - Move the map builder inline javascript to the provider specific map scripts - Refactor passing the data from the backend to the frontend map instances to allow full frontend configuration * Refactor the specs after refactoring the map configuring * Update the manifest paths for map providers * Remove unnecessary comments * Remove double configuration of the legacy style maps * Refactor legacy maps support (not enabled by default) If the system needs legacy maps support, there is now an error message thrown asking to update or indicating how to enable it. * Add legacy map support to the core JS manifets * Fix and simplify passing configurations to the map element * Pass always the default popup template ID to the map builder * Trigger a ready event for the maps * Rename map settings to config (to avoid confusion) * Rename mapData to mapConfig * Fix issue with the map when no markers are provided in the config * Fix map specs after the front-end refactoring and parameter renaming * Fix specs broken after maps frontend refactoring * Remove unnecessary map_id from the dynamic map builder attr_reader * Pass the view context to the meetings map The map display needs the view context in order to add extra snippets for the map to the page <head>. * Allow displaying multiple maps on a single page * Fix maps header snippets for the cells The content_for method is not available in the cells which is why we need a special snippets registry during the view rendering where snippets can be added and fetched from. This works in the controller level which can be delegated to cell methods. * Implement a display method for the snippets * Add specs for the snippets class * Include NeedsSnippets for the devise controllers * Change snippets to be defined first time it is requested Before the snippet was requested only during the before_action callback which caused a problem when called prior to those callbacks have run. * Fix spec failing at specific dates * Fix typo * Remove unnecessary requires * Simplify map provider frontend initialization code * Styling: ensure snippets array is always one dimensional Just a styling issue, does not really affect the display or the functionality. * Name the map JS files correctly * Introduce a frontend map factory concept Decouple the map specific functionality to individual map type specific controllers and allow customizing the creation of the map controllers by overriding the a factory method. This makes it easier to create additional map types and extend the maps functionality in external contexts. * Refactor the map controllers code Separate the "markers" map controller to its own file. * Move this.markerClusters variable to the markers map controller * Apply the refactoring changes to the legacy map script Call the map factory method instead of creating the map controller manually in the legacy map script. * Remove unnecessary requires * Define the correct icon size for the map marker icons * Simplify map category disabling * Update the tests after changing how to disable a map category * Update the maps documentation about disabling a map category * Fix rubocop violations * Fix a bug in the markers controller In case the markers were cleared from the map, it did not previously add the layer back for the new markers. * Refactor part of the dynamic map utility Generalize parts of the dynamic map utility in order to provide similar front-end builder functionality for other utilities as well. * Add geocoding autocompletion functionality for address fields Generalize the autocompletion functionality for different map service providers. * Make the geocoding_field helper available through the form builder * Apply the geocoding autocomplete functionality to proposals * Add the geocoding JS files to the core assets manifest * Fix the map spec after introduction of the autocomplete map utility * Rename the geocodign provider JS files with .js.es6 * Better styling of the tribute elements * Add documentation about geocoding autocompletion * Unify maps documentation JS code block languages * Add tests for the maps geocoding autocomplete * Generalize attaching geocoding autocompletion to a front-end field * Map the autocomplete field in the form builder's field method This will take care of adding the label to the field. * Improve the styling of the geocoding autocompletion dropdown * Add autocompletion to proposals admin * Fix double geocoding if the address is already geocoded If the address is geocoded in the front-end, the back-end does not need to do another geocoding. * Add the geocoding field to the proposals admin * Add the geocoding field to meetings admin * Make it possible to display geocoding fields at the admin panel * Apply the geocoding field to the front-end meetings form * Remove unnecessary comment * Fix admin proposal form spec when no address is provided * Apply geocoding field to meeting copies * Apply geocoding field to the collaborative draft edit views * Add tests for front-end geocoding * Fix proposal form spec This reverts the spec when the address is not present on the proposal form. * Fix geocoding autocomplete spec after change of the test API url * Fix proposal forms spec for both admin and non-admin cases * Update docs/services/maps.md Co-authored-by: Oliver Valls <199462+tramuntanal@users.noreply.github.com> * Update CHANGELOG.md Co-authored-by: Oliver Valls <199462+tramuntanal@users.noreply.github.com> * Remove the PR change note from CHANGELOG * Add method documentation for front-end attachGeocoding Explain how to use `Decidim.attachGeocoding()` and why it matters. * Fix comment for front-end `Decidim.attachGeocoding()` * Add a note about `Decidim.attachGeocoding()` to the maps docs * Dynamically create a map ID for the dynamic map if not defined * Move the `createIcon()` method to the base map controller * Implement a static map fallback with the dynamic map In case the map service provider does not offer static map images, use the dynamic maps to create a similarly styled map element. * Add documentation notes about static map fall backs Adds notes for the static maps that Decidim will fall back to using the dynamic map utility in case the service provider does not offer static map images. * Add a maps documentation note about static map fall backs * Remove unused dependency from the autocomplete utility * Change HTTPParty to Faraday * Move the map system specs under the system folder * Disable browser autocompletion for the geocoding autocomplete field * Improve the front-end geocoder - Move autocomplete address formatting to its own JS utility file. - Make it possible to configure the address format for the HERE and Photon front-end geocoders - Make it possible to configure a minimum query length in order to save some API quota on the geocoding requests - Change how the builder configurations are passed for the front-end map utilities. Now all configurations are passed by default to the front-end elements. This is applied to the autocomplete utilities. * Add documentation how to customize the autocomplete address format * Fix map autocomplete utility specs for HERE and OSM * Disable self-XSS warning when the messages are not defined * Fix geocoding autocomplete front-end specs * Fix HERE front-end autocomplete spec missing expected attribute The address key is now required for the autocomplete functionality. * Fix shared proposal examples for the address field tests * Fix issue with CHANGELOG Co-authored-by: Oliver Valls <199462+tramuntanal@users.noreply.github.com>
Leusev
pushed a commit
that referenced
this pull request
Dec 2, 2020
* Remove Markdown doc * Add documentation with Antora (AsciiDoc format - .adoc) Adds sections: * configure * customize * develop * install * services Also adds: * a README explaining the relationship with the documentation repository available in https://github.com/decidim/documentation * antora metadata file so we can build these sections in the same website * Fix Antora name for docs * Rename advanced pages to Concerns * Add Authorizations customize from module's README * Move 'add_authorizable_action' to 'permissions' * Move 'adding_fixtures_aka_dummy_content' to 'components' * Move 'how_to_create_a_module' to 'components' * Remove 'upgrading', now it's in 'update' * Install guide: fix error in 'whatever' gem (it's 'whenever') * Install guide: fix error in RAILS_ENV order in commands * Install guide: fix command for open_data export * Install guide: fix link to Contribution guide * Develop guide: add example apps * Architecture docs Add first version of c4model diagrams with PlantUML * https://c4model.com/ * https://plantuml.com/ * https://github.com/RicardoNiepel/C4-PlantUML * Add some explanation of modules types (with Components link) * Configure: ENV VARS and Initializer This moves ENV VARS configuration docs to its own page. We also create a new page for explaining Decidim's initializer settings (config/initializer/decidim.rb). For the moment is mostly a copy paste with nice formating, but the idea is to expand it. * Sync "Make maps actually configurable" by @ahukkanen Extracted from #6340 * Sync "Templates module" by @verarojman Extracted from #6247 * Sync "Configure Decidim Bulletin Board" by @leio10 Extracted from #6420 * Sync "Add a task to fix locale issues" by @microstudi Extracted from #6510 * Update versions in SECURITY.adoc * Convert CONTRIBUTING.md to AsciiDoc * Convert README.md to AsciiDoc * Clarify CONTRIBUTING and links to docs site * Remove Markdown linter CI * Sync "Update documentation for `decidim` OAuth social provider" by @tramuntanal Extracted from #6607 * Sync "Generate changelog entries" by @tramuntanal Extracted from #6794 * Fix link in oauth.adoc * Sync "Improve moderation panel" by @beagleknight Extracted from #6677 * Removes trailing whitespaces Co-authored-by: Oliver Valls <199462+tramuntanal@users.noreply.github.com>
12 tasks
12 tasks
12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


🎩 What? Why?
For as long as I remember, the Geocoding documentation page has claimed the following:
This is not really true because you cannot use OSM based services without heavy core customization of Decidim. HERE Maps is currently even hard coded to the map functionality currently plugged to Decidim.
Having HERE Maps as a hard requirement for the open source framework does not really seem to make any sense. It has been also reported that HERE Maps does not work for all users.
This pull request finally makes the Decidim maps and geocoding configurable and provides a standardized API to plug any possible service to the following map functionality in Decidim:
Later on, this same API could be used e.g. to provide such functionalities as geocoding autocompletion(geocoding autocompletion is now included in this PR) or something else related to the maps.In addition, this pull request also adds the ability to plug Decidim to OSM based map servers, either by self hosting them or by buying them as a service from a commercial vendor. It is also possible to add new providers though the new API.
For further information, please read the updated documentation at:
https://github.com/decidim/decidim/tree/develop/docs/services/maps.md
Furthermore, here is some documentation about the maps API and how to build your own providers for the map functionality:
https://github.com/decidim/decidim/tree/develop/docs/customization/maps.md
📌 Related Issues
📋 Subtasks
CHANGELOGupgrade notes, if required