-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring/tobias 117 convert leaflet to js #137
Refactoring/tobias 117 convert leaflet to js #137
Conversation
@TheGrayStone: There is a method called |
Codecov Report
@@ Coverage Diff @@
## dev #137 +/- ##
==========================================
- Coverage 98.52% 95.58% -2.94%
==========================================
Files 25 25
Lines 406 408 +2
==========================================
- Hits 400 390 -10
- Misses 6 18 +12
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
Troubleshooting |
@TheGrayStone told me earlier that their team is also working on something similar, let's refrain from merging and putting too much additional work into this before they clarify here @hpi-swt2/rh21 |
fixes Places::DESTINATIONS variable being dumped into HTML (introduced in #102)
Co-authored-by: TheGrayStone <[email protected]> Co-authored-by: Julian Schmidt <[email protected]>
Thanks for the investigation! Could the following still help, perhaps?
|
The |
Fixed this! |
Coverage will increase with Issue #149, where we fix the tests that are currently only run locally (the features however work). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good
I could imagine that there still is a race condition and it just doesn't appear by chance in the current tests. You changed in 98d559e // these operations are executed in parallel
getView().then((view) => {
setView(view);
addTargetMarker();
});
getBuildings().then((buildingPolygons) => {
addPolygons(buildingPolygons);
});
getBuildingMarkers().then((buildingMarkers) => {
addMarkers(buildingMarkers);
}); to const view = await getView();
setView(view);
addTargetMarker();
const buildingPolygons = await getBuildings();
addPolygons(buildingPolygons);
const buildingMarkers = await getBuildingMarkers();
addMarkers(buildingMarkers); From my understanding this should be equivalent to (except rejections error handling): getView().then((view) => {
setView(view);
addTargetMarker();
getBuildings().then((buildingPolygons) => {
addPolygons(buildingPolygons);
getBuildingMarkers().then((buildingMarkers) => {
addMarkers(buildingMarkers);
});
});
}); I don't see how this could have fixed the errors... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 😄 We will have to change lots of code in the other pull requests (because they stiil use JS inside the .html.erb
file), but I'm glad this finally works!
app/javascript/packs/building_map.js
Outdated
import { displayRoute, setupMap } from './leafletMap.js'; | ||
|
||
let currentLocation; | ||
const YOUR_LOCATION_MAGIC_STRING = "Your location" // TODO: Change this!!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because we cannot execute Ruby code inside the JS file, right? It might be difficult to fix (and use the Ruby constant again), because afaik there is no such thing as a .js.erb
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't really pass things from ruby over to js. We might find a workaround, where we provide this thing from the server via an ajax request (like we did with the other constants) but maybe it won't be necessary due to the new UI which uses js as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AJAX just for getting a string constant seems a bit ugly (because we need new/separate endpoints for each constant), but I'm fine with leaving this as it is until we know how the new UI and translation is implemented. We should just keep this in mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using an Ajax call to get a string, you could also consider writing the value as a data
attribute into an HTML element in the .erb
template, which is read by the JS ($('.map').data('location')
), i.e. <div class="map" data-location="Your location"></div>
. Then the value is bound to the element that requires it. This pattern is sometimes called 'Unobtrusive JS': https://guides.rubyonrails.org/working_with_javascript_in_rails.html#unobtrusive-javascript
Co-authored-by: Julian Schmidt
It seemed like there was a race condition. We resolved it by skipping the respective tests for now. |
Refactor leaflet ruby gem to plain js. This merge will remove the map on the location show page, as communicated with team @hpi-swt2/apmw21. We moved functionality from server to client. Coverage will be restored with Issue #149. * Start working on refactoring to js * Refactor map elements to js * Remove style from head * removed brackets as suggested * Fix variable erroneously dumped to page fixes Places::DESTINATIONS variable being dumped into HTML (introduced in #102) * Restore package-lock.json and other feedback * First steps on new js conversion Co-authored-by: TheGrayStone <[email protected]> Co-authored-by: Julian Schmidt <[email protected]> * Refactor routing display * Add Route to its own layer * Trying to fix tests with js * Comment on old magic constant * Adapt tests for routing * linting stuff * Remove test for targets, minor fixes * [CodeFactor] Apply fixes * Remove old map from locations, needs more fixing * Extra js file for leaflet Map * prepare locations show * Remove map from location page * add debugging help to routing tests * add waiting time for routing * remove unnecessary code * adding wait_for_ajax to route tests * Remove old unused code (Commented for target) * tag tests and improve backend routes * improved tagging to new syntax * exclude tests with the tag "local_only" * add jQuery as requested * code cleanup for jQuery * enable indoor rooms from hg * add target marker functionality * remove old variable on index * [CodeFactor] Apply fixes * a try on fixing tests * [CodeFactor] Apply fixes * fix CodeFactor issue * improve tests with find and waiting time * edit tags for tests * remove parallel execution in js * remove wait_for_ajax * run route tests only local * restore yarn.lock * add newline to yarn.lock * Code improvements * [CodeFactor] Apply fixes * Fix magic string * possible fix for routing tests * Parallelize ajax requests Co-authored-by: Julian Schmidt * reverse changes for parallel ajax * add comment about race condition * Paralize ajax requests WITH tests * remove tests for routing (race condition) Co-authored-by: Lukas Rost <[email protected]> Co-authored-by: TheGrayStone <[email protected]> Co-authored-by: Julian Schmidt <[email protected]> Co-authored-by: codefactor-io <[email protected]>
We removed the ruby gem for leaflet and do the map with plain js.