Fix issues with overriding maps and loading Leaflet#11105
Merged
andreslucena merged 6 commits intodecidim:developfrom Jul 5, 2023
Merged
Fix issues with overriding maps and loading Leaflet#11105andreslucena merged 6 commits intodecidim:developfrom
andreslucena merged 6 commits intodecidim:developfrom
Conversation
andreslucena
requested changes
Jun 29, 2023
Member
andreslucena
left a comment
There was a problem hiding this comment.
Tried it locally and it works 👌🏽
Outstanding work with the "Testing" explanation, it'd be difficult if I didn't have that.
I have a couple of suggestions and this would be ready to be merged.
This was referenced Jul 5, 2023
entantoencuanto
added a commit
that referenced
this pull request
Jul 7, 2023
* feature/redesign: Redesign: replace cells with redesigned versions if present and update references (#11123) Remove duplicated constant Simplify logic Enable specs Fix leaflet fix failing specs Fix issues with overriding maps and loading Leaflet (#11105) Update decidim-proposals/app/views/decidim/proposals/proposals/new.html.erb Update decidim-comments/lib/decidim/comments/comments_helper.rb Update decidim-assemblies/spec/system/filter_assemblies_spec.rb Update decidim-assemblies/spec/system/filter_assemblies_spec.rb Document how to work locally with Elections/Votings (#10870) Fix Admin dashboard disappear if you are in Trustee Zone (#11111) Fix Shakapacker upgrade does not work for existing instances (#10814) Fix for sending welcome emails for new participants (#10991) Fix seeded trustees (#10964)
andreslucena
pushed a commit
that referenced
this pull request
Jul 18, 2023
* Fix issues with overriding maps and loading Leaflet * Remove commented configuration * Prevent external requests during the custom map spec * Test that the custom map also shows the marker correctly * Correct the dummy tiles route for OSM maps * Apply review recommendations
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?
There are several problems when trying to override the maps currently:
Lconstant.drag_markers.jsmap controller which is incorrect as we do not want this file to be included for non-Here providers.This PR fixes the problems by fixing the map assets and the order of inclusion when the map element is created.
In this PR I am also adding a custom map factory within the
decidim-devgem because this file does not need to be bundled to the production applications, this is why I added it todecidim-dev. This is only used to test that the map factory can be customized and is working correctly. This has to be tested end-to-end why it needs its own asset pack.This fix should be also backported but it is not straight forward as the map inclusion strategy has changed due to Shakapacker. I can work on the backports once this is merged.
📌 Related Issues
Testing
To see the loading error:
developand make sure your development app is up to datedecidim-devgem add the following files from this PR:decidim-dev/app/packs/entrypoints/decidim_dev_test_custom_map.jsdecidim-dev/app/packs/src/decidim/dev/test/custom_map_factory.jsassets.rbconfiguration of thedecidim-devgem (as in this PR)config.maps = { provider: :here, api_key: "12345" }within the Decidim initializerThe snippet to use the custom map within the proposals index page (for instance):
After this error is solved as per this PR, reload that page and see the map working correctly without errors. Note that you may have to adjust the content security policy depending on your map configuration.
Also after this PR is applied, you should see a couple of paragraphs of text added to the bottom of the page where the map is added to indicate that the map customization is working correctly. There is a spec added in this PR to test that for both OSM and Here.
The added system spec to the
decidim-devgem is testing this exact case for both OSM and Here.📷 Screenshots
This is a screenshot of the developer console when trying to load the custom map:

In text format for easier searching: