Skip to content
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

Auto-complete address and coordinates of locations #1744

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

MizukiTemma
Copy link
Member

@MizukiTemma MizukiTemma commented Oct 10, 2022

Short description

Currently coordinates of a POI appears (if left blank) first after the POI is saved.
This PR auto fills coordinates live while editing when the address of POI is completed.

Proposed changes

  • Add event listeners in the address fields.
  • Coordinates will be searched live while an user is filling the address fields.

Side effects

  • So far not known

Resolved issues

Part of: #1000


Pull Request Review Guidelines

@MizukiTemma MizukiTemma requested a review from a team as a code owner October 10, 2022 22:29
@codeclimate
Copy link

codeclimate bot commented Oct 10, 2022

Code Climate has analyzed commit 9c219c2 and detected 1 issue on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1

The test coverage on the diff in this pull request is 45.4% (50% is the threshold).

This pull request will bring the total coverage in the repository to 74.4% (0.0% change).

View more on Code Climate.

@MizukiTemma MizukiTemma marked this pull request as draft October 10, 2022 22:40
@MizukiTemma MizukiTemma force-pushed the Autofill-Coordinates branch 2 times, most recently from c2aee7e to 24267a2 Compare October 10, 2022 23:22
@MizukiTemma MizukiTemma marked this pull request as ready for review October 10, 2022 23:32
Copy link
Contributor

@sarahsporck sarahsporck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice work!
Tested and seems to work correctly 👌🏼

I think you can adjust the help text of the longitude/latitude field in the poi_form, as they are now inferred live :) Maybe something like Geographische Länge und Breite werden automatisch aus der Adresse abgeleitet.

Further I'm a little bit worried about people who want to set longitude and latitude to a different value as the address. In this case changing the Address would mean to overwrite the longitude and latitude value. Maybe the users should be able to opt-out from inferring by adding a tick box Länge und Breite aus der Addresse ableiten?
This would also make the help text for longitude and latitude irrelevant, I guess.

@MizukiTemma
Copy link
Member Author

@sarahsporck
Thnak you for your review :)

Now the tick box is added so users can choose whether the coordinates are to be auto-filled.
When they once checked the box but uncheck it afterwords, the original value of coordinates will be restored.

Copy link
Member

@david-venhoff david-venhoff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! This pr works as expected, I just found a few typos and smaller problems:

integreat_cms/cms/views/pois/poi_actions.py Outdated Show resolved Hide resolved
integreat_cms/cms/views/pois/poi_actions.py Outdated Show resolved Hide resolved
integreat_cms/cms/views/pois/poi_actions.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
integreat_cms/cms/templates/pois/poi_form.html Outdated Show resolved Hide resolved
integreat_cms/locale/de/LC_MESSAGES/django.po Outdated Show resolved Hide resolved
Copy link
Member

@timobrembeck timobrembeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, really cool feature! 🚀

Just because you linked issue #1000 as fixed: I'm very sorry if the issue was misleading - the checked items were not the tasks to work on, but the tasks that were already done... so in theory I already considered the previous solution with fetching the coordinates after form submission sufficient - nevertheless very cool feature to fetch them dynamically! 👍
I just wanted to point out that this PR does not fix the issue - it just improves one part of it which was already done.

integreat_cms/cms/templates/pois/poi_form.html Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
integreat_cms/cms/views/pois/poi_actions.py Show resolved Hide resolved
integreat_cms/cms/views/pois/poi_actions.py Outdated Show resolved Hide resolved
integreat_cms/cms/views/pois/poi_actions.py Show resolved Hide resolved
integreat_cms/cms/templates/pois/poi_form.html Outdated Show resolved Hide resolved
@MizukiTemma MizukiTemma force-pushed the Autofill-Coordinates branch 3 times, most recently from 73e4f70 to 07c2ebf Compare October 13, 2022 13:14
@MizukiTemma
Copy link
Member Author

@timoludwig
Cool improvement 😄 Thank you!

Sorry that I have misunderstoot the issue. I'll now add other (not yet checked) features 🙂

Copy link
Member

@timobrembeck timobrembeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A few small details, then this PR is ready to be merged! 🎉

I'll now add other (not yet checked) features 🙂

Well, I mean those are just ideas, if you notice that some of them are too much work for the benefit they provide, you can also edit the issue and explain why you reject a specific point 😁

integreat_cms/cms/views/pois/poi_actions.py Outdated Show resolved Hide resolved
integreat_cms/cms/templates/pois/poi_form.html Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
integreat_cms/static/src/js/pois/poi-actions.ts Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@MizukiTemma
Copy link
Member Author

MizukiTemma commented Oct 13, 2022

Now the ajax call for the coordination will be called if street and postcode are filled (city is not anymore an necessary firing condition).

When coordinates are found from the street and postcode, this proves (I think) the validity of street input. Users can know something is not correctly given, seeing an error from this calculation.

From those coordinates the city will be calculated.
This is needed because data which geocode calclulates with the combination of street and postcode has the address as one string without attribute like "city" or "comunity (Landkreis)" and there is no guaranty on which positioin the city name stands: whether the address is in a Landkreis or kreisfreie Stadt makes a difference on the position of city name.

The calculated city will be auto-filled (or replace the old input if the new address is in another city). The country field will be now auto-filled too.

@MizukiTemma
Copy link
Member Author

Thanks! A few small details, then this PR is ready to be merged! 🎉

I'll now add other (not yet checked) features 🙂

Well, I mean those are just ideas, if you notice that some of them are too much work for the benefit they provide, you can also edit the issue and explain why you reject a specific point 😁

Oh oh... I read this comment just now...... 😅

@MizukiTemma MizukiTemma force-pushed the Autofill-Coordinates branch 3 times, most recently from c10a5a9 to e0e90a8 Compare October 15, 2022 09:40
@timobrembeck timobrembeck changed the title Auto-fill coordinates when address is complete Auto-complete address and coordinates of locations Oct 15, 2022
Co-authored-by: David Venhoff <venhoff@integreat-app.de>
Co-authored-by: Timo Ludwig <ludwig@integreat-app.de
Copy link
Member

@timobrembeck timobrembeck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot, I really think this makes creating POIs much easier! 🚀
I had a few ideas for improvement which were outside the area GitHub allowed me to post suggestions for, so I directly pushed to your branch 😇
I tried to explain my changes in the comments below:

@MizukiTemma
Copy link
Member Author

@timoludwig
Cool improvement! Thank you for your aid 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants