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

Add profile location #5302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nertc
Copy link
Contributor

@nertc nertc commented Nov 5, 2024

PR adds location name info on the user profile page. Location name can be changed from "Edit Profile" page either by manual typing or auto-filling according to the home location.

One column was added to the user table to save user's location.
JS logics are responsible for handling:

  1. Delete-Undelete buttons interactions
  2. Nominatim calls to locate home locations country name
  3. Warning logic of the location name

image
image
image

@nertc nertc marked this pull request as draft November 5, 2024 08:41
@nertc nertc force-pushed the issues_add_profile_location branch from d20e90d to e5de628 Compare November 5, 2024 08:52
@nertc nertc marked this pull request as ready for review November 5, 2024 09:02
@tomhughes
Copy link
Member

This seems like an awful lot of complication...

It seems to me that we have the option of either allowing the user to input freetext, or of generating something from the location with Nominatim but this tries to do both at once which just makes things very complicated and probably quite confusing.

How often does nomination actually manage to match? I don't see any indication of zoom on the reverse geocode, and you're just taking the last name, so how likely is it that will match what the user entered even if they are trying to be accurate? Are we just going to wind up telling everybody their location doesn't match?

@nertc
Copy link
Contributor Author

nertc commented Nov 8, 2024

@tomhughes Thank you for the comment. I agree with you about the complexity of the code, but there are several reasons for both methods.

Changing location name manually solves cases like:

  1. Disputed areas - someone living in the area A may not want to show that area is part of country B and not C.
  2. Several countries - someone who has citizenship of several countries may want to set his location name to something like "Georgia & Germany"
  3. Choosing privacy - someone may want to explicitly mention "Tbilisi, Georgia", but someone may want to just show the country and keep other details private

Meanwhile, changing location with Nominatim autofill introduces:

  1. Better UX - if user is okay with showing only home country, autofill avoids extra typing from user
  2. Standardization - default value introduces default standard for user to easily perceive what kind of and what detalization of information is recommended for the field
  3. Motivation to fill - when user sees a warning about the field that it doesn't match home location, it subconsciously motivates him to click the autofill button (just one easy click) and increases use of the feature

By choosing only one solution we sacrifice either functionality or better UX.

Currently, autofill suggests name of the country and warning is only shown if manually typed location doesn't contain country name. Therefore, "Germany & Georgia", "Tbilisi, Georgia", "Georgia" won't show any autofill warning if user has home location set in Georgia.

user = create(:user)
sign_in_as(user)

visit user_path(user.display_name)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You write it differently below

Suggested change
visit user_path(user.display_name)
visit user_path(user)

const geocodeUrl = `${OSM.NOMINATIM_URL}reverse?format=json&lat=${lat}&lon=${lon}`;

if (locationInput.request) locationInput.request.abort();
locationInput.request = $.getJSON(geocodeUrl, function (data) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

blocked by content security policy

Comment on lines +57 to +60
<div id="location_name_warning" class="row align-items-center d-none">
<p class="m-0 w-auto fs-6 pe-1"><%= t ".location_name_warning" %></p>
<button id="location_default_name" class="btn btn-link p-0 w-auto text-sm-start" type="button"></button>
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like a sentence and it's not obvious that it ends with a button I'm supposed to click to update the value:

image

return;
}

const geocodeUrl = `${OSM.NOMINATIM_URL}reverse?format=json&lat=${lat}&lon=${lon}`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If you only want a country why don't you ask for a country

Suggested change
const geocodeUrl = `${OSM.NOMINATIM_URL}reverse?format=json&lat=${lat}&lon=${lon}`;
const geocodeUrl = `${OSM.NOMINATIM_URL}reverse?format=json&lat=${lat}&lon=${lon}&zoom=3`;

instead of getting a full address of things you don't care about and then doing .split(",")?

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.

3 participants